Skip to content

Commit 3c1c2f1

Browse files
committed
Guard against an argumentexception if we're trying to update a source that was just lost
1 parent 9d703f3 commit 3c1c2f1

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Assets/MRTK/Providers/WindowsMixedReality/Shared/WindowsMixedRealityHandMeshProvider.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,21 @@ public void UpdateHandMesh(SpatialInteractionSourceState sourceState)
209209

210210
if (vertexAndNormals != null && handMeshTriangleIndices != null)
211211
{
212-
var handMeshVertexState = handMeshObserver.GetVertexStateForPose(handPose);
212+
HandMeshVertexState handMeshVertexState = null;
213+
try
214+
{
215+
handMeshVertexState = handMeshObserver.GetVertexStateForPose(handPose);
216+
}
217+
catch (ArgumentException)
218+
{
219+
Debug.Log($"{nameof(WindowsMixedRealityHandMeshProvider)} failed to update the hand mesh. This might happen if a source was detected and lost rapidly. Otherwise, the mesh might be stale this frame.");
220+
}
221+
222+
if (handMeshVertexState == null)
223+
{
224+
return;
225+
}
226+
213227
handMeshVertexState.GetVertices(vertexAndNormals);
214228

215229
var meshTransform = handMeshVertexState.CoordinateSystem.TryGetTransformTo(WindowsMixedRealityUtilities.SpatialCoordinateSystem);

0 commit comments

Comments
 (0)