Correct parenting of spatial mesh to preserve local transform. #9819
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
When the spatial mesh's transform was getting attached to the ObservedObjectParent using the parent property, the default behavior of preserving world space position was kicking in.
This sounds right, but isn't. It meant that the current ObservedObjectParent's transform (which ultimately resolves to the MRTK Playspace transform) was getting discarded (or more specifically, absorbed into the mesh's local transform).
This led to the observed behavior, that when the MRTK Playspace transform changed, existing spatial meshes remained in correct position (because they were attached to the MRTK Playspace). But new spatial meshes, because they essentially discarded the playspace transform, would appear offset from their physical counterparts.
Changes
Verification
The issue was most easily seen by clearing the hololens spatial map via WDP before running.
Only XRSDK was affected. WSA worked fine, OpenXR doesn't seem to have spatial meshes yet.