Skip to content

Commit 213c472

Browse files
author
David Kline
authored
Merge pull request #3475 from Microsoft/beta2-stabilization
Beta2 stabilization -> mrtk development
2 parents 6bb4b6c + 9021fde commit 213c472

File tree

13 files changed

+129
-43
lines changed

13 files changed

+129
-43
lines changed

Assets/MixedRealityToolkit.SDK/Features/Input/Handlers/ManipulationHandler.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ private enum TwoHandedManipulation
5757
[Tooltip("Constrain rotation along an axis")]
5858
private RotationConstraintType constraintOnRotation = RotationConstraintType.None;
5959

60+
[SerializeField]
61+
[Tooltip("Constrain movement")]
62+
private MovementConstraintType constraintOnMovement = MovementConstraintType.None;
63+
6064
[SerializeField]
6165
private HandMovementType handMoveType = HandMovementType.OneAndTwoHanded;
6266

@@ -88,7 +92,7 @@ private enum State
8892
private void Awake()
8993
{
9094
gazeHandHelper = new GazeHandHelper();
91-
m_moveLogic = new TwoHandMoveLogic();
95+
m_moveLogic = new TwoHandMoveLogic(constraintOnMovement);
9296
m_rotateLogic = new TwoHandRotateLogic(constraintOnRotation);
9397
m_scaleLogic = new TwoHandScaleLogic();
9498
}

Assets/MixedRealityToolkit.SDK/Features/UX/Scripts/Pointers/BaseControllerPointer.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,34 @@ protected override async void Start()
139139
{
140140
base.Start();
141141

142-
if (lateRegisterTeleport)
142+
if (lateRegisterTeleport && MixedRealityToolkit.Instance.ActiveProfile.IsTeleportSystemEnabled)
143143
{
144-
await new WaitUntil(() => MixedRealityToolkit.TeleportSystem != null);
144+
if (MixedRealityToolkit.TeleportSystem == null)
145+
{
146+
await new WaitUntil(() => MixedRealityToolkit.TeleportSystem != null);
147+
148+
// We've been destroyed during the await.
149+
if (this == null)
150+
{
151+
return;
152+
}
153+
}
154+
145155
lateRegisterTeleport = false;
146156
MixedRealityToolkit.TeleportSystem.Register(gameObject);
147157
}
148158

149-
await WaitUntilInputSystemValid;
159+
if (MixedRealityToolkit.InputSystem == null)
160+
{
161+
await WaitUntilInputSystemValid;
162+
}
163+
164+
// We've been destroyed during the await.
165+
if (this == null)
166+
{
167+
return;
168+
}
169+
150170
SetCursor();
151171
}
152172

Assets/MixedRealityToolkit.SDK/Features/UX/Scripts/Pointers/LinePointer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public override void OnPreRaycast()
150150
for (int i = 0; i < Rays.Length; i++)
151151
{
152152
Vector3 currentPoint = lineBase.GetUnClampedPoint(stepSize * (i + 1));
153-
Rays[i] = new RayStep(lastPoint, currentPoint);
153+
Rays[i].UpdateRayStep(ref lastPoint, ref currentPoint);
154154
lastPoint = currentPoint;
155155
}
156156
}

Assets/MixedRealityToolkit.SDK/Features/UX/Scripts/Pointers/TeleportPointer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public override void OnPreRaycast()
146146
for (int i = 0; i < Rays.Length; i++)
147147
{
148148
Vector3 currentPoint = LineBase.GetUnClampedPoint(stepSize * (i + 1));
149-
Rays[i] = new RayStep(lastPoint, currentPoint);
149+
Rays[i].UpdateRayStep(ref lastPoint, ref currentPoint);
150150
lastPoint = currentPoint;
151151
}
152152

Assets/MixedRealityToolkit.Services/InputSystem/FocusProvider.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,12 @@ public void UpdateFocusLockedHit()
252252
pointerWasLocked = true;
253253
}
254254

255-
// In case the focused object is moving, we need to update the focus point based on the object's new transform.
256-
focusDetails.Point = focusDetails.Object.transform.TransformPoint(pointLocalSpace);
257-
focusDetails.Normal = focusDetails.Object.transform.TransformDirection(normalLocalSpace);
255+
if (focusDetails.Object != null && focusDetails.Object.transform != null)
256+
{
257+
// In case the focused object is moving, we need to update the focus point based on the object's new transform.
258+
focusDetails.Point = focusDetails.Object.transform.TransformPoint(pointLocalSpace);
259+
focusDetails.Normal = focusDetails.Object.transform.TransformDirection(normalLocalSpace);
260+
}
258261

259262
StartPoint = Pointer.Rays[0].Origin;
260263

Assets/MixedRealityToolkit.Services/InputSystem/GazeProvider.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ public override void OnPreRaycast()
199199
newGazeNormal = stabilizer.StableRay.direction;
200200
}
201201

202-
Rays[0].UpdateRayStep(newGazeOrigin, newGazeOrigin + (newGazeNormal * pointerExtent));
202+
Vector3 endPoint = newGazeOrigin + (newGazeNormal * pointerExtent);
203+
Rays[0].UpdateRayStep(ref newGazeOrigin, ref endPoint);
203204

204205
gazeProvider.HitPosition = Rays[0].Origin + (gazeProvider.lastHitDistance * Rays[0].Direction);
205206
}

Assets/MixedRealityToolkit.Services/InputSystem/InputSystemGlobalListener.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,17 @@ protected virtual async void Start()
2828
{
2929
if (lateInitialize)
3030
{
31-
await WaitUntilInputSystemValid;
31+
if (MixedRealityToolkit.InputSystem == null)
32+
{
33+
await WaitUntilInputSystemValid;
34+
}
35+
36+
if (this == null)
37+
{
38+
// We've been destroyed during the await.
39+
return;
40+
}
41+
3242
lateInitialize = false;
3343
MixedRealityToolkit.InputSystem.Register(gameObject);
3444
}

Assets/MixedRealityToolkit/Definitions/Physics/RayStep.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ public Vector3 GetPoint(float distance)
3131
return Vector3.MoveTowards(Origin, Terminus, distance);
3232
}
3333

34-
public void UpdateRayStep(Vector3 origin, Vector3 terminus)
34+
/// <summary>
35+
/// Update current raystep with new origin and terminus points.
36+
/// Pass by ref to avoid unnecessary struct copy into function since values will be copied anyways locally
37+
/// </summary>
38+
/// <param name="origin">beginning of raystep origin</param>
39+
/// <param name="terminus">end of raystep</param>
40+
public void UpdateRayStep(ref Vector3 origin, ref Vector3 terminus)
3541
{
3642
Origin = origin;
3743
Terminus = terminus;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
namespace Microsoft.MixedReality.Toolkit.Core.Definitions.Utilities
5+
{
6+
public enum MovementConstraintType
7+
{
8+
None,
9+
FixDistanceFromHead
10+
}
11+
}

Assets/MixedRealityToolkit/Definitions/Utilities/MovementConstraintType.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)