Repository navigation
fix(flame_3d): Invalidate the AABB of a parent when a child is added or removed - #4180
Merged
Merged
Conversation
wolfenrain
approved these changes
Oct 31, 2026
…or removed A parent's AABB is the hull of its own geometry and the AABBs of its children, but adding or removing a child didn't invalidate it. Since an Object3D culls itself and its whole subtree using its AABB, a child added inside the view could be skipped when the parent's cached AABB was outside of it. The parent's AABB is now marked dirty when a component is mounted or removed.
ufrshubham
force-pushed
the
devkage/fix-3d-aabb-on-child-added
branch
from
October 31, 2026 16:09
bb957e4 to
c342e18
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
A
Component3D's AABB is the hull of its own geometry and the AABBs of its children, but adding or removing a child didn't invalidate the parent's cached AABB.Object3D.renderTreeculls a component together with its whole subtree using its AABB, so a child added inside the view was never rendered when the parent's cached AABB was outside of it, for example a spawner or pool that adds children to itself at runtime.This PR marks the parent's AABB as dirty when a component is mounted, so new children are included in it. It does the same when a component is removed, which isn't visible but keeps the parent's AABB from staying bigger than its children. Marking stops at the first ancestor that is already dirty and the AABB is only recomputed lazily, so this costs the same as a child moving, which already marks its ancestors dirty.
The tests cover a child added to a parent, a child added deeper in the hierarchy and a child being removed, and all of them fail without the fix. I also verified the fix with the repro from #4164 on Windows.
This PR is stacked on top of #4167, as both add the same test file. It will be retargeted to
mainonce #4167 is merged.before_4164.mp4
after_4164.mp4
Checklist
docsand added dartdoc comments with///.examplesordocs.Breaking Change?
Related Issues
Closes #4164