Skip to content

[Visual] Scene center and radius are not longer cached#5976

Open
alxbilger wants to merge 3 commits intosofa-framework:masterfrom
alxbilger:basecamera
Open

[Visual] Scene center and radius are not longer cached#5976
alxbilger wants to merge 3 commits intosofa-framework:masterfrom
alxbilger:basecamera

Conversation

@alxbilger
Copy link
Contributor

This PR removes the cache mechanism around the scene center and radius in the BaseCamera class.

Removed:

  • Data member sceneCenter and sceneRadius are removed. This is breaking for derived class using them.

Added:

  • Methods to get the scene center and radius when needed.

Changes:

  • The cached scene center and radius are replaced by direct calls to the newly added methods.

Effects:

  • If fixes a bug producing nans in the projection matrix of the camera. The cached value sceneCenter was used, but it was not already computed and cached. Therefore, the default value was used (likely zero). The default value was then used to compute Znear and Zfar, resulting both to be set to zero. At some point there is a division by (currentZFar - currentZNear), leading to a nan.

Before:
image

After:
image

Note that I don't understand why having nan is not problematic. I am not sure neither if having valid values helps.

I took the opportunity to add easy constness to some methods.


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

This avoids a case where it was used but not yet defined.
@alxbilger alxbilger added pr: fix Fix a bug pr: status to review To notify reviewers to review this pull-request labels Feb 26, 2026
@fredroy fredroy added pr: status ready Approved a pull-request, ready to be squashed and removed pr: status to review To notify reviewers to review this pull-request labels Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: fix Fix a bug pr: status ready Approved a pull-request, ready to be squashed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants