constraints setLimit problem

Post Reply
Posts: 2
Joined: Tue May 31, 2011 2:53 pm

constraints setLimit problem

Post by muzer » Wed Jun 01, 2011 3:29 am


I'm trying to make the Bullet physics run on flash player. if you installed the new flash player11( ... bator.html), you can look this demo: ... yTest.html, the dynamics and collision is works fine.

But I had some trouble in creating hinge and generic 6Dof constraints. When I create a hinge constraint, it works fine if there is no limit, but once I set the limit, the hinge start auto rotate and shake.

look this two test: (click the mouse left button shoot ball)
the first test there is no limit, works fine. the second test has set limit.

here is the code I create the hinge:

Code: Select all

btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
btCollisionDispatcher* dispatcher = new	btCollisionDispatcher(collisionConfiguration);
btBroadphaseInterface* overlappingPairCache = new btDbvtBroadphase();
btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver();

btDiscreteDynamicsWorld* dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,overlappingPairCache,solver,collisionConfiguration);

btCollisionShape* shape = new btBoxShape(btVector3(5.0f,10.0f,1.0f));
double mass=1;
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0,0,0);
if (isDynamic)

btDefaultMotionState* myMotionState = new btDefaultMotionState();
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,shape,localInertia);
btRigidBody* body = new btRigidBody(rbInfo);

btVector3 pivot(0,0,0);
btVector3 axis(0,1,0);
btHingeConstraint* hinge = new btHingeConstraint(*body, pivot, axis);
hinge->setLimit( -SIMD_PI * 0.25f, SIMD_PI * 0.25f );//there is problem if add this line

I think maybe I have made some mistake on understanding operating mechanism. but I'm not find out what cause this.
So I post here hope anyone have experience on this. Any suggestion will be appreciate!

Posts: 6
Joined: Mon May 30, 2011 8:00 am

Re: constraints setLimit problem

Post by Xcoder77 » Wed Jun 01, 2011 7:44 am

Look at Bullet Physics Manual under constraints section

Post Reply