Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Changes from XRTK.Core 0.1.17 #71

Merged
merged 19 commits into from
Aug 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
da0f750
- added some comments to disable.
StephenHodgson Aug 9, 2019
edd4bcf
- restore the previous pointer extent
StephenHodgson Aug 9, 2019
d675fb4
remember previous spatial mesh visibility
StephenHodgson Aug 9, 2019
42d2c12
Merge branch 'development' into dev/manipulation-physics
StephenHodgson Aug 9, 2019
7496d67
Merge branch 'development' into dev/manipulation-physics
StephenHodgson Aug 14, 2019
3c32bc6
Merge branch 'development' into dev/manipulation-physics
StephenHodgson Aug 14, 2019
0810a2b
Moved all the focus data up a level
StephenHodgson Aug 15, 2019
18224cb
updated IMixedRealityPointer references
StephenHodgson Aug 15, 2019
860e447
removed null checks for pointer.Result
StephenHodgson Aug 15, 2019
bca602c
Merge branch 'development' into dev/pointer-refactor-2
StephenHodgson Aug 15, 2019
fc8d5e0
Merge branch 'development' into dev/manipulation-physics
StephenHodgson Aug 15, 2019
78a2bd8
Fixed merge change
StephenHodgson Aug 15, 2019
ddec49e
cleaned up the manipulation handler class. No logical changes
StephenHodgson Aug 15, 2019
681ce83
Fixed merge issues
StephenHodgson Aug 15, 2019
fab11f1
added comments to disable
StephenHodgson Aug 15, 2019
b1ab1a9
rearranged a few end hold member
StephenHodgson Aug 15, 2019
b34a8dd
Merge branch 'dev/manipulation-physics' into dev/pointer-refactor-2
StephenHodgson Aug 16, 2019
24054ff
updated xrtk.core package to 0.1.17
StephenHodgson Aug 16, 2019
e1b97dc
Fixed nudging not moving the manipulated target
StephenHodgson Aug 16, 2019
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
10 changes: 5 additions & 5 deletions XRTK.SDK/Packages/com.xrtk.sdk/Features/Input/GazeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ public Vector2 NudgeConstraints

#endregion Manipulation Options

#region Properties

/// <summary>
/// The current status of the hold.
/// </summary>
Expand All @@ -285,29 +287,6 @@ public Vector2 NudgeConstraints
/// </remarks>
public bool IsBeingHeld { get; private set; } = false;

/// <summary>
/// The updated extent of the pointer.
/// </summary>
private float updatedExtent;

/// <summary>The updated scale of the model based on controller input.</summary>
private Vector3 updatedScale;

/// <summary>
/// The first input source to start the manipulation phase of this object.
/// </summary>
private IMixedRealityInputSource primaryInputSource = null;

/// <summary>
/// The first pointer to start the manipulation phase of this object.
/// </summary>
private IMixedRealityPointer primaryPointer = null;

/// <summary>
/// The last rotation reading used to calculate if the rotation action is active.
/// </summary>
private Vector2 lastPositionReading = Vector2.zero;

/// <summary>
/// Is the <see cref="primaryInputSource"/> currently pressed?
/// </summary>
Expand All @@ -333,18 +312,29 @@ public Vector2 NudgeConstraints
/// </summary>
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

Expand All @@ -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)
{
Expand All @@ -375,6 +365,7 @@ protected virtual void Update()
{
if (IsNudgePossible)
{
manipulationTarget.position = grabbedPosition + pointerPosition;
primaryPointer.PointerExtent = updatedExtent;
}
else if (IsScalingPossible)
Expand All @@ -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();
}
}
Expand Down Expand Up @@ -482,7 +476,7 @@ public virtual void OnInputChanged(InputEventData<Vector2> eventData)
return;
}

var pointerPosition = primaryPointer.Result.Details.Point;
var pointerPosition = primaryPointer.Result.EndPoint;

// Filter our actions
if (eventData.MixedRealityInputAction != nudgeAction ||
Expand Down Expand Up @@ -566,7 +560,7 @@ public virtual void OnInputChanged(InputEventData<Vector2> 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.
Expand Down Expand Up @@ -620,27 +614,6 @@ public virtual void OnInputChanged(InputEventData<Vector2> eventData)
}
}

/// <summary>
/// Calculates the extent of the nudge.
/// </summary>
/// <param name="eventData">The event data.</param>
/// <param name="prevExtent">The previous extent distance of the pointer and raycast.</param>
/// <returns>The new pointer extent.</returns>
protected virtual float CalculateNudgeDistance(InputEventData<Vector2> eventData, float prevExtent)
{
return prevExtent + nudgeAmount * (eventData.InputData.y < 0f ? -1 : 1);
}

protected virtual Vector3 CalculateScaleAmount(InputEventData<Vector2> eventData, Vector3 prevScale)
{
if (eventData.InputData.x < 0f)
{
return prevScale *= scaleAmount;
}
// else
return prevScale /= scaleAmount;
}

#endregion IMixedRealityInputHandler Implementation

#region IMixedRealityPointerHandler Implementation
Expand Down Expand Up @@ -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;

Expand All @@ -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;
}

Expand Down Expand Up @@ -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)
{
Expand All @@ -770,7 +749,6 @@ public virtual void EndHold(bool isCanceled = false)
manipulationTarget.rotation = prevRotation;
}

IsBeingHeld = false;
MixedRealityToolkit.InputSystem.PopModalInputHandler();

manipulationTarget.SetLayerRecursively(prevPhysicsLayer);
Expand All @@ -779,6 +757,32 @@ public virtual void EndHold(bool isCanceled = false)
{
boundingBox.transform.SetLayerRecursively(boundingBoxPrevPhysicsLayer);
}

primaryPointer = null;
primaryInputSource = null;
IsBeingHeld = false;
}

/// <summary>
/// Calculates the extent of the nudge using input event data.
/// </summary>
/// <param name="eventData">The event data.</param>
/// <param name="prevExtent">The previous extent distance of the pointer and raycast.</param>
/// <returns>The new pointer extent.</returns>
protected virtual float CalculateNudgeDistance(InputEventData<Vector2> eventData, float prevExtent)
{
return prevExtent + nudgeAmount * (eventData.InputData.y < 0f ? -1 : 1);
}

/// <summary>
/// Calculates the scale amount using the input event data.
/// </summary>
/// <param name="eventData">The event data.</param>
/// <param name="scale">The previous scale</param>
/// <returns>The new scale value.</returns>
protected virtual Vector3 CalculateScaleAmount(InputEventData<Vector2> eventData, Vector3 scale)
{
return eventData.InputData.x < 0f ? scale * scaleAmount : scale / scaleAmount;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,8 @@ public virtual bool IsInteractionEnabled
/// <inheritdoc />
public bool IsFocusLocked { get; set; }

[SerializeField]
private bool isTargetPositionLockedOnFocusLock;

/// <inheritdoc />
public bool IsTargetPositionLockedOnFocusLock
{
get => isTargetPositionLockedOnFocusLock;
set => isTargetPositionLockedOnFocusLock = value;
}
public bool SyncPointerTargetPosition { get; set; }

[SerializeField]
private bool overrideGlobalPointerExtent = false;
Expand Down Expand Up @@ -320,7 +313,10 @@ public float PointerExtent
public LayerMask[] PrioritizedLayerMasksOverride { get; set; } = null;

/// <inheritdoc />
public IMixedRealityFocusHandler FocusTarget { get; set; }
public IMixedRealityFocusHandler FocusHandler { get; set; }

/// <inheritdoc />
public IMixedRealityInputHandler InputHandler { get; set; }

/// <inheritdoc />
public IPointerResult Result { get; set; }
Expand Down
Loading