Fix issue in ContactManifoldSet

This commit is contained in:
Daniel Chappuis 2017-10-04 22:38:39 +02:00
parent cbfeb608df
commit d62aa41974

View File

@ -253,14 +253,14 @@ void ContactManifoldSet::removeManifold(ContactManifold* manifold) {
ContactManifold* next = manifold->getNext(); ContactManifold* next = manifold->getNext();
if (previous != nullptr) { if (previous != nullptr) {
previous->setNext(manifold->getNext()); previous->setNext(next);
} }
else { else {
mManifolds = next; mManifolds = next;
} }
if (next != nullptr) { if (next != nullptr) {
next->setPrevious(manifold->getPrevious()); next->setPrevious(previous);
} }
// Delete the contact manifold // Delete the contact manifold
@ -286,30 +286,21 @@ void ContactManifoldSet::makeContactsObsolete() {
void ContactManifoldSet::clearObsoleteManifoldsAndContactPoints() { void ContactManifoldSet::clearObsoleteManifoldsAndContactPoints() {
ContactManifold* manifold = mManifolds; ContactManifold* manifold = mManifolds;
ContactManifold* previousManifold = nullptr;
while (manifold != nullptr) { while (manifold != nullptr) {
// Get the next manifold in the linked-list
ContactManifold* nextManifold = manifold->getNext(); ContactManifold* nextManifold = manifold->getNext();
// If the manifold is obsolete
if (manifold->getIsObsolete()) { if (manifold->getIsObsolete()) {
if (previousManifold != nullptr) {
previousManifold->setNext(nextManifold);
if (nextManifold != nullptr) {
nextManifold->setPrevious(previousManifold);
}
}
else {
mManifolds = nextManifold;
}
// Delete the contact manifold // Delete the contact manifold
removeManifold(manifold); removeManifold(manifold);
} }
else { else {
// Clear the obsolete contact points of the manifold
manifold->clearObseleteContactPoints(); manifold->clearObseleteContactPoints();
previousManifold = manifold;
} }
manifold = nextManifold; manifold = nextManifold;