fix issue related to addConstraint/removeConstraint, introduced by filtering collision between two particular bodies
https://github.com/bulletphysics/bullet3/issues/173
This commit is contained in:
@@ -653,6 +653,9 @@ void btDiscreteDynamicsWorld::updateActivationState(btScalar timeStep)
|
||||
void btDiscreteDynamicsWorld::addConstraint(btTypedConstraint* constraint,bool disableCollisionsBetweenLinkedBodies)
|
||||
{
|
||||
m_constraints.push_back(constraint);
|
||||
//Make sure the two bodies of a type constraint are different (possibly add this to the btTypedConstraint constructor?)
|
||||
btAssert(&constraint->getRigidBodyA()!=&constraint->getRigidBodyB());
|
||||
|
||||
if (disableCollisionsBetweenLinkedBodies)
|
||||
{
|
||||
constraint->getRigidBodyA().addConstraintRef(constraint);
|
||||
|
||||
@@ -326,7 +326,7 @@ void btRigidBody::addConstraintRef(btTypedConstraint* c)
|
||||
|
||||
int index = m_constraintRefs.findLinearSearch(c);
|
||||
//don't add constraints that are already referenced
|
||||
btAssert(index == m_constraintRefs.size());
|
||||
//btAssert(index == m_constraintRefs.size());
|
||||
if (index == m_constraintRefs.size())
|
||||
{
|
||||
m_constraintRefs.push_back(c);
|
||||
@@ -340,25 +340,27 @@ void btRigidBody::addConstraintRef(btTypedConstraint* c)
|
||||
{
|
||||
colObjB->setIgnoreCollisionCheck(colObjA, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void btRigidBody::removeConstraintRef(btTypedConstraint* c)
|
||||
{
|
||||
int index = m_constraintRefs.findLinearSearch(c);
|
||||
//don't remove constraints that are not referenced
|
||||
btAssert(index < m_constraintRefs.size());
|
||||
m_constraintRefs.remove(c);
|
||||
btCollisionObject* colObjA = &c->getRigidBodyA();
|
||||
btCollisionObject* colObjB = &c->getRigidBodyB();
|
||||
if (colObjA == this)
|
||||
{
|
||||
colObjA->setIgnoreCollisionCheck(colObjB, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
colObjB->setIgnoreCollisionCheck(colObjA, false);
|
||||
}
|
||||
if(index < m_constraintRefs.size())
|
||||
{
|
||||
m_constraintRefs.remove(c);
|
||||
btCollisionObject* colObjA = &c->getRigidBodyA();
|
||||
btCollisionObject* colObjB = &c->getRigidBodyB();
|
||||
if (colObjA == this)
|
||||
{
|
||||
colObjA->setIgnoreCollisionCheck(colObjB, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
colObjB->setIgnoreCollisionCheck(colObjA, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int btRigidBody::calculateSerializeBufferSize() const
|
||||
|
||||
Reference in New Issue
Block a user