Skip to content

Commit 84b3b1e

Browse files
Merge pull request #964 from keveleigh/FixTeleportAndUpdateBoundary
Fix teleport to match current shell and update stage to not move during teleport
2 parents c591bbb + a0e11ce commit 84b3b1e

17 files changed

+352
-192
lines changed

Assets/HoloToolkit/Boundary/Scripts/BoundaryManager.cs

+27-25
Original file line numberDiff line numberDiff line change
@@ -104,35 +104,37 @@ private void RenderFloorQuad()
104104
if (FloorQuad != null && HolographicSettings.IsDisplayOpaque)
105105
{
106106
floorQuadInstance = Instantiate(FloorQuad);
107-
floorQuadInstance.transform.SetParent(gameObject.transform.parent);
108-
109-
#if UNITY_EDITOR
110-
// So the floor quad does not occlude in editor testing, draw it lower.
111-
floorQuadInstance.transform.localPosition = new Vector3(0, -3, 0);
112-
#else
113-
// Inside immersive headset draw floor quad at Y value of dimensions.
114-
Vector3 dimensions;
115-
// TODO: BUG: Unity: TryGetDimensions does not return true either.
116-
//if (UnityEngine.Experimental.XR.Boundary.TryGetDimensions(out dimensions,
117-
//UnityEngine.Experimental.XR.Boundary.Type.TrackedArea))
118-
if (UnityEngine.Experimental.XR.Boundary.TryGetDimensions(out dimensions,
119-
UnityEngine.Experimental.XR.Boundary.Type.TrackedArea))
107+
108+
if (!XRDevice.isPresent)
120109
{
121-
Debug.Log("Got dimensions of tracked area.");
122-
if (dimensions != null)
123-
{
124-
Debug.Log("Drawing floor at dimensions Y.");
125-
// Draw the floor at boundary Y.
126-
floorQuadInstance.transform.localPosition = new Vector3(0, dimensions.y, 0);
127-
}
110+
// So the floor quad does not occlude in editor testing, draw it lower.
111+
floorQuadInstance.transform.localPosition = new Vector3(0, -3, 0);
128112
}
129113
else
130114
{
131-
Debug.Log("Drawing floor at 0,0,0.");
132-
// Draw the floor at 0,0,0.
133-
floorQuadInstance.transform.localPosition = Vector3.zero;
134-
}
135-
#endif
115+
// Inside immersive headset draw floor quad at Y value of dimensions.
116+
Vector3 dimensions;
117+
// TODO: BUG: Unity: TryGetDimensions does not return true either.
118+
//if (UnityEngine.Experimental.XR.Boundary.TryGetDimensions(out dimensions,
119+
//UnityEngine.Experimental.XR.Boundary.Type.TrackedArea))
120+
if (UnityEngine.Experimental.XR.Boundary.TryGetDimensions(out dimensions,
121+
UnityEngine.Experimental.XR.Boundary.Type.TrackedArea))
122+
{
123+
Debug.Log("Got dimensions of tracked area.");
124+
if (dimensions != null)
125+
{
126+
Debug.Log("Drawing floor at dimensions Y.");
127+
// Draw the floor at boundary Y.
128+
floorQuadInstance.transform.localPosition = new Vector3(0, dimensions.y, 0);
129+
}
130+
}
131+
else
132+
{
133+
Debug.Log("Drawing floor at 0,0,0.");
134+
// Draw the floor at 0,0,0.
135+
floorQuadInstance.transform.localPosition = Vector3.zero;
136+
}
137+
}
136138
floorQuadInstance.SetActive(true);
137139
}
138140
}

Assets/HoloToolkit/Input/Prefabs/MixedRealityCameraParent.prefab

+34-21
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ GameObject:
232232
serializedVersion: 5
233233
m_Component:
234234
- component: {fileID: 4541142303025740}
235-
- component: {fileID: 114092548863884916}
235+
- component: {fileID: 114059824862712730}
236+
- component: {fileID: 114812681035175298}
236237
m_Layer: 0
237238
m_Name: MixedRealityCameraParent
238239
m_TagString: Untagged
@@ -599,6 +600,17 @@ MonoBehaviour:
599600
Axis0Destination: 0
600601
Axis1Destination: 4
601602
Axis2Destination: 6
603+
--- !u!114 &114059824862712730
604+
MonoBehaviour:
605+
m_ObjectHideFlags: 1
606+
m_PrefabParentObject: {fileID: 0}
607+
m_PrefabInternal: {fileID: 100100000}
608+
m_GameObject: {fileID: 1850730992894404}
609+
m_Enabled: 1
610+
m_EditorHideFlags: 0
611+
m_Script: {fileID: 11500000, guid: cae8f3c88e9704a4393cb8d904b62372, type: 3}
612+
m_Name:
613+
m_EditorClassIdentifier:
602614
--- !u!114 &114061490341948574
603615
MonoBehaviour:
604616
m_ObjectHideFlags: 1
@@ -623,26 +635,6 @@ MonoBehaviour:
623635
JoystickXYRotationAxisControl: {fileID: 114991520948515094}
624636
JoystickXYTranslationAxisControl: {fileID: 114873870855691164}
625637
JoystickXZTranslationAxisControl: {fileID: 114029515443702222}
626-
--- !u!114 &114092548863884916
627-
MonoBehaviour:
628-
m_ObjectHideFlags: 1
629-
m_PrefabParentObject: {fileID: 0}
630-
m_PrefabInternal: {fileID: 100100000}
631-
m_GameObject: {fileID: 1850730992894404}
632-
m_Enabled: 1
633-
m_EditorHideFlags: 0
634-
m_Script: {fileID: 11500000, guid: 1bc175d33f66e6647aabac1b65e7e632, type: 3}
635-
m_Name:
636-
m_EditorClassIdentifier:
637-
TeleportButtonName: Jump
638-
GoBackButtonName: Fire2
639-
LeftJoystickX: ControllerLeftStickX
640-
LeftJoystickY: ControllerLeftStickY
641-
EnableTeleport: 1
642-
EnableJoystickMovement: 0
643-
BumperRotationSize: 30
644-
TeleportMarker: {fileID: 1503526479864244, guid: 10d95b99055c6ad40b735cc8b3593745,
645-
type: 2}
646638
--- !u!114 &114121188885475510
647639
MonoBehaviour:
648640
m_ObjectHideFlags: 1
@@ -801,6 +793,27 @@ MonoBehaviour:
801793
Axis0Destination: 4
802794
Axis1Destination: 6
803795
Axis2Destination: 6
796+
--- !u!114 &114812681035175298
797+
MonoBehaviour:
798+
m_ObjectHideFlags: 1
799+
m_PrefabParentObject: {fileID: 0}
800+
m_PrefabInternal: {fileID: 100100000}
801+
m_GameObject: {fileID: 1850730992894404}
802+
m_Enabled: 1
803+
m_EditorHideFlags: 0
804+
m_Script: {fileID: 11500000, guid: 1bc175d33f66e6647aabac1b65e7e632, type: 3}
805+
m_Name:
806+
m_EditorClassIdentifier:
807+
LeftJoystickX: ControllerLeftStickX
808+
LeftJoystickY: ControllerLeftStickY
809+
EnableTeleport: 1
810+
EnableRotation: 1
811+
EnableStrafe: 1
812+
EnableJoystickMovement: 0
813+
RotationSize: 45
814+
StrafeAmount: 0.5
815+
TeleportMarker: {fileID: 1503526479864244, guid: 10d95b99055c6ad40b735cc8b3593745,
816+
type: 2}
804817
--- !u!114 &114828096048444974
805818
MonoBehaviour:
806819
m_ObjectHideFlags: 1

Assets/HoloToolkit/Input/Prefabs/TeleportMarker.prefab

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Transform:
116116
m_GameObject: {fileID: 1503526479864244}
117117
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
118118
m_LocalPosition: {x: 0, y: 0, z: 0}
119-
m_LocalScale: {x: 1.5, y: 1.5, z: 1.5}
119+
m_LocalScale: {x: 5, y: 5, z: 5}
120120
m_Children:
121121
- {fileID: 4016362903904820}
122122
- {fileID: 4557482788704076}

Assets/HoloToolkit/Input/Scripts/ControllerVisualizer.cs

+20-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ private void Start()
7474
if (spatialInteractionManager != null)
7575
{
7676
spatialInteractionManager.SourceDetected += SpatialInteractionManager_SourceDetected;
77+
spatialInteractionManager.SourceLost += SpatialInteractionManager_SourceLost;
7778
}
7879
}, true);
7980
#else
@@ -88,8 +89,8 @@ private void Start()
8889
}
8990

9091
InteractionManager.InteractionSourceDetected += InteractionManager_InteractionSourceDetected;
91-
#endif
9292
InteractionManager.InteractionSourceLost += InteractionManager_InteractionSourceLost;
93+
#endif
9394
InteractionManager.InteractionSourceUpdated += InteractionManager_InteractionSourceUpdated;
9495
#endif
9596
}
@@ -120,6 +121,24 @@ private void SpatialInteractionManager_SourceDetected(SpatialInteractionManager
120121
}
121122
}
122123

124+
private void SpatialInteractionManager_SourceLost(SpatialInteractionManager sender, SpatialInteractionSourceEventArgs args)
125+
{
126+
SpatialInteractionSource source = args.State.Source;
127+
if (source.Kind == SpatialInteractionSourceKind.Controller)
128+
{
129+
ControllerInfo controller;
130+
if (controllerDictionary != null && controllerDictionary.TryGetValue(source.Id, out controller))
131+
{
132+
controllerDictionary.Remove(source.Id);
133+
134+
UnityEngine.WSA.Application.InvokeOnAppThread(() =>
135+
{
136+
Destroy(controller);
137+
}, false);
138+
}
139+
}
140+
}
141+
123142
private IEnumerator LoadControllerModel(SpatialInteractionController controller, SpatialInteractionSource source)
124143
{
125144
GameObject controllerModelGameObject;

Assets/HoloToolkit/Input/Scripts/Cursor/Cursor.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,11 @@ private void TryLoadPointerIfNeeded()
271271
{
272272
// For backward-compatibility, if a pointer wasn't specified, but there's exactly one
273273
// pointer currently registered with FocusManager, we use it.
274-
275-
Pointer = FocusManager.Instance.TryGetSinglePointer();
274+
IPointingSource pointingSource;
275+
if (FocusManager.Instance.TryGetSinglePointer(out pointingSource))
276+
{
277+
Pointer = pointingSource;
278+
}
276279
}
277280
else
278281
{

Assets/HoloToolkit/Input/Scripts/EditorInputSelector.cs

+5
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,15 @@ public class EditorInputSelector : MonoBehaviour
2929

3030
private void Awake()
3131
{
32+
#if UNITY_EDITOR
3233
if (UnityEngine.XR.XRDevice.isPresent)
3334
{
35+
#endif
3436
Destroy(gameObject);
37+
return;
38+
#if UNITY_EDITOR
3539
}
40+
#endif
3641

3742
Inputs = new List<GameObject>();
3843

Assets/HoloToolkit/Input/Scripts/Focus/FocusManager.cs

+30-10
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,24 @@ public GameObject TryGetFocusedObject(BaseEventData eventData)
263263
{
264264
FocusDetails? details = TryGetFocusDetails(eventData);
265265

266-
return (details == null)
267-
? null
268-
: details.Value.Object;
266+
return (details == null) ? null : details.Value.Object;
267+
}
268+
269+
public bool TryGetPointingSource(BaseEventData eventData, out IPointingSource pointingSource)
270+
{
271+
for (int iPointer = 0; iPointer < pointers.Count; iPointer++)
272+
{
273+
PointerData pointer = pointers[iPointer];
274+
275+
if (pointer.PointingSource.OwnsInput(eventData))
276+
{
277+
pointingSource = pointer.PointingSource;
278+
return true;
279+
}
280+
}
281+
282+
pointingSource = null;
283+
return false;
269284
}
270285

271286
public FocusDetails GetFocusDetails(IPointingSource pointingSource)
@@ -282,13 +297,18 @@ public GameObject GetFocusedObject(IPointingSource pointingSource)
282297
/// Checks if exactly one pointer is registered and returns it if so.
283298
/// </summary>
284299
/// <returns>The registered pointer if exactly one is registered, null otherwise.</returns>
285-
public IPointingSource TryGetSinglePointer()
300+
public bool TryGetSinglePointer(out IPointingSource pointingSource)
286301
{
287-
IPointingSource singlePointer = (pointers.Count == 1)
288-
? pointers[0].PointingSource
289-
: null;
290-
291-
return singlePointer;
302+
if (pointers.Count == 1)
303+
{
304+
pointingSource = pointers[0].PointingSource;
305+
return true;
306+
}
307+
else
308+
{
309+
pointingSource = null;
310+
return false;
311+
}
292312
}
293313

294314
public delegate void FocusEnteredMethod(GameObject focusedObject);
@@ -310,7 +330,7 @@ public PointerInputEventData BorrowPointerEventData()
310330
{
311331
Clear(uiRaycastPointerInputData);
312332
}
313-
333+
314334
return uiRaycastPointerInputData;
315335
}
316336

Assets/HoloToolkit/Input/Scripts/Focus/InputSourcePointer.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ namespace HoloToolkit.Unity.InputModule
1111
/// Class implementing IPointingSource to demonstrate how to create a pointing source.
1212
/// This is consumed by SimpleSinglePointerSelector.
1313
/// </summary>
14-
public class InputSourcePointer :
15-
IPointingSource
14+
public class InputSourcePointer : IPointingSource
1615
{
1716
public IInputSource InputSource { get; set; }
1817

@@ -69,8 +68,7 @@ public bool InputIsFromSource(BaseEventData eventData)
6968

7069
return (inputData != null)
7170
&& (inputData.InputSource == InputSource)
72-
&& (inputData.SourceId == InputSourceId)
73-
;
71+
&& (inputData.SourceId == InputSourceId);
7472
}
7573
}
7674
}

0 commit comments

Comments
 (0)