minor bug in btConeTwistConstraint 1-body constructor

JedL
Posts: 1
Joined: Thu Jan 17, 2008 6:49 am

minor bug in btConeTwistConstraint 1-body constructor

Post by JedL »

When playing around with btConeTwistConstraint for the first time, I tried to make a box connected to the world (i.e. no bodyB). The shape kept zooming to the origin instead of sticking where I wanted it. I walked through the solver code and eventually found the workaround below. It sets B's coordinate frame origin to A's transformed origin. btPoint2PointConstraint already does this in it's 1-body constructor. btConeTwistConstraint should, too.

Code: Select all

// BodyA is out in the world, not at the origin.
btTransform localA;
localA.setIdentity();
localA.setOrigin( btVector3(0, 0, -1); // Some point, not zero.

// BUG: doesn't put origin of second frame at the right place
//pJoint = new btConeTwistConstraint(*pBodyA, localA);

// WORKAROUND:
static btRigidBody fixed( 0, 0, 0 );
btTransform localB = localA;
localB.setOrigin( pBodyA->getCenterOfMassTransform() * localA.getOrigin() );
pJoint = new btConeTwistConstraint(*pBodyA, fixed, localA, localB);
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: minor bug in btConeTwistConstraint 1-body constructor

Post by Erwin Coumans »

That should probably be fixed indeed, I'll check it out.

Thanks for the feedback,
Erwin