diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BaseContactLagrangianConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BaseContactLagrangianConstraint.inl index 5286a588fd3..e88e3c553fb 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BaseContactLagrangianConstraint.inl +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BaseContactLagrangianConstraint.inl @@ -105,7 +105,7 @@ void BaseContactLagrangianConstraint::buildConstraintM if (this->mstate1 == this->mstate2) { - MatrixDeriv& c1 = *c1_d.beginEdit(); + helper::WriteAccessor c1 = c1_d; for (unsigned int i = 0; i < contacts.size(); i++) { @@ -132,12 +132,11 @@ void BaseContactLagrangianConstraint::buildConstraintM } } - c1_d.endEdit(); } else { - MatrixDeriv& c1 = *c1_d.beginEdit(); - MatrixDeriv& c2 = *c2_d.beginEdit(); + helper::WriteAccessor c1 = c1_d; + helper::WriteAccessor c2 = c2_d; for (unsigned int i = 0; i < contacts.size(); i++) { @@ -169,8 +168,6 @@ void BaseContactLagrangianConstraint::buildConstraintM } } - c1_d.endEdit(); - c2_d.endEdit(); } }