Skip to content

Commit

Permalink
Merge pull request #964 from keveleigh/FixTeleportAndUpdateBoundary
Browse files Browse the repository at this point in the history
Fix teleport to match current shell and update stage to not move during teleport
  • Loading branch information
jessemcculloch committed Sep 25, 2017
2 parents c591bbb + a0e11ce commit 84b3b1e
Show file tree
Hide file tree
Showing 17 changed files with 352 additions and 192 deletions.
52 changes: 27 additions & 25 deletions Assets/HoloToolkit/Boundary/Scripts/BoundaryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,35 +104,37 @@ private void RenderFloorQuad()
if (FloorQuad != null && HolographicSettings.IsDisplayOpaque)
{
floorQuadInstance = Instantiate(FloorQuad);
floorQuadInstance.transform.SetParent(gameObject.transform.parent);

#if UNITY_EDITOR
// So the floor quad does not occlude in editor testing, draw it lower.
floorQuadInstance.transform.localPosition = new Vector3(0, -3, 0);
#else
// Inside immersive headset draw floor quad at Y value of dimensions.
Vector3 dimensions;
// TODO: BUG: Unity: TryGetDimensions does not return true either.
//if (UnityEngine.Experimental.XR.Boundary.TryGetDimensions(out dimensions,
//UnityEngine.Experimental.XR.Boundary.Type.TrackedArea))
if (UnityEngine.Experimental.XR.Boundary.TryGetDimensions(out dimensions,
UnityEngine.Experimental.XR.Boundary.Type.TrackedArea))

if (!XRDevice.isPresent)
{
Debug.Log("Got dimensions of tracked area.");
if (dimensions != null)
{
Debug.Log("Drawing floor at dimensions Y.");
// Draw the floor at boundary Y.
floorQuadInstance.transform.localPosition = new Vector3(0, dimensions.y, 0);
}
// So the floor quad does not occlude in editor testing, draw it lower.
floorQuadInstance.transform.localPosition = new Vector3(0, -3, 0);
}
else
{
Debug.Log("Drawing floor at 0,0,0.");
// Draw the floor at 0,0,0.
floorQuadInstance.transform.localPosition = Vector3.zero;
}
#endif
// Inside immersive headset draw floor quad at Y value of dimensions.
Vector3 dimensions;
// TODO: BUG: Unity: TryGetDimensions does not return true either.
//if (UnityEngine.Experimental.XR.Boundary.TryGetDimensions(out dimensions,
//UnityEngine.Experimental.XR.Boundary.Type.TrackedArea))
if (UnityEngine.Experimental.XR.Boundary.TryGetDimensions(out dimensions,
UnityEngine.Experimental.XR.Boundary.Type.TrackedArea))
{
Debug.Log("Got dimensions of tracked area.");
if (dimensions != null)
{
Debug.Log("Drawing floor at dimensions Y.");
// Draw the floor at boundary Y.
floorQuadInstance.transform.localPosition = new Vector3(0, dimensions.y, 0);
}
}
else
{
Debug.Log("Drawing floor at 0,0,0.");
// Draw the floor at 0,0,0.
floorQuadInstance.transform.localPosition = Vector3.zero;
}
}
floorQuadInstance.SetActive(true);
}
}
Expand Down
55 changes: 34 additions & 21 deletions Assets/HoloToolkit/Input/Prefabs/MixedRealityCameraParent.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ GameObject:
serializedVersion: 5
m_Component:
- component: {fileID: 4541142303025740}
- component: {fileID: 114092548863884916}
- component: {fileID: 114059824862712730}
- component: {fileID: 114812681035175298}
m_Layer: 0
m_Name: MixedRealityCameraParent
m_TagString: Untagged
Expand Down Expand Up @@ -599,6 +600,17 @@ MonoBehaviour:
Axis0Destination: 0
Axis1Destination: 4
Axis2Destination: 6
--- !u!114 &114059824862712730
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1850730992894404}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cae8f3c88e9704a4393cb8d904b62372, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &114061490341948574
MonoBehaviour:
m_ObjectHideFlags: 1
Expand All @@ -623,26 +635,6 @@ MonoBehaviour:
JoystickXYRotationAxisControl: {fileID: 114991520948515094}
JoystickXYTranslationAxisControl: {fileID: 114873870855691164}
JoystickXZTranslationAxisControl: {fileID: 114029515443702222}
--- !u!114 &114092548863884916
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1850730992894404}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1bc175d33f66e6647aabac1b65e7e632, type: 3}
m_Name:
m_EditorClassIdentifier:
TeleportButtonName: Jump
GoBackButtonName: Fire2
LeftJoystickX: ControllerLeftStickX
LeftJoystickY: ControllerLeftStickY
EnableTeleport: 1
EnableJoystickMovement: 0
BumperRotationSize: 30
TeleportMarker: {fileID: 1503526479864244, guid: 10d95b99055c6ad40b735cc8b3593745,
type: 2}
--- !u!114 &114121188885475510
MonoBehaviour:
m_ObjectHideFlags: 1
Expand Down Expand Up @@ -801,6 +793,27 @@ MonoBehaviour:
Axis0Destination: 4
Axis1Destination: 6
Axis2Destination: 6
--- !u!114 &114812681035175298
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1850730992894404}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1bc175d33f66e6647aabac1b65e7e632, type: 3}
m_Name:
m_EditorClassIdentifier:
LeftJoystickX: ControllerLeftStickX
LeftJoystickY: ControllerLeftStickY
EnableTeleport: 1
EnableRotation: 1
EnableStrafe: 1
EnableJoystickMovement: 0
RotationSize: 45
StrafeAmount: 0.5
TeleportMarker: {fileID: 1503526479864244, guid: 10d95b99055c6ad40b735cc8b3593745,
type: 2}
--- !u!114 &114828096048444974
MonoBehaviour:
m_ObjectHideFlags: 1
Expand Down
2 changes: 1 addition & 1 deletion Assets/HoloToolkit/Input/Prefabs/TeleportMarker.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Transform:
m_GameObject: {fileID: 1503526479864244}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1.5, y: 1.5, z: 1.5}
m_LocalScale: {x: 5, y: 5, z: 5}
m_Children:
- {fileID: 4016362903904820}
- {fileID: 4557482788704076}
Expand Down
21 changes: 20 additions & 1 deletion Assets/HoloToolkit/Input/Scripts/ControllerVisualizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ private void Start()
if (spatialInteractionManager != null)
{
spatialInteractionManager.SourceDetected += SpatialInteractionManager_SourceDetected;
spatialInteractionManager.SourceLost += SpatialInteractionManager_SourceLost;
}
}, true);
#else
Expand All @@ -88,8 +89,8 @@ private void Start()
}

InteractionManager.InteractionSourceDetected += InteractionManager_InteractionSourceDetected;
#endif
InteractionManager.InteractionSourceLost += InteractionManager_InteractionSourceLost;
#endif
InteractionManager.InteractionSourceUpdated += InteractionManager_InteractionSourceUpdated;
#endif
}
Expand Down Expand Up @@ -120,6 +121,24 @@ private void SpatialInteractionManager_SourceDetected(SpatialInteractionManager
}
}

private void SpatialInteractionManager_SourceLost(SpatialInteractionManager sender, SpatialInteractionSourceEventArgs args)
{
SpatialInteractionSource source = args.State.Source;
if (source.Kind == SpatialInteractionSourceKind.Controller)
{
ControllerInfo controller;
if (controllerDictionary != null && controllerDictionary.TryGetValue(source.Id, out controller))
{
controllerDictionary.Remove(source.Id);

UnityEngine.WSA.Application.InvokeOnAppThread(() =>
{
Destroy(controller);
}, false);
}
}
}

private IEnumerator LoadControllerModel(SpatialInteractionController controller, SpatialInteractionSource source)
{
GameObject controllerModelGameObject;
Expand Down
7 changes: 5 additions & 2 deletions Assets/HoloToolkit/Input/Scripts/Cursor/Cursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,11 @@ private void TryLoadPointerIfNeeded()
{
// For backward-compatibility, if a pointer wasn't specified, but there's exactly one
// pointer currently registered with FocusManager, we use it.

Pointer = FocusManager.Instance.TryGetSinglePointer();
IPointingSource pointingSource;
if (FocusManager.Instance.TryGetSinglePointer(out pointingSource))
{
Pointer = pointingSource;
}
}
else
{
Expand Down
5 changes: 5 additions & 0 deletions Assets/HoloToolkit/Input/Scripts/EditorInputSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ public class EditorInputSelector : MonoBehaviour

private void Awake()
{
#if UNITY_EDITOR
if (UnityEngine.XR.XRDevice.isPresent)
{
#endif
Destroy(gameObject);
return;
#if UNITY_EDITOR
}
#endif

Inputs = new List<GameObject>();

Expand Down
40 changes: 30 additions & 10 deletions Assets/HoloToolkit/Input/Scripts/Focus/FocusManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,24 @@ public GameObject TryGetFocusedObject(BaseEventData eventData)
{
FocusDetails? details = TryGetFocusDetails(eventData);

return (details == null)
? null
: details.Value.Object;
return (details == null) ? null : details.Value.Object;
}

public bool TryGetPointingSource(BaseEventData eventData, out IPointingSource pointingSource)
{
for (int iPointer = 0; iPointer < pointers.Count; iPointer++)
{
PointerData pointer = pointers[iPointer];

if (pointer.PointingSource.OwnsInput(eventData))
{
pointingSource = pointer.PointingSource;
return true;
}
}

pointingSource = null;
return false;
}

public FocusDetails GetFocusDetails(IPointingSource pointingSource)
Expand All @@ -282,13 +297,18 @@ public GameObject GetFocusedObject(IPointingSource pointingSource)
/// Checks if exactly one pointer is registered and returns it if so.
/// </summary>
/// <returns>The registered pointer if exactly one is registered, null otherwise.</returns>
public IPointingSource TryGetSinglePointer()
public bool TryGetSinglePointer(out IPointingSource pointingSource)
{
IPointingSource singlePointer = (pointers.Count == 1)
? pointers[0].PointingSource
: null;

return singlePointer;
if (pointers.Count == 1)
{
pointingSource = pointers[0].PointingSource;
return true;
}
else
{
pointingSource = null;
return false;
}
}

public delegate void FocusEnteredMethod(GameObject focusedObject);
Expand All @@ -310,7 +330,7 @@ public PointerInputEventData BorrowPointerEventData()
{
Clear(uiRaycastPointerInputData);
}

return uiRaycastPointerInputData;
}

Expand Down
6 changes: 2 additions & 4 deletions Assets/HoloToolkit/Input/Scripts/Focus/InputSourcePointer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ namespace HoloToolkit.Unity.InputModule
/// Class implementing IPointingSource to demonstrate how to create a pointing source.
/// This is consumed by SimpleSinglePointerSelector.
/// </summary>
public class InputSourcePointer :
IPointingSource
public class InputSourcePointer : IPointingSource
{
public IInputSource InputSource { get; set; }

Expand Down Expand Up @@ -69,8 +68,7 @@ public bool InputIsFromSource(BaseEventData eventData)

return (inputData != null)
&& (inputData.InputSource == InputSource)
&& (inputData.SourceId == InputSourceId)
;
&& (inputData.SourceId == InputSourceId);
}
}
}

0 comments on commit 84b3b1e

Please sign in to comment.