Skip to content

Commit

Permalink
fix(Pointer): ensure visibility and interaction states are toggled
Browse files Browse the repository at this point in the history
There was an issue where the cursor and tracer visibility could not
be toggled to always visible unless a toggle event was called.

There was another issue where if the tracer or cursor was active
that the interaction object would not be enabled until the pointer
activation button was pressed.

This has now been fixed by ensuring the correct state of the tracer
and cursor visibility is checked taking into account the visibility
state. Also, if the tracer or cursor is visible even when the
pointer activation button hasn't been pressed then the object
interactor will be activate.
  • Loading branch information
thestonefox committed Feb 20, 2017
1 parent 8d796fa commit 1cdf73e
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,20 @@ public virtual void Toggle(bool pointerState, bool actualState)
controllingPointer.ResetActivationTimer();
PointerExit(destinationHit);
}
ToggleObjectInteraction(pointerState);
ToggleInteraction(pointerState);
TogglePlayArea(pointerState, actualState);
ToggleRenderer(pointerState, actualState);
}

/// <summary>
/// The ToggleInteraction method is used to enable or disable the controller extension interactions.
/// </summary>
/// <param name="state">If true then the object interactor will be enabled.</param>
public virtual void ToggleInteraction(bool state)
{
ToggleObjectInteraction(state);
}

/// <summary>
/// The UpdateRenderer method is used to run an Update routine on the pointer.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class VRTK_BezierPointerRenderer : VRTK_BasePointerRenderer
/// </summary>
public override void UpdateRenderer()
{
if ((controllingPointer && controllingPointer.IsPointerActive()) || tracerVisible || cursorVisible)
if ((controllingPointer && controllingPointer.IsPointerActive()) || IsTracerVisible() || IsCursorVisible())
{
Vector3 jointPosition = ProjectForwardBeam();
Vector3 downPosition = ProjectDownBeam(jointPosition);
Expand Down Expand Up @@ -135,6 +135,16 @@ protected override void ChangeMaterial(Color givenColor)
ChangeMaterialColor(actualCursor, givenColor);
}

protected virtual bool IsTracerVisible()
{
return (tracerVisibility == VisibilityStates.AlwaysOn || tracerVisible);
}

protected virtual bool IsCursorVisible()
{
return (cursorVisibility == VisibilityStates.AlwaysOn || cursorVisible);
}

protected virtual void CreateTracer()
{
actualTracer = actualContainer.gameObject.AddComponent<VRTK_CurveGenerator>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class VRTK_StraightPointerRenderer : VRTK_BasePointerRenderer
/// </summary>
public override void UpdateRenderer()
{
if ((controllingPointer && controllingPointer.IsPointerActive()) || tracerVisible || cursorVisible)
if ((controllingPointer && controllingPointer.IsPointerActive()) || IsTracerVisible() || IsCursorVisible())
{
float tracerLength = CastRayForward();
SetPointerAppearance(tracerLength);
Expand Down Expand Up @@ -102,6 +102,16 @@ protected override void UpdateObjectInteractor()
}
}

protected virtual bool IsTracerVisible()
{
return (tracerVisibility == VisibilityStates.AlwaysOn || tracerVisible);
}

protected virtual bool IsCursorVisible()
{
return (cursorVisibility == VisibilityStates.AlwaysOn || cursorVisible);
}

protected virtual void CreateTracer()
{
if (customTracer)
Expand Down
5 changes: 5 additions & 0 deletions Assets/VRTK/Scripts/Pointers/VRTK_Pointer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ protected virtual void Update()
{
pointerRenderer.InitalizePointer(this, invalidListPolicy, navMeshCheckDistance, headsetPositionCompensation);
pointerRenderer.UpdateRenderer();
if (!IsPointerActive())
{
bool interactionState = (pointerRenderer.tracerVisibility == VRTK_BasePointerRenderer.VisibilityStates.AlwaysOn || pointerRenderer.cursorVisibility == VRTK_BasePointerRenderer.VisibilityStates.AlwaysOn);
pointerRenderer.ToggleInteraction(interactionState);
}
}
}

Expand Down
11 changes: 11 additions & 0 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,17 @@ The InitalizePointer method is used to set up the state of the pointer renderer.

The Toggle Method is used to enable or disable the pointer renderer.

#### ToggleInteraction/1

> `public virtual void ToggleInteraction(bool state)`
* Parameters
* `bool state` - If true then the object interactor will be enabled.
* Returns
* _none_

The ToggleInteraction method is used to enable or disable the controller extension interactions.

#### UpdateRenderer/0

> `public virtual void UpdateRenderer()`
Expand Down

0 comments on commit 1cdf73e

Please sign in to comment.