fix hinge-constraint constructors to use otherAxis

This commit is contained in:
Seth Alves 2017-04-15 08:51:08 -07:00
parent db98020974
commit d42970d480

View file

@ -84,31 +84,24 @@ btTypedConstraint* ObjectConstraintHinge::getConstraint() {
return nullptr; return nullptr;
} }
bool useReferenceFrameA { false };
if (!otherEntityID.isNull()) { if (!otherEntityID.isNull()) {
// This hinge is between two entities... find the other rigid body. // This hinge is between two entities... find the other rigid body.
btRigidBody* rigidBodyB = getOtherRigidBody(otherEntityID); btRigidBody* rigidBodyB = getOtherRigidBody(otherEntityID);
if (!rigidBodyB) { if (!rigidBodyB) {
return nullptr; return nullptr;
} }
btTransform rigidBodyAFrame(btQuaternion(0.0f, 0.0f, 0.0f, 1.0f), glmToBullet(pivotInA));
btTransform rigidBodyBFrame(btQuaternion(0.0f, 0.0f, 0.0f, 1.0f), glmToBullet(pivotInB));
constraint = new btHingeConstraint(*rigidBodyA, *rigidBodyB, constraint = new btHingeConstraint(*rigidBodyA, *rigidBodyB,
rigidBodyAFrame, rigidBodyBFrame, glmToBullet(pivotInA), glmToBullet(pivotInB),
useReferenceFrameA); glmToBullet(axisInA), glmToBullet(axisInB),
true); // useReferenceFrameA
} else { } else {
// This hinge is between an entity and the world-frame. // This hinge is between an entity and the world-frame.
btTransform rigidBodyAFrame(btQuaternion(0.0f, 0.0f, 0.0f, 1.0f), glmToBullet(pivotInA)); constraint = new btHingeConstraint(*rigidBodyA,
glmToBullet(pivotInA), glmToBullet(axisInA),
constraint = new btHingeConstraint(*rigidBodyA, rigidBodyAFrame, useReferenceFrameA); true); // useReferenceFrameA
} }
btVector3 bulletAxisInA = glmToBullet(axisInA);
constraint->setAxis(bulletAxisInA);
constraint->setLimit(low, high, softness, biasFactor, relaxationFactor); constraint->setLimit(low, high, softness, biasFactor, relaxationFactor);
withWriteLock([&]{ withWriteLock([&]{