Fix bounding boxes

Each time an AABB is rotated, it gets bigger. That means opposite rotations don't cancel out.

The previous implementation repeatedly rotates children AABBs as it climbs up the tree. This often resulted in selection boxes looking bigger than their contents.

This implementation calculates and applies a single final transformation to each AABB before it is merged with the others. After merging, there are no additional rotations, so AABBs remain accurate.

Co-Authored-By: Robert Yevdokimov <105675984+ryevdokimov@users.noreply.github.com>
This commit is contained in:
Robbie Cooper
2024-01-10 20:44:06 -05:00
committed by Robert Yevdokimov
parent 10e111477d
commit 30914c0434
2 changed files with 18 additions and 19 deletions
+1 -1
View File
@@ -434,7 +434,7 @@ private:
Point2i _get_warped_mouse_motion(const Ref<InputEventMouseMotion> &p_ev_mouse_motion) const;
Vector3 _get_instance_position(const Point2 &p_pos) const;
static AABB _calculate_spatial_bounds(const Node3D *p_parent, bool p_exclude_top_level_transform = true);
static AABB _calculate_spatial_bounds(const Node3D *p_parent, const Node3D *p_top_level_parent = nullptr);
Node *_sanitize_preview_node(Node *p_node) const;