Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circular Drive is attached to hand similar to Linear Drive #304

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 36 additions & 25 deletions Assets/SteamVR/InteractionSystem/Core/Scripts/CircularDrive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,22 @@ public enum Axis_t
public TextMesh debugText = null;

[Tooltip( "The output angle value of the drive in degrees, unlimited will increase or decrease without bound, take the 360 modulus to find number of rotations" )]
public float outAngle;
[SerializeField]
private float outAngle;

public float OutAngle
{
get
{
return outAngle;
}
set
{
outAngle = value;
UpdateAll();
}
}


private Quaternion start;

Expand All @@ -93,7 +108,7 @@ public enum Axis_t

private bool driving = false;

// If the drive is limited as is at min/max, angles greater than this are ignored
// If the drive is limited as is at min/max, angles greater than this are ignored
private float minMaxAngularThreshold = 1.0f;

private bool frozen = false;
Expand Down Expand Up @@ -243,11 +258,9 @@ private void OnHandHoverEnd( Hand hand )
private void HandHoverUpdate( Hand hand )
{
GrabTypes startingGrabType = hand.GetGrabStarting();
bool isGrabEnding = hand.IsGrabbingWithType(grabbedWithType) == false;

if (grabbedWithType == GrabTypes.None && startingGrabType != GrabTypes.None)
if (interactable.attachedToHand == null && startingGrabType != GrabTypes.None)
{
grabbedWithType = startingGrabType;
// Trigger was just pressed
lastHandProjected = ComputeToTransformProjected( hand.hoverSphereTransform );

Expand All @@ -259,30 +272,28 @@ private void HandHoverUpdate( Hand hand )

driving = true;

ComputeAngle( hand );
UpdateAll();

hand.AttachObject(gameObject, startingGrabType, attachmentFlags);
hand.HideGrabHint();
}
else if (grabbedWithType != GrabTypes.None && isGrabEnding)
{
// Trigger was just released
if ( hoverLock )
{
hand.HoverUnlock(interactable);
handHoverLocked = null;
}
}
}

driving = false;
grabbedWithType = GrabTypes.None;
protected virtual void HandAttachedUpdate(Hand hand)
{
ComputeAngle(hand);
UpdateAll();

if (hand.IsGrabEnding(this.gameObject))
{
hand.DetachObject(gameObject);

if (hoverLock)
{
hand.HoverUnlock(interactable);
handHoverLocked = null;
}
}
}

if ( driving && isGrabEnding == false && hand.hoveringInteractable == this.interactable )
{
ComputeAngle( hand );
UpdateAll();
}
}


//-------------------------------------------------
Expand Down