Skip to content

Commit

Permalink
Merge pull request #1 from Briinah/circular-drive-attach
Browse files Browse the repository at this point in the history
Circular drive attach
  • Loading branch information
Roland Fredenhagen authored Mar 27, 2021
2 parents 9442d7d + 8650f3c commit de55bd1
Showing 1 changed file with 35 additions and 24 deletions.
59 changes: 35 additions & 24 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 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

0 comments on commit de55bd1

Please sign in to comment.