Skip to content

[Constraint] Improve initialization and state validation in StopperLagrangianConstraint#5935

Open
alxbilger wants to merge 1 commit intosofa-framework:masterfrom
alxbilger:initstopper
Open

[Constraint] Improve initialization and state validation in StopperLagrangianConstraint#5935
alxbilger wants to merge 1 commit intosofa-framework:masterfrom
alxbilger:initstopper

Conversation

@alxbilger
Copy link
Contributor


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

@alxbilger alxbilger added pr: status to review To notify reviewers to review this pull-request pr: clean Cleaning the code labels Feb 4, 2026
Comment on lines +47 to +53
helper::WriteAccessor<Data<VecCoord> > xData = *this->mstate->write(core::vec_id::write_access::position);
VecCoord& x = xData.wref();
if (x[d_index.getValue()].x() < d_min.getValue())
x[d_index.getValue()].x() = (Real) d_min.getValue();
if (x[d_index.getValue()].x() > d_max.getValue())
x[d_index.getValue()].x() = (Real) d_max.getValue();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get that this is just the old code refactored. But I find it intriguing that a lagrangian constraint is performing a pure projection at init. Nobody asked for this. I would remove this because it might create very bad internal stress in some cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This projection is here since the introduction of the component (9be66af)

If we remove the projection, we can remove the entire init method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would advocate for it. Let the constraint solver do the work instead of doing something unrelated before the solving...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: clean Cleaning the code 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