Fix #86861: Respect top_level property of children when drawing selection box #1
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.
Previously, children with
top_level=true
were bounded as if they weretop_level=false
. This led to situations where selection boxes were drawn incorrectly. The box would appear offset from the object it was meant to render onto.Node3DEditorViewport::_calculate_spatial_bounds
traverses the scene tree to calculate bounds in a bottom-up fashion. Children boxes are transformed relative to their parents until we reach the top-level parent (the one the function was initially called on). The final return value is a bounding box in the top-level parent's local space.On line 2812 in the caller, the top-level node's transform is applied to get the final selection box in global space.
This fix applies the inverse of the parent's global transform to children with
top_level=true
. This counteracts the transforms we apply while traversing the scene tree. It also counteracts the caller's final transform on line 2812.