Fix two issues
This commit is contained in:
parent
0071ed16a8
commit
af2fcaeb82
|
@ -34,8 +34,10 @@ BallAndSocketJoint::BallAndSocketJoint(const BallAndSocketJointInfo &jointInfo)
|
||||||
: Constraint(jointInfo), mImpulse(Vector3(0, 0, 0)) {
|
: Constraint(jointInfo), mImpulse(Vector3(0, 0, 0)) {
|
||||||
|
|
||||||
// Compute the local-space anchor point for each body
|
// Compute the local-space anchor point for each body
|
||||||
mLocalAnchorPointBody1 = mBody1->getTransform().getInverse() * jointInfo.anchorPointWorldSpace;
|
mLocalAnchorPointBody1 = mBody1->getTransform().getOrientation().getInverse() *
|
||||||
mLocalAnchorPointBody1 = mBody1->getTransform().getInverse() * jointInfo.anchorPointWorldSpace;
|
jointInfo.anchorPointWorldSpace;
|
||||||
|
mLocalAnchorPointBody2 = mBody2->getTransform().getOrientation().getInverse() *
|
||||||
|
jointInfo.anchorPointWorldSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
@ -107,13 +109,13 @@ void BallAndSocketJoint::solve(const ConstraintSolverData& constraintSolverData)
|
||||||
Vector3 Jv = -v1 + mU1World.cross(w1) + v2 - mU2World.cross(w2);
|
Vector3 Jv = -v1 + mU1World.cross(w1) + v2 - mU2World.cross(w2);
|
||||||
|
|
||||||
// Compute the bias "b" of the constraint
|
// Compute the bias "b" of the constraint
|
||||||
decimal beta = 0.8; // TODO : Use a constant here
|
decimal beta = 0.7; // TODO : Use a constant here
|
||||||
decimal biasFactor = -(beta/constraintSolverData.timeStep);
|
decimal biasFactor = -(beta/constraintSolverData.timeStep);
|
||||||
Vector3 b = biasFactor * (x2 + mU2World - x1 - mU1World);
|
Vector3 b = biasFactor * (x2 + mU2World - x1 - mU1World);
|
||||||
|
|
||||||
// Compute the Lagrange multiplier lambda
|
// Compute the Lagrange multiplier lambda
|
||||||
Vector3 deltaLambda = mInverseMassMatrix * (-Jv - b);
|
Vector3 deltaLambda = mInverseMassMatrix * (-Jv - b);
|
||||||
mImpulse = mImpulse + deltaLambda;
|
mImpulse += deltaLambda;
|
||||||
|
|
||||||
// Compute the impulse P=J^T * lambda
|
// Compute the impulse P=J^T * lambda
|
||||||
Vector3 linearImpulseBody1 = -deltaLambda;
|
Vector3 linearImpulseBody1 = -deltaLambda;
|
||||||
|
|
|
@ -219,11 +219,15 @@ void DynamicsWorld::integrateRigidBodiesVelocities() {
|
||||||
RigidBody* rigidBody = *it;
|
RigidBody* rigidBody = *it;
|
||||||
mMapBodyToConstrainedVelocityIndex.insert(std::make_pair<RigidBody*, uint>(rigidBody, i));
|
mMapBodyToConstrainedVelocityIndex.insert(std::make_pair<RigidBody*, uint>(rigidBody, i));
|
||||||
|
|
||||||
// Integrate the external force to get the new velocity of the body
|
// If the body is allowed to move
|
||||||
mConstrainedLinearVelocities[i] = rigidBody->getLinearVelocity() +
|
if (rigidBody->getIsMotionEnabled()) {
|
||||||
dt * rigidBody->getMassInverse() * rigidBody->getExternalForce();
|
|
||||||
mConstrainedAngularVelocities[i] = rigidBody->getAngularVelocity() +
|
// Integrate the external force to get the new velocity of the body
|
||||||
dt * rigidBody->getInertiaTensorInverseWorld() * rigidBody->getExternalTorque();
|
mConstrainedLinearVelocities[i] = rigidBody->getLinearVelocity() +
|
||||||
|
dt * rigidBody->getMassInverse() * rigidBody->getExternalForce();
|
||||||
|
mConstrainedAngularVelocities[i] = rigidBody->getAngularVelocity() +
|
||||||
|
dt * rigidBody->getInertiaTensorInverseWorld() * rigidBody->getExternalTorque();
|
||||||
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user