Skip to content

[Simulation.Core] Fix BoundingBox initialization and updates#6146

Open
fredroy wants to merge 2 commits into
sofa-framework:masterfrom
fredroy:fix_fixed_bbox_and_update
Open

[Simulation.Core] Fix BoundingBox initialization and updates#6146
fredroy wants to merge 2 commits into
sofa-framework:masterfrom
fredroy:fix_fixed_bbox_and_update

Conversation

@fredroy

@fredroy fredroy commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

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

    sofa::type::BoundingBox* nodeBBox = node->f_bbox.beginEdit();
    if(!node->f_bbox.isSet())
    ....

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 init then 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)
bbox_norefit
after (can shrink)
bbox_refit


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

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@fredroy fredroy added pr: fix Fix a bug pr: status to review To notify reviewers to review this pull-request pr: experimental Demonstrate an experimental feature pr: status wip Development in the pull-request is still in progress and removed pr: status to review To notify reviewers to review this pull-request pr: status wip Development in the pull-request is still in progress labels Jun 9, 2026
@hugtalbot hugtalbot added this to the v26.06 milestone Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: experimental Demonstrate an experimental feature pr: fix Fix a bug pr: status to review To notify reviewers to review this pull-request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants