Why two pivot specs?

Post Reply
bram
Posts: 51
Joined: Sun Nov 23, 2008 4:43 pm

Why two pivot specs?

Post by bram »

btHello()

I'm porting my code from OpenDE to Bullet.

I got puzzled by Bullet's hinge constraint.
Why do I have to specify the pivot twice, once in rbA's frame, and once in rbB's frame?
Surely, the hinge has ONE pivot, and ONE axis?

From OpenDE, I am used to just place two bodies, and then specify pivot and axis in global coordinates.
Bullet seems to want them in local coordinates, twice?
I find dealing with global coordinates easier.
Or am I missing something?
Are there helper functions that can be of use for creating constraints between two bodies?

Thanks,

Bram Stolk
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Why two pivot specs?

Post by Erwin Coumans »

This way you can create a constraint that is in initial violation (if desired),
so you can serialize the state exactly as-is, load the simulation and continue from there.

It is trivial to convert from global frame to local:

btTransform globalFrame=...
btTransform localFrameInA = bodyA.getWorldTransform().inverse()*globalFrame;
btTransform localFrameInB = bodyB.getWorldTransform().inverse()*globalFrame;

Hope this helps,
Erwin
bram
Posts: 51
Joined: Sun Nov 23, 2008 4:43 pm

Re: Why two pivot specs?

Post by bram »

Thanks Erwin,

Please note that btHinge2Constraint() deviates from this, and seems to follow OpenDE's use of global axes instead?

Code: Select all

    btHinge2Constraint(btRigidBody& rbA, btRigidBody& rbB, btVector3& anchor, btVector3& axis1, btVector3& axis2);
Post Reply