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

Dev/manipulation physics #64

Closed
wants to merge 8 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ public Vector2 NudgeConstraints

private int prevPhysicsLayer;
private int boundingBoxPrevPhysicsLayer;
private float prevPointerExtent;
private SpatialMeshDisplayOptions prevSpatialMeshDisplay;

#region Monobehaviour Implementation

Expand Down Expand Up @@ -376,6 +378,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 @@ -702,7 +707,12 @@ public virtual void BeginHold(MixedRealityPointerEventData eventData)
}

MixedRealityToolkit.InputSystem.PushModalInputHandler(gameObject);
MixedRealityToolkit.SpatialAwarenessSystem.SetMeshVisibility(spatialMeshVisibility);

if (MixedRealityToolkit.SpatialAwarenessSystem != null)
{
prevSpatialMeshDisplay = MixedRealityToolkit.SpatialAwarenessSystem.SpatialMeshVisibility;
MixedRealityToolkit.SpatialAwarenessSystem.SpatialMeshVisibility = spatialMeshVisibility;
}

var pointerPosition = primaryPointer.Result.Details.Point;

Expand All @@ -714,6 +724,7 @@ public virtual void BeginHold(MixedRealityPointerEventData eventData)

// update the pointer extent to prevent the object from popping to the end of the pointer
var currentRaycastDistance = primaryPointer.Result.Details.RayDistance;
prevPointerExtent = primaryPointer.PointerExtent;
primaryPointer.PointerExtent = currentRaycastDistance;
}

Expand Down Expand Up @@ -742,8 +753,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;

Expand Down