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 @@ -345,6 +345,7 @@ public Vector2 NudgeConstraints

private int prevPhysicsLayer;
private int boundingBoxPrevPhysicsLayer;
private SpatialMeshDisplayOptions prevSpatialMeshDisplay;

#region Monobehaviour Implementation

Expand Down Expand Up @@ -396,6 +397,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 @@ -716,7 +720,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 Down Expand Up @@ -757,7 +766,10 @@ 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;
Expand Down