[kernel] allow unlink() calls outside updateInteractions() to reset OSNS matrices
motivation: removing interactions via collision manager removeBody()
(i.e. remove contact interactions) results in unlink() calls outside
of updateInteractions() that did not trigger updateIndexSets(),
leaving bad references in indexSet(1).
@@ -468,8 +468,7 @@ void Simulation::unlink(SP::Interaction inter)
void Simulation::updateInteractions()
{
// Update interactions if a manager was provided
- if (_interman) {
- _linkOrUnlink = false;
+ if (_interman)
_interman->updateInteractions(shared_from_this());
if (_linkOrUnlink) {
@@ -479,15 +478,14 @@ void Simulation::updateInteractions()
// topology->hasChanged() flag, it must be specified explicitly.
// Otherwise OneStepNSProblem may fail to update its matrices.
_nsds->topology()->setHasChanged(true);
- }
+ _linkOrUnlink = false;
}
}
void Simulation::updateInteractionsNewtonIteration()
{
// Update interactions if a manager was provided
- if (_interman) {
- _linkOrUnlink = false;
+ if (_interman)
_interman->updateInteractionsNewtonIteration(shared_from_this());
if (_linkOrUnlink) {
@@ -497,7 +495,7 @@ void Simulation::updateInteractionsNewtonIteration()
// topology->hasChanged() flag, it must be specified explicitly.
// Otherwise OneStepNSProblem may fail to update its matrices.
_nsds->topology()->setHasChanged(true);
- }
+ _linkOrUnlink = false;
}
}
