[Simulation.Core] Fix BoundingBox initialization and updates#6146
Open
fredroy wants to merge 2 commits into
Open
[Simulation.Core] Fix BoundingBox initialization and updates#6146fredroy wants to merge 2 commits into
fredroy wants to merge 2 commits into
Conversation
… to compute bbox (or not)
hugtalbot
approved these changes
Jun 11, 2026
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.
BoundingBox's handling in SOFA is a recurring issue for time immemorial.
This PR is supposed to fix the fact that the bounding box cannot shrink during the simulation, only increase, which poses quite a problem for the scenes with long wire.
Admittedly This comes from the bug
I guess the isSet was understood like "if in the xml, it is written bbox=XXXX" but isSet is set to true as soon as beginEdit() is called... so the condition will be always true.
Before, as the condition was always true, the bbox was always kept from the previous step. Moreover, bbox's API only allow the bbox to be increased.
Now if the BBox is
not set before initthen it will invalided and then recomputed from zero.A better solution would be (maybe) to have a better tracking of the value in the Data API but I did not want to touch anything in Data/Base....
Note that the BBoxes of the component inside the Node are still computed.
before (never reduced)


after (can shrink)
This fixes also an other bug when computeBBox=false for the animation loop, when the bbox is computed only during init() but does not take into account mappings.

My use case, a BeamAdapter scene, the bounding box is huge because of the rest position of the catheter (due to the quirks on how to build a wire), the bbox is computed once after init(), and then never resized:
with this PR:

--
NB: I set experimental because I know someone, somewhere will have a problem due to this PR, so I would like extensive tests from users 🥸
[with-all-tests]
By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).
Reviewers will merge this pull-request only if