Skip to content

Commit e393a1a

Browse files
Merge branch 'vNEXT-Teleportation' into vNEXT-ControllerRenderwithTeleport
2 parents 7fbf91b + efacac6 commit e393a1a

File tree

84 files changed

+5410
-187
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+5410
-187
lines changed

Assets/MixedRealityToolkit-SDK/Features/Input/Handlers/ControllerPoseSynchronizer.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ public bool DestroyOnLost
3636
set { destroyOnLost = value; }
3737
}
3838

39+
/// <summary>
40+
/// Is the controller this Synchronizer is registered to currently tracked?
41+
/// </summary>
42+
public bool IsTracked { get; protected set; } = false;
43+
44+
/// <summary>
45+
/// The current tracking state of the assigned <see cref="IMixedRealityController"/>
46+
/// </summary>
47+
protected TrackingState TrackingState = TrackingState.NotTracked;
48+
3949
private IMixedRealityController controller;
4050

4151
/// <inheritdoc />
@@ -73,16 +83,6 @@ public MixedRealityInputAction PoseAction
7383

7484
#endregion IMixedRealityControllerPoseSynchronizer Implementation
7585

76-
/// <summary>
77-
/// Is the controller this Synchronizer is registered to currently tracked?
78-
/// </summary>
79-
public bool IsTracked { get; protected set; } = false;
80-
81-
/// <summary>
82-
/// The current tracking state of the assigned <see cref="IMixedRealityController"/>
83-
/// </summary>
84-
protected TrackingState TrackingState = TrackingState.NotTracked;
85-
8686
#region IMixedRealitySourcePoseHandler Implementation
8787

8888
/// <inheritdoc />
@@ -135,8 +135,8 @@ public virtual void OnSourcePoseChanged(SourcePoseEventData eventData)
135135

136136
if (TrackingState == TrackingState.Tracked)
137137
{
138-
transform.position = eventData.MixedRealityPose.Position;
139-
transform.rotation = eventData.MixedRealityPose.Rotation;
138+
transform.localPosition = eventData.MixedRealityPose.Position;
139+
transform.localRotation = eventData.MixedRealityPose.Rotation;
140140
}
141141
}
142142

@@ -166,7 +166,7 @@ public virtual void OnPositionChanged(InputEventData<Vector3> eventData)
166166
{
167167
IsTracked = true;
168168
TrackingState = TrackingState.Tracked;
169-
transform.position = eventData.InputData;
169+
transform.localPosition = eventData.InputData;
170170
}
171171
}
172172
}
@@ -181,7 +181,7 @@ public virtual void OnRotationChanged(InputEventData<Quaternion> eventData)
181181
{
182182
IsTracked = true;
183183
TrackingState = TrackingState.Tracked;
184-
transform.rotation = eventData.InputData;
184+
transform.localRotation = eventData.InputData;
185185
}
186186
}
187187
}
@@ -196,8 +196,8 @@ public virtual void OnPoseInputChanged(InputEventData<MixedRealityPose> eventDat
196196
{
197197
IsTracked = true;
198198
TrackingState = TrackingState.Tracked;
199-
transform.position = eventData.InputData.Position;
200-
transform.rotation = eventData.InputData.Rotation;
199+
transform.localPosition = eventData.InputData.Position;
200+
transform.localRotation = eventData.InputData.Rotation;
201201
}
202202
}
203203
}

Assets/MixedRealityToolkit-SDK/Features/Input/Handlers/TeleportHandler.cs renamed to Assets/MixedRealityToolkit-SDK/Features/Input/Handlers/TeleportHotSpot.cs

Lines changed: 50 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,55 @@
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
using Microsoft.MixedReality.Toolkit.Internal.EventDatum.Input;
5-
using Microsoft.MixedReality.Toolkit.Internal.Interfaces.InputSystem;
5+
using Microsoft.MixedReality.Toolkit.Internal.Interfaces.TeleportSystem;
6+
using Microsoft.MixedReality.Toolkit.Internal.Managers;
7+
using Microsoft.MixedReality.Toolkit.SDK.UX.Pointers;
68
using UnityEngine;
79

810
namespace Microsoft.MixedReality.Toolkit.SDK.Input.Handlers
911
{
1012
/// <summary>
11-
/// SDK component handling teleportation when a user focuses this <see cref="GameObject"/> and triggers the teleport action.
13+
/// SDK component handling teleportation to a specific position &amp; orientation when a user focuses
14+
/// this <see cref="GameObject"/> and triggers the teleport action.
1215
/// </summary>
13-
public class TeleportHandler : BaseFocusHandler, ITeleportTarget
16+
public class TeleportHotSpot : BaseFocusHandler, IMixedRealityTeleportHotSpot
1417
{
15-
[SerializeField]
16-
[Tooltip("Should the destination orientation be overridden? " +
17-
"Useful when you want to orient the user in a specific direction when they teleport to this position. " +
18-
"Override orientation is the transform forward of the GameObject this component is attached to.")]
19-
private bool overrideOrientation = false;
18+
private static IMixedRealityTeleportSystem teleportSystem = null;
19+
protected static IMixedRealityTeleportSystem TeleportSystem => teleportSystem ?? (teleportSystem = MixedRealityManager.Instance.GetManager<IMixedRealityTeleportSystem>());
20+
21+
#region IMixedRealityFocusHandler Implementation
22+
23+
/// <inheritdoc />
24+
public override void OnBeforeFocusChange(FocusEventData eventData)
25+
{
26+
base.OnBeforeFocusChange(eventData);
27+
28+
if (!(eventData.Pointer is TeleportPointer)) { return; }
29+
30+
if (eventData.NewFocusedObject == gameObject)
31+
{
32+
eventData.Pointer.TeleportHotSpot = this;
33+
34+
if (eventData.Pointer.IsInteractionEnabled)
35+
{
36+
TeleportSystem.RaiseTeleportCanceled(eventData.Pointer, this);
37+
TeleportSystem.RaiseTeleportRequest(eventData.Pointer, this);
38+
}
39+
}
40+
else if (eventData.OldFocusedObject == gameObject)
41+
{
42+
eventData.Pointer.TeleportHotSpot = null;
43+
44+
if (eventData.Pointer.IsInteractionEnabled)
45+
{
46+
TeleportSystem.RaiseTeleportCanceled(eventData.Pointer, this);
47+
}
48+
}
49+
}
50+
51+
#endregion IMixedRealityFocusHandler Implementation
52+
53+
#region IMixedRealityTeleportTarget Implementation
2054

2155
/// <inheritdoc />
2256
public Vector3 Position => transform.position;
@@ -27,27 +61,22 @@ public class TeleportHandler : BaseFocusHandler, ITeleportTarget
2761
/// <inheritdoc />
2862
public bool IsActive => isActiveAndEnabled;
2963

64+
[SerializeField]
65+
[Tooltip("Should the destination orientation be overridden? " +
66+
"Useful when you want to orient the user in a specific direction when they teleport to this position. " +
67+
"Override orientation is the transform forward of the GameObject this component is attached to.")]
68+
private bool overrideOrientation = false;
69+
3070
/// <inheritdoc />
3171
public bool OverrideTargetOrientation => overrideOrientation;
3272

3373
/// <inheritdoc />
3474
public float TargetOrientation => transform.eulerAngles.y;
3575

3676
/// <inheritdoc />
37-
public override void OnBeforeFocusChange(FocusEventData eventData)
38-
{
39-
base.OnBeforeFocusChange(eventData);
77+
public GameObject GameObjectReference => gameObject;
4078

41-
if (eventData.NewFocusedObject == gameObject)
42-
{
43-
eventData.Pointer.TeleportTarget = this;
44-
}
45-
46-
if (eventData.OldFocusedObject == gameObject)
47-
{
48-
eventData.Pointer.TeleportTarget = null;
49-
}
50-
}
79+
#endregion IMixedRealityTeleportTarget Implementation
5180

5281
private void OnDrawGizmos()
5382
{

Assets/MixedRealityToolkit-SDK/Features/Input/Handlers/TeleportHandler.cs.meta renamed to Assets/MixedRealityToolkit-SDK/Features/Input/Handlers/TeleportHotSpot.cs.meta

File renamed without changes.

Assets/MixedRealityToolkit-SDK/Features/Teleportation.meta

Lines changed: 8 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)