Fix compilation error on Mac OS X and errors in SliderJoint and HingeJoint
This commit is contained in:
parent
8ff0d9753c
commit
3173b368c7
|
@ -127,7 +127,7 @@ void Scene::simulate() {
|
|||
if (mIsRunning) {
|
||||
|
||||
// Update the motor speed of the Slider Joint (to move up and down)
|
||||
long double motorSpeed = 3 * cos(mDynamicsWorld->getPhysicsTime() * 1.5);
|
||||
long double motorSpeed = 2 * cos(mDynamicsWorld->getPhysicsTime() * 1.5);
|
||||
mSliderJoint->setMotorSpeed(rp3d::decimal(motorSpeed));
|
||||
|
||||
// Take a simulation step
|
||||
|
|
|
@ -194,9 +194,10 @@ void HingeJoint::initBeforeSolve(const ConstraintSolverData& constraintSolverDat
|
|||
mImpulseMotor = 0.0;
|
||||
}
|
||||
|
||||
if (mIsLimitEnabled && (mIsLowerLimitViolated || mIsUpperLimitViolated)) {
|
||||
// If the motor or limits are enabled
|
||||
if (mIsMotorEnabled || (mIsLimitEnabled && (mIsLowerLimitViolated || mIsUpperLimitViolated))) {
|
||||
|
||||
// Compute the inverse of the mass matrix K=JM^-1J^t for the limits (1x1 matrix)
|
||||
// Compute the inverse of the mass matrix K=JM^-1J^t for the limits and motor (1x1 matrix)
|
||||
mInverseMassMatrixLimitMotor = 0.0;
|
||||
if (mBody1->isMotionEnabled()) {
|
||||
mInverseMassMatrixLimitMotor += mA1.dot(mI1 * mA1);
|
||||
|
@ -207,6 +208,8 @@ void HingeJoint::initBeforeSolve(const ConstraintSolverData& constraintSolverDat
|
|||
mInverseMassMatrixLimitMotor = (mInverseMassMatrixLimitMotor > 0.0) ?
|
||||
decimal(1.0) / mInverseMassMatrixLimitMotor : decimal(0.0);
|
||||
|
||||
if (mIsLimitEnabled) {
|
||||
|
||||
// Compute the bias "b" of the lower limit constraint
|
||||
mBLowerLimit = 0.0;
|
||||
if (mPositionCorrectionTechnique == BAUMGARTE_JOINTS) {
|
||||
|
@ -219,6 +222,7 @@ void HingeJoint::initBeforeSolve(const ConstraintSolverData& constraintSolverDat
|
|||
mBUpperLimit = biasFactor * upperLimitError;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Warm start the constraint (apply the previous impulse at the beginning of the step)
|
||||
|
@ -423,6 +427,7 @@ void HingeJoint::solveVelocityConstraint(const ConstraintSolverData& constraintS
|
|||
|
||||
// --------------- Motor --------------- //
|
||||
|
||||
// If the motor is enabled
|
||||
if (mIsMotorEnabled) {
|
||||
|
||||
// Compute J*v for the motor
|
||||
|
|
|
@ -184,6 +184,7 @@ void SliderJoint::initBeforeSolve(const ConstraintSolverData& constraintSolverDa
|
|||
mBRotation = biasFactor * decimal(2.0) * qError.getVectorV();
|
||||
}
|
||||
|
||||
// If the limits are enabled
|
||||
if (mIsLimitEnabled && (mIsLowerLimitViolated || mIsUpperLimitViolated)) {
|
||||
|
||||
// Compute the inverse of the mass matrix K=JM^-1J^t for the limits (1x1 matrix)
|
||||
|
@ -212,6 +213,9 @@ void SliderJoint::initBeforeSolve(const ConstraintSolverData& constraintSolverDa
|
|||
}
|
||||
}
|
||||
|
||||
// If the motor is enabled
|
||||
if (mIsMotorEnabled) {
|
||||
|
||||
// Compute the inverse of mass matrix K=JM^-1J^t for the motor (1x1 matrix)
|
||||
mInverseMassMatrixMotor = 0.0;
|
||||
if (mBody1->isMotionEnabled()) {
|
||||
|
@ -222,6 +226,7 @@ void SliderJoint::initBeforeSolve(const ConstraintSolverData& constraintSolverDa
|
|||
}
|
||||
mInverseMassMatrixMotor = (mInverseMassMatrixMotor > 0.0) ?
|
||||
decimal(1.0) / mInverseMassMatrixMotor : decimal(0.0);
|
||||
}
|
||||
|
||||
// If warm-starting is not enabled
|
||||
if (!constraintSolverData.isWarmStartingActive) {
|
||||
|
|
|
@ -232,7 +232,7 @@ void Profiler::printRecursiveNodeReport(ProfileNodeIterator* iterator,
|
|||
(currentTotalTime / parentTime) * 100.0 : 0.0;
|
||||
for (int j=0; j<spacing; j++) outputStream << " ";
|
||||
outputStream << "| " << i << " -- " << iterator->getCurrentName() << " : " <<
|
||||
fraction << " % | " << (currentTotalTime / long double(nbFrames)) <<
|
||||
fraction << " % | " << (currentTotalTime / (long double) (nbFrames)) <<
|
||||
" ms/frame (" << iterator->getCurrentNbTotalCalls() << " calls)" <<
|
||||
std::endl;
|
||||
totalTime += currentTotalTime;
|
||||
|
|
Loading…
Reference in New Issue
Block a user