I have done it like Erwin described here in this post. http://www.bulletphysics.org/Bullet/php ... f=9&t=2814
But if I do so the constraint is only deleted if the main object is deleted (object 3). If the target object will be deleted the constraint will not be deleted (object 4). If a add the reference with addConstraintRef() to the target object, the collisions between linked bodies will be disabled.
1. Is there a simple way, without modifying the bullet source, to delete the constraint if the target object will be deleted?
2. Why the constraint references is used to disable the collisions between linked bodies?
Code: Select all
653
void btDiscreteDynamicsWorld::addConstraint(btTypedConstraint* constraint,bool disableCollisionsBetweenLinkedBodies)
{
m_constraints.push_back(constraint);
if (disableCollisionsBetweenLinkedBodies)
{
constraint->getRigidBodyA().addConstraintRef(constraint);
constraint->getRigidBodyB().addConstraintRef(constraint);
}
}
320
bool btRigidBody::checkCollideWithOverride(const btCollisionObject* co) const
{
const btRigidBody* otherRb = btRigidBody::upcast(co);
if (!otherRb)
return true;
for (int i = 0; i < m_constraintRefs.size(); ++i)
{
const btTypedConstraint* c = m_constraintRefs[i];
if (c->isEnabled())
if (&c->getRigidBodyA() == otherRb || &c->getRigidBodyB() == otherRb)
return false;
}
return true;
}