Skip to content

Commit 5ed65a5

Browse files
committed
Ensure the bounds are recalculated
Otherwise, they'll stay vaguely at the origin on some platforms, which causes Unity to clip them as you look away from the origin Update PlatformHandMeshVisualizer.cs
1 parent d147fb1 commit 5ed65a5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

org.mixedrealitytoolkit.input/Visualizers/PlatformHandVisualizer/PlatformHandMeshVisualizer.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ protected void Update()
9595
if (meshInfo.ChangeState == MeshChangeState.Added
9696
|| meshInfo.ChangeState == MeshChangeState.Updated)
9797
{
98-
handRenderer.enabled = true;
99-
10098
meshSubsystem.GenerateMeshAsync(meshInfo.MeshId, meshFilter.mesh,
10199
null, MeshVertexAttributes.Normals, result => { });
102100

101+
handRenderer.enabled = true;
102+
103103
// This hand mesh is provided pre-translated from the world origin,
104104
// so we want to ensure the mesh is "centered" at the world origin
105105
transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity);
@@ -110,6 +110,11 @@ protected void Update()
110110
&& handMeshTracker.TryGetHandMesh(FrameTime.OnUpdate, meshFilter.mesh)
111111
&& handMeshTracker.TryLocateHandMesh(FrameTime.OnUpdate, out Pose pose))
112112
{
113+
// On some runtimes, the mesh is moved in its local space instead of world space,
114+
// while its world space location is unchanged. In this case, we want to ensure the
115+
// bounds follow the hand around by manually recalculating them.
116+
meshFilter.mesh.RecalculateBounds();
117+
113118
handRenderer.enabled = true;
114119

115120
if (!initializedUVs && handMeshTracker.TryGetHandMesh(FrameTime.OnUpdate, neutralPoseMesh, HandPoseType.ReferenceOpenPalm))

0 commit comments

Comments
 (0)