Page 1 of 1

breakable constraints

Posted: Mon Jul 03, 2006 5:05 pm
by Erwin Coumans
To trigger breaking chains, collapsing bridges etc. there is a new getAppliedImpulse to measure 'stress' on the constraints. A bridge can be build using 'hinge' constraint, or a bunch of point-to-point constraints.

The stress/appliedImpulse can be read out in the very latest RC3 preview43 build, see the included breaking_chain.blend.

Win32:
http://www.continuousphysics.com/ftp/pu ... indows.zip

Linux:
http://www.continuousphysics.com/ftp/pu ... view43.tgz

Code: Select all

#shows breaking constraints dependent on constraint 'appliedImpulse'
import PhysicsConstraints
import GameLogic
ob = GameLogic.getCurrentController().getOwner()
#ob.id points to the constraint id
imp1 = PhysicsConstraints.getAppliedImpulse(ob.id)
imp = imp1*imp1
print imp
breakingTreshold = 0.82
if imp>breakingTreshold:
    PhysicsConstraints.removeConstraint(ob.id)


Erwin

Re: breakable constraints

Posted: Wed Nov 04, 2009 5:19 am
by RJNelson68
I realize this is an old post, but where could you detect the constraint's id? I am just looking for a place that this could be utilized becasue as far as I can tell the forces applied to the joints are not exposed to use something like this.

Re: breakable constraints

Posted: Wed Nov 04, 2009 8:32 pm
by RJNelson68
OK I have a nearly working system but I need to access the btDiscreteDynamicsWorld from btRigidBody to perform the removeConstraint function.

Code: Select all

void btRigidBody::checkToBreakConstraints()
{
	for (int i = 0; i < m_constraintRefs.size(); ++i)
	{
		btTypedConstraint* constraint = m_constraintRefs[i];
		if(constraint->getBreakable())
		{
			btScalar imp1 = constraint->getAppliedImpulse();
			btScalar imp = imp1 * imp1;
			if(imp > constraint->getBreakThreshold())
        }
	}
}
As you can tell I added a flag and a float to use for detecting if the joint is breakable and what the break threshold would be. Can someone tell me how to access the world so I can call the function?