Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct parenting of spatial mesh to preserve local transform. #9819

Merged
merged 1 commit into from
May 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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