Skip to content

[Simulation.Core] Fix: Keep a node bbox written after its creation - #6443

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

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

Conversation

@fredroy

@fredroy fredroy commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Fixing the BBox in Node, episode 324325
With SofaPython3 bindings, setting the bbox for root in createScene() was not working 💀

A node bbox was only considered fixed when given as a scene attribute (Node::parse sets m_bboxIsFixed).
Writing the bbox Data afterwards, e.g. root.bbox = ... in a Python createScene or from a controller, was silently overwritten by InitVisitor/UpdateBoundingBoxVisitor, which recompute every non-fixed bbox from the objects and children.

[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).

NodeBBox_test covers how a node bbox is computed or kept:
- computedBBoxFollowsObjects: without a given bbox, it is computed at
  init and follows the objects when they move;
- bboxSetBeforeInitIsKept / bboxSetAfterInitIsKept: a bbox written after
  the node creation (e.g. `root.bbox = ...` from Python, or from a
  controller) is kept by init and by UpdateBoundingBoxVisitor;
- bboxFromSceneAttributeIsKeptAndIncludedInParent: a bbox given as a
  scene attribute (Node::parse) is kept, and the computed bbox of the
  parent includes it along with its computed siblings.

bboxSetBeforeInitIsKept and bboxSetAfterInitIsKept fail at this commit:
a bbox written after the node creation is overwritten. Fixed by the
next commit.
A node bbox was only considered fixed when given as a scene attribute
(Node::parse sets m_bboxIsFixed). Writing the bbox Data afterwards, e.g.
`root.bbox = ...` in a Python createScene or from a controller, was
silently overwritten by InitVisitor/UpdateBoundingBoxVisitor, which
recompute every non-fixed bbox from the objects and children.

- Node::bboxIsFixed() is now also true when the bbox Data is set.
- InitVisitor and UpdateBoundingBoxVisitor no longer touch a fixed bbox,
  and unset() the Data after writing a computed one, so that only an
  external write marks it as set (every Data write marks it set).

Computed bboxes keep following the objects; scene attributes and
addChild(name, bbox=...) behave as before.
@fredroy fredroy added pr: fix Fix a bug pr: status to review To notify reviewers to review this pull-request pr: based on previous PR PR based on a previous PR, therefore to be merged ONLY subsequently pr: AI-aided Label notifying the reviewers that part or all of the PR has been generated with the help of an AI labels Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: AI-aided Label notifying the reviewers that part or all of the PR has been generated with the help of an AI pr: based on previous PR PR based on a previous PR, therefore to be merged ONLY subsequently 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.

1 participant