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

Fix #86861: Respect top_level property of children when drawing selection box #1

Merged
merged 1 commit into from
Jan 12, 2024

Conversation

cooperra
Copy link

Previously, children with top_level=true were bounded as if they were top_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.

…awing selection box

Previously, children with `top_level=true` were bounded as if they were `top_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][].

[line 2812]: https://github.com/godotengine/godot/blob/9b522ac1a85cab1a7a867b7a9f3bb102d9376ac2/editor/plugins/node_3d_editor_plugin.cpp#L2812
@ryevdokimov ryevdokimov changed the base branch from master to fix-86861 January 12, 2024 03:58
@ryevdokimov ryevdokimov merged commit 0426810 into Open-Industry-Project:fix-86861 Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants