diff --git a/Features/Input/GazeProvider.cs b/Features/Input/GazeProvider.cs
index 5dfe8981..ca99d14a 100644
--- a/Features/Input/GazeProvider.cs
+++ b/Features/Input/GazeProvider.cs
@@ -202,14 +202,14 @@ public override void OnPreRaycast()
public override void OnPostRaycast()
{
- gazeProvider.HitInfo = Result.Details.LastRaycastHit;
- gazeProvider.GazeTarget = Result.Details.Object;
+ gazeProvider.HitInfo = Result.LastRaycastHit;
+ gazeProvider.GazeTarget = Result.CurrentPointerTarget;
- if (Result.Details.Object != null)
+ if (Result.CurrentPointerTarget != null)
{
- gazeProvider.lastHitDistance = (Result.Details.Point - Rays[0].Origin).magnitude;
+ gazeProvider.lastHitDistance = (Result.EndPoint - Rays[0].Origin).magnitude;
gazeProvider.HitPosition = Rays[0].Origin + (gazeProvider.lastHitDistance * Rays[0].Direction);
- gazeProvider.HitNormal = Result.Details.Normal;
+ gazeProvider.HitNormal = Result.Normal;
}
}
diff --git a/Features/Input/Handlers/BaseFocusHandler.cs b/Features/Input/Handlers/BaseFocusHandler.cs
index 34ba7e7b..4e498603 100644
--- a/Features/Input/Handlers/BaseFocusHandler.cs
+++ b/Features/Input/Handlers/BaseFocusHandler.cs
@@ -56,7 +56,7 @@ public virtual void OnBeforeFocusChange(FocusEventData eventData)
// add the pointer to the list of focusers.
if (eventData.NewFocusedObject == gameObject)
{
- eventData.Pointer.FocusTarget = this;
+ eventData.Pointer.FocusHandler = this;
activePointers.Add(eventData.Pointer);
}
// If we're the old focused target object,
@@ -69,7 +69,7 @@ public virtual void OnBeforeFocusChange(FocusEventData eventData)
// clear the FocusTarget field from the Pointer.
if (eventData.NewFocusedObject == null)
{
- eventData.Pointer.FocusTarget = null;
+ eventData.Pointer.FocusHandler = null;
}
}
}
diff --git a/Features/Input/Handlers/DragAndDropHandler.cs b/Features/Input/Handlers/DragAndDropHandler.cs
index 5a101b81..85b0a7e3 100644
--- a/Features/Input/Handlers/DragAndDropHandler.cs
+++ b/Features/Input/Handlers/DragAndDropHandler.cs
@@ -125,8 +125,8 @@ void IMixedRealityPointerHandler.OnPointerDown(MixedRealityPointerEventData even
currentInputSource = eventData.InputSource;
currentPointer = eventData.Pointer;
- Vector3 initialDraggingPosition = MixedRealityToolkit.InputSystem.FocusProvider.TryGetFocusDetails(currentPointer, out FocusDetails focusDetails)
- ? focusDetails.Point
+ Vector3 initialDraggingPosition = MixedRealityToolkit.InputSystem.FocusProvider.TryGetFocusDetails(currentPointer, out var focusDetails)
+ ? focusDetails.EndPoint
: hostTransform.position;
StartDragging(initialDraggingPosition);
diff --git a/Features/Input/Handlers/ManipulationHandler.cs b/Features/Input/Handlers/ManipulationHandler.cs
index 1d7f4ea4..44cc2996 100644
--- a/Features/Input/Handlers/ManipulationHandler.cs
+++ b/Features/Input/Handlers/ManipulationHandler.cs
@@ -277,6 +277,8 @@ public Vector2 NudgeConstraints
#endregion Manipulation Options
+ #region Properties
+
///
/// The current status of the hold.
///
@@ -285,29 +287,6 @@ public Vector2 NudgeConstraints
///
public bool IsBeingHeld { get; private set; } = false;
- ///
- /// The updated extent of the pointer.
- ///
- private float updatedExtent;
-
- /// The updated scale of the model based on controller input.
- private Vector3 updatedScale;
-
- ///
- /// The first input source to start the manipulation phase of this object.
- ///
- private IMixedRealityInputSource primaryInputSource = null;
-
- ///
- /// The first pointer to start the manipulation phase of this object.
- ///
- private IMixedRealityPointer primaryPointer = null;
-
- ///
- /// The last rotation reading used to calculate if the rotation action is active.
- ///
- private Vector2 lastPositionReading = Vector2.zero;
-
///
/// Is the currently pressed?
///
@@ -333,18 +312,29 @@ public Vector2 NudgeConstraints
///
public bool IsRotationPossible { get; private set; } = false;
- private Vector3 prevScale = Vector3.one;
- private Vector3 prevPosition = Vector3.zero;
- private Quaternion prevRotation = Quaternion.identity;
-
- private Vector3 grabbedPosition = Vector3.zero;
+ #endregion Properties
private BoundingBox boundingBox;
- private float prevPointerExtent;
+ private IMixedRealityPointer primaryPointer;
+
+ private IMixedRealityInputSource primaryInputSource;
private int prevPhysicsLayer;
private int boundingBoxPrevPhysicsLayer;
+ private SpatialMeshDisplayOptions prevSpatialMeshDisplay;
+
+ private float updatedExtent;
+ private float prevPointerExtent;
+
+ private Vector2 lastPositionReading;
+
+ private Vector3 prevScale;
+ private Vector3 prevPosition;
+ private Vector3 updatedScale;
+ private Vector3 grabbedPosition;
+
+ private Quaternion prevRotation;
#region Monobehaviour Implementation
@@ -362,7 +352,7 @@ protected virtual void Update()
{
if (!IsBeingHeld || primaryPointer == null) { return; }
- var pointerPosition = primaryPointer.Result.Details.Point;
+ var pointerPosition = primaryPointer.Result.EndPoint;
if (!IsPressed)
{
@@ -375,6 +365,7 @@ protected virtual void Update()
{
if (IsNudgePossible)
{
+ manipulationTarget.position = grabbedPosition + pointerPosition;
primaryPointer.PointerExtent = updatedExtent;
}
else if (IsScalingPossible)
@@ -396,6 +387,9 @@ protected override void OnDisable()
if (IsBeingHeld)
{
+ // We don't pass IsCancelled here because
+ // it's the intended behaviour to end the hold
+ // if the component is disabled.
EndHold();
}
}
@@ -482,7 +476,7 @@ public virtual void OnInputChanged(InputEventData eventData)
return;
}
- var pointerPosition = primaryPointer.Result.Details.Point;
+ var pointerPosition = primaryPointer.Result.EndPoint;
// Filter our actions
if (eventData.MixedRealityInputAction != nudgeAction ||
@@ -566,7 +560,7 @@ public virtual void OnInputChanged(InputEventData eventData)
{
Debug.Assert(primaryPointer != null);
var newExtent = primaryPointer.PointerExtent;
- var currentRaycastDistance = primaryPointer.Result.Details.RayDistance;
+ var currentRaycastDistance = primaryPointer.Result.RayDistance;
// Reset the cursor extent to the nearest value in case we're hitting something close
// and the user wants to adjust. That way it doesn't take forever to see the change.
@@ -620,27 +614,6 @@ public virtual void OnInputChanged(InputEventData eventData)
}
}
- ///
- /// Calculates the extent of the nudge.
- ///
- /// The event data.
- /// The previous extent distance of the pointer and raycast.
- /// The new pointer extent.
- protected virtual float CalculateNudgeDistance(InputEventData eventData, float prevExtent)
- {
- return prevExtent + nudgeAmount * (eventData.InputData.y < 0f ? -1 : 1);
- }
-
- protected virtual Vector3 CalculateScaleAmount(InputEventData eventData, Vector3 prevScale)
- {
- if (eventData.InputData.x < 0f)
- {
- return prevScale *= scaleAmount;
- }
- // else
- return prevScale /= scaleAmount;
- }
-
#endregion IMixedRealityInputHandler Implementation
#region IMixedRealityPointerHandler Implementation
@@ -716,9 +689,14 @@ public virtual void BeginHold(MixedRealityPointerEventData eventData)
}
MixedRealityToolkit.InputSystem.PushModalInputHandler(gameObject);
- MixedRealityToolkit.SpatialAwarenessSystem.SetMeshVisibility(spatialMeshVisibility);
- var pointerPosition = primaryPointer.Result.Details.Point;
+ if (MixedRealityToolkit.SpatialAwarenessSystem != null)
+ {
+ prevSpatialMeshDisplay = MixedRealityToolkit.SpatialAwarenessSystem.SpatialMeshVisibility;
+ MixedRealityToolkit.SpatialAwarenessSystem.SpatialMeshVisibility = spatialMeshVisibility;
+ }
+
+ var pointerPosition = primaryPointer.Result.EndPoint;
prevPosition = manipulationTarget.position;
@@ -728,7 +706,7 @@ public virtual void BeginHold(MixedRealityPointerEventData eventData)
prevPointerExtent = primaryPointer.PointerExtent;
// update the pointer extent to prevent the object from popping to the end of the pointer
- var currentRaycastDistance = primaryPointer.Result.Details.RayDistance;
+ var currentRaycastDistance = primaryPointer.Result.RayDistance;
primaryPointer.PointerExtent = currentRaycastDistance;
}
@@ -757,11 +735,12 @@ public virtual void EndHold(bool isCanceled = false)
{
if (!IsBeingHeld) { return; }
- MixedRealityToolkit.SpatialAwarenessSystem.SetMeshVisibility(SpatialMeshDisplayOptions.None);
+ if (MixedRealityToolkit.SpatialAwarenessSystem != null)
+ {
+ MixedRealityToolkit.SpatialAwarenessSystem.SpatialMeshVisibility = prevSpatialMeshDisplay;
+ }
primaryPointer.PointerExtent = prevPointerExtent;
- primaryPointer = null;
- primaryInputSource = null;
if (isCanceled)
{
@@ -770,7 +749,6 @@ public virtual void EndHold(bool isCanceled = false)
manipulationTarget.rotation = prevRotation;
}
- IsBeingHeld = false;
MixedRealityToolkit.InputSystem.PopModalInputHandler();
manipulationTarget.SetLayerRecursively(prevPhysicsLayer);
@@ -779,6 +757,32 @@ public virtual void EndHold(bool isCanceled = false)
{
boundingBox.transform.SetLayerRecursively(boundingBoxPrevPhysicsLayer);
}
+
+ primaryPointer = null;
+ primaryInputSource = null;
+ IsBeingHeld = false;
+ }
+
+ ///
+ /// Calculates the extent of the nudge using input event data.
+ ///
+ /// The event data.
+ /// The previous extent distance of the pointer and raycast.
+ /// The new pointer extent.
+ protected virtual float CalculateNudgeDistance(InputEventData eventData, float prevExtent)
+ {
+ return prevExtent + nudgeAmount * (eventData.InputData.y < 0f ? -1 : 1);
+ }
+
+ ///
+ /// Calculates the scale amount using the input event data.
+ ///
+ /// The event data.
+ /// The previous scale
+ /// The new scale value.
+ protected virtual Vector3 CalculateScaleAmount(InputEventData eventData, Vector3 scale)
+ {
+ return eventData.InputData.x < 0f ? scale * scaleAmount : scale / scaleAmount;
}
}
}
diff --git a/Features/UX/Scripts/Cursors/BaseCursor.cs b/Features/UX/Scripts/Cursors/BaseCursor.cs
index 81fa91bc..d9cea0ec 100644
--- a/Features/UX/Scripts/Cursors/BaseCursor.cs
+++ b/Features/UX/Scripts/Cursors/BaseCursor.cs
@@ -401,9 +401,9 @@ protected virtual void UpdateCursorTransform()
// If no modifier is on the target, just use the hit result to set cursor position
// Get the look forward by using distance between pointer origin and target position
// (This may not be strictly accurate for extremely wobbly pointers, but it should produce usable results)
- var distanceToTarget = Vector3.Distance(Pointer.Rays[0].Origin, focusDetails.Point);
+ var distanceToTarget = Vector3.Distance(Pointer.Rays[0].Origin, focusDetails.EndPoint);
lookForward = -RayStep.GetDirectionByDistance(Pointer.Rays, distanceToTarget);
- targetPosition = focusDetails.Point + (lookForward * surfaceCursorDistance);
+ targetPosition = focusDetails.EndPoint + (lookForward * surfaceCursorDistance);
var lookRotation = Vector3.Slerp(focusDetails.Normal, lookForward, lookRotationBlend);
targetRotation = Quaternion.LookRotation(lookRotation == Vector3.zero ? lookForward : lookRotation, Vector3.up);
}
@@ -416,9 +416,9 @@ protected virtual void UpdateCursorTransform()
// Use the lerp times to blend the position to the target position
var cachedTransform = transform;
- if (Pointer.IsFocusLocked && Pointer.IsTargetPositionLockedOnFocusLock && focusDetails.Object != null)
+ if (Pointer.IsFocusLocked && Pointer.SyncPointerTargetPosition && focusDetails.CurrentPointerTarget != null)
{
- cachedTransform.position = focusDetails.Point;
+ cachedTransform.position = focusDetails.EndPoint;
}
else
{
diff --git a/Features/UX/Scripts/Cursors/CursorModifier.cs b/Features/UX/Scripts/Cursors/CursorModifier.cs
index b31dc7df..3499affd 100644
--- a/Features/UX/Scripts/Cursors/CursorModifier.cs
+++ b/Features/UX/Scripts/Cursors/CursorModifier.cs
@@ -128,10 +128,10 @@ public Vector3 GetModifiedPosition(IMixedRealityCursor cursor)
return Vector3.zero;
}
- if (MixedRealityToolkit.InputSystem != null && MixedRealityToolkit.InputSystem.FocusProvider.TryGetFocusDetails(cursor.Pointer, out FocusDetails focusDetails))
+ if (MixedRealityToolkit.InputSystem != null && MixedRealityToolkit.InputSystem.FocusProvider.TryGetFocusDetails(cursor.Pointer, out var focusDetails))
{
// Else, consider the modifiers on the cursor modifier, but don't snap
- return focusDetails.Point + HostTransform.TransformVector(CursorPositionOffset);
+ return focusDetails.EndPoint + HostTransform.TransformVector(CursorPositionOffset);
}
return Vector3.zero;
diff --git a/Features/UX/Scripts/Cursors/TeleportCursor.cs b/Features/UX/Scripts/Cursors/TeleportCursor.cs
index 765d5c30..6e3552ae 100644
--- a/Features/UX/Scripts/Cursors/TeleportCursor.cs
+++ b/Features/UX/Scripts/Cursors/TeleportCursor.cs
@@ -88,7 +88,7 @@ protected override void UpdateCursorTransform()
return;
}
- if (!MixedRealityToolkit.InputSystem.FocusProvider.TryGetFocusDetails(Pointer, out FocusDetails focusDetails))
+ if (!MixedRealityToolkit.InputSystem.FocusProvider.TryGetFocusDetails(Pointer, out var focusDetails))
{
if (MixedRealityToolkit.InputSystem.FocusProvider.IsPointerRegistered(Pointer))
{
@@ -102,11 +102,9 @@ protected override void UpdateCursorTransform()
return;
}
- if (pointer.Result == null) { return; }
+ transform.position = focusDetails.EndPoint;
- transform.position = pointer.Result.Details.Point;
-
- Vector3 forward = CameraCache.Main.transform.forward;
+ var forward = CameraCache.Main.transform.forward;
forward.y = 0f;
// Smooth out rotation just a tad to prevent jarring transitions
diff --git a/Features/UX/Scripts/Pointers/BaseControllerPointer.cs b/Features/UX/Scripts/Pointers/BaseControllerPointer.cs
index fecb86db..12f764d7 100644
--- a/Features/UX/Scripts/Pointers/BaseControllerPointer.cs
+++ b/Features/UX/Scripts/Pointers/BaseControllerPointer.cs
@@ -260,15 +260,8 @@ public virtual bool IsInteractionEnabled
///
public bool IsFocusLocked { get; set; }
- [SerializeField]
- private bool isTargetPositionLockedOnFocusLock;
-
///
- public bool IsTargetPositionLockedOnFocusLock
- {
- get => isTargetPositionLockedOnFocusLock;
- set => isTargetPositionLockedOnFocusLock = value;
- }
+ public bool SyncPointerTargetPosition { get; set; }
[SerializeField]
private bool overrideGlobalPointerExtent = false;
@@ -320,7 +313,10 @@ public float PointerExtent
public LayerMask[] PrioritizedLayerMasksOverride { get; set; } = null;
///
- public IMixedRealityFocusHandler FocusTarget { get; set; }
+ public IMixedRealityFocusHandler FocusHandler { get; set; }
+
+ ///
+ public IMixedRealityInputHandler InputHandler { get; set; }
///
public IPointerResult Result { get; set; }
diff --git a/Features/UX/Scripts/Pointers/LinePointer.cs b/Features/UX/Scripts/Pointers/LinePointer.cs
index 41c593df..1c004173 100644
--- a/Features/UX/Scripts/Pointers/LinePointer.cs
+++ b/Features/UX/Scripts/Pointers/LinePointer.cs
@@ -116,13 +116,13 @@ public override void OnPreRaycast()
// Set our first and last points
lineBase.FirstPoint = pointerPosition;
- if (!IsFocusLocked || Result == null)
+ if (IsFocusLocked)
{
- lineBase.LastPoint = pointerPosition + pointerRotation * Vector3.forward * PointerExtent;
+ lineBase.LastPoint = Result.EndPoint;
}
else
{
- lineBase.LastPoint = Result.Details.Point;
+ lineBase.LastPoint = pointerPosition + pointerRotation * Vector3.forward * PointerExtent;
}
// Make sure our array will hold
@@ -167,9 +167,9 @@ public override void OnPostRaycast()
float cursorOffsetWorldLength = BaseCursor?.SurfaceCursorDistance ?? 0f;
// If we hit something
- if (Result?.CurrentPointerTarget != null)
+ if (Result.CurrentPointerTarget != null)
{
- clearWorldLength = Result.Details.RayDistance;
+ clearWorldLength = Result.RayDistance;
lineColor = IsSelectPressed ? LineColorSelected : LineColorValid;
}
else
@@ -196,7 +196,7 @@ public override void OnPostRaycast()
// If focus is locked, we're sticking to the target
// So don't clamp the world length
- if (IsFocusLocked && IsTargetPositionLockedOnFocusLock)
+ if (IsFocusLocked && SyncPointerTargetPosition)
{
float cursorOffsetLocalLength = LineBase.GetNormalizedLengthFromWorldLength(cursorOffsetWorldLength);
LineBase.LineEndClamp = 1 - cursorOffsetLocalLength;
diff --git a/Features/UX/Scripts/Pointers/TeleportPointer.cs b/Features/UX/Scripts/Pointers/TeleportPointer.cs
index 9ede752a..90f87f41 100644
--- a/Features/UX/Scripts/Pointers/TeleportPointer.cs
+++ b/Features/UX/Scripts/Pointers/TeleportPointer.cs
@@ -173,7 +173,7 @@ public override void OnPostRaycast()
{
// If it's NOT a hotspot, check if the hit normal is too steep
// (Hotspots override dot requirements)
- TeleportSurfaceResult = Vector3.Dot(Result.Details.LastRaycastHit.normal, Vector3.up) > upDirectionThreshold
+ TeleportSurfaceResult = Vector3.Dot(Result.LastRaycastHit.normal, Vector3.up) > upDirectionThreshold
? TeleportSurfaceResult.Valid
: TeleportSurfaceResult.Invalid;
}
@@ -202,7 +202,7 @@ public override void OnPostRaycast()
}
// Only add the distance between the start point and the hit
- clearWorldLength += Vector3.Distance(Result.StartPoint, Result.Details.Point);
+ clearWorldLength += Vector3.Distance(Result.StartPoint, Result.EndPoint);
}
else if (i < Result.RayStepIndex)
{
diff --git a/Features/UX/Scripts/Pointers/TouchPointer.cs b/Features/UX/Scripts/Pointers/TouchPointer.cs
index a57348d1..276df9af 100644
--- a/Features/UX/Scripts/Pointers/TouchPointer.cs
+++ b/Features/UX/Scripts/Pointers/TouchPointer.cs
@@ -66,7 +66,9 @@ public override bool TryGetPointerPosition(out Vector3 position)
{
position = Vector3.zero;
if (fingerId < 0) { return false; }
- position = Result?.Details.Point ?? CameraCache.Main.ScreenPointToRay(UnityEngine.Input.GetTouch(FingerId).position).GetPoint(PointerExtent);
+ position = Result.CurrentPointerTarget != null
+ ? Result.EndPoint
+ : CameraCache.Main.ScreenPointToRay(UnityEngine.Input.GetTouch(FingerId).position).GetPoint(PointerExtent);
return true;
}
diff --git a/package.json b/package.json
index bf2c119b..4bba489a 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "com.xrtk.sdk",
"displayName": "XRTK.SDK",
"description": "The SDK for the Mixed Reality Toolkit",
- "version": "0.1.11",
+ "version": "0.1.12",
"unity": "2019.1",
"license": "MIT",
"repository": {
@@ -12,6 +12,6 @@
"src": "Assets/XRTK.Core",
"author": "XRTK Team (https://github.com/XRTK)",
"dependencies": {
- "com.xrtk.core": "0.1.16"
+ "com.xrtk.core": "0.1.17"
}
}
\ No newline at end of file