Skip to content

Commit

Permalink
Merge pull request #9866 from davidkline-ms/2.6.2
Browse files Browse the repository at this point in the history
[2.6.2] Cherry-pick #9819
  • Loading branch information
David Kline committed May 24, 2021
2 parents 5a82135 + b126b4f commit 4f18f90
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,12 @@ private void MeshGenerationAction(MeshGenerationResult meshGenerationResult)
}
meshes.Add(meshObject.Id, meshObject);

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

meshEventData.Initialize(this, meshObject.Id, meshObject);
if (isMeshUpdate)
Expand Down

0 comments on commit 4f18f90

Please sign in to comment.