Skip to content

Commit 4f18f90

Browse files
author
David Kline
authored
Merge pull request #9866 from davidkline-ms/2.6.2
[2.6.2] Cherry-pick #9819
2 parents 5a82135 + b126b4f commit 4f18f90

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Assets/MRTK/Providers/XRSDK/GenericXRSDKSpatialMeshObserver.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,12 @@ private void MeshGenerationAction(MeshGenerationResult meshGenerationResult)
495495
}
496496
meshes.Add(meshObject.Id, meshObject);
497497

498-
meshObject.GameObject.transform.parent = (ObservedObjectParent.transform != null) ?
499-
ObservedObjectParent.transform : null;
498+
// This is important. We need to preserve the mesh's local transform here, not its global pose.
499+
// Think of it like this. If we set the camera's coordinates 3 meters to the left, the physical camera
500+
// hasn't moved, only its coordinates have changed. Likewise, the physical room hasn't moved (relative to
501+
// the physical camera), so we also want to set its coordinates 3 meters to the left.
502+
Transform meshObjectParent = (ObservedObjectParent.transform != null) ? ObservedObjectParent.transform : null;
503+
meshObject.GameObject.transform.SetParent(meshObjectParent, false);
500504

501505
meshEventData.Initialize(this, meshObject.Id, meshObject);
502506
if (isMeshUpdate)

0 commit comments

Comments
 (0)