Fix for #1582
This commit is contained in:
@@ -356,7 +356,7 @@ void AllConstraintDemo::initPhysics()
|
|||||||
|
|
||||||
spSlider6Dof->getTranslationalLimitMotor()->m_enableMotor[0] = true;
|
spSlider6Dof->getTranslationalLimitMotor()->m_enableMotor[0] = true;
|
||||||
spSlider6Dof->getTranslationalLimitMotor()->m_targetVelocity[0] = -5.0f;
|
spSlider6Dof->getTranslationalLimitMotor()->m_targetVelocity[0] = -5.0f;
|
||||||
spSlider6Dof->getTranslationalLimitMotor()->m_maxMotorForce[0] = 0.1f;
|
spSlider6Dof->getTranslationalLimitMotor()->m_maxMotorForce[0] = 6.0f;
|
||||||
|
|
||||||
|
|
||||||
m_dynamicsWorld->addConstraint(spSlider6Dof);
|
m_dynamicsWorld->addConstraint(spSlider6Dof);
|
||||||
@@ -431,7 +431,7 @@ void AllConstraintDemo::initPhysics()
|
|||||||
|
|
||||||
// pGen6DOF->getTranslationalLimitMotor()->m_enableMotor[0] = true;
|
// pGen6DOF->getTranslationalLimitMotor()->m_enableMotor[0] = true;
|
||||||
// pGen6DOF->getTranslationalLimitMotor()->m_targetVelocity[0] = 5.0f;
|
// pGen6DOF->getTranslationalLimitMotor()->m_targetVelocity[0] = 5.0f;
|
||||||
// pGen6DOF->getTranslationalLimitMotor()->m_maxMotorForce[0] = 0.1f;
|
// pGen6DOF->getTranslationalLimitMotor()->m_maxMotorForce[0] = 6.0f;
|
||||||
|
|
||||||
|
|
||||||
// pGen6DOF->setAngularLowerLimit(btVector3(0., SIMD_HALF_PI*0.9, 0.));
|
// pGen6DOF->setAngularLowerLimit(btVector3(0., SIMD_HALF_PI*0.9, 0.));
|
||||||
@@ -662,7 +662,7 @@ void AllConstraintDemo::initPhysics()
|
|||||||
|
|
||||||
pGen6Dof->getTranslationalLimitMotor()->m_enableMotor[0] = true;
|
pGen6Dof->getTranslationalLimitMotor()->m_enableMotor[0] = true;
|
||||||
pGen6Dof->getTranslationalLimitMotor()->m_targetVelocity[0] = 5.0f;
|
pGen6Dof->getTranslationalLimitMotor()->m_targetVelocity[0] = 5.0f;
|
||||||
pGen6Dof->getTranslationalLimitMotor()->m_maxMotorForce[0] = 0.1f;
|
pGen6Dof->getTranslationalLimitMotor()->m_maxMotorForce[0] = 6.0f;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -300,11 +300,11 @@ void Dof6Spring2Setup::initPhysics()
|
|||||||
#ifdef USE_6DOF2
|
#ifdef USE_6DOF2
|
||||||
constraint->enableMotor(5,true);
|
constraint->enableMotor(5,true);
|
||||||
constraint->setTargetVelocity(5,3.f);
|
constraint->setTargetVelocity(5,3.f);
|
||||||
constraint->setMaxMotorForce(5,10.f);
|
constraint->setMaxMotorForce(5,600.f);
|
||||||
#else
|
#else
|
||||||
constraint->getRotationalLimitMotor(2)->m_enableMotor = true;
|
constraint->getRotationalLimitMotor(2)->m_enableMotor = true;
|
||||||
constraint->getRotationalLimitMotor(2)->m_targetVelocity = 3.f;
|
constraint->getRotationalLimitMotor(2)->m_targetVelocity = 3.f;
|
||||||
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 10;
|
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 600.f;
|
||||||
#endif
|
#endif
|
||||||
constraint->setDbgDrawSize(btScalar(2.f));
|
constraint->setDbgDrawSize(btScalar(2.f));
|
||||||
m_dynamicsWorld->addConstraint(constraint, true);
|
m_dynamicsWorld->addConstraint(constraint, true);
|
||||||
@@ -335,13 +335,13 @@ void Dof6Spring2Setup::initPhysics()
|
|||||||
#ifdef USE_6DOF2
|
#ifdef USE_6DOF2
|
||||||
constraint->enableMotor(5,true);
|
constraint->enableMotor(5,true);
|
||||||
constraint->setTargetVelocity(5,3.f);
|
constraint->setTargetVelocity(5,3.f);
|
||||||
constraint->setMaxMotorForce(5,10.f);
|
constraint->setMaxMotorForce(5,600.f);
|
||||||
constraint->setServo(5,true);
|
constraint->setServo(5,true);
|
||||||
constraint->setServoTarget(5, M_PI_2);
|
constraint->setServoTarget(5, M_PI_2);
|
||||||
#else
|
#else
|
||||||
constraint->getRotationalLimitMotor(2)->m_enableMotor = true;
|
constraint->getRotationalLimitMotor(2)->m_enableMotor = true;
|
||||||
constraint->getRotationalLimitMotor(2)->m_targetVelocity = 3.f;
|
constraint->getRotationalLimitMotor(2)->m_targetVelocity = 3.f;
|
||||||
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 10;
|
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 600.f;
|
||||||
//servo motor is not implemented in 6dofspring constraint
|
//servo motor is not implemented in 6dofspring constraint
|
||||||
#endif
|
#endif
|
||||||
constraint->setDbgDrawSize(btScalar(2.f));
|
constraint->setDbgDrawSize(btScalar(2.f));
|
||||||
|
|||||||
@@ -4939,9 +4939,7 @@ bool PhysicsServerCommandProcessor::processSendDesiredStateCommand(const struct
|
|||||||
{
|
{
|
||||||
con->enableMotor(3+limitAxis,true);
|
con->enableMotor(3+limitAxis,true);
|
||||||
con->setTargetVelocity(3+limitAxis, qdotTarget);
|
con->setTargetVelocity(3+limitAxis, qdotTarget);
|
||||||
//this is max motor force impulse
|
con->setMaxMotorForce(3+limitAxis, torque);
|
||||||
btScalar torqueImpulse = torque*m_data->m_dynamicsWorld->getSolverInfo().m_timeStep;
|
|
||||||
con->setMaxMotorForce(3+limitAxis,torqueImpulse);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -4954,9 +4952,7 @@ bool PhysicsServerCommandProcessor::processSendDesiredStateCommand(const struct
|
|||||||
//next one is the maximum velocity to reach target position.
|
//next one is the maximum velocity to reach target position.
|
||||||
//the maximum velocity is limited by maxMotorForce
|
//the maximum velocity is limited by maxMotorForce
|
||||||
con->setTargetVelocity(3+limitAxis, 100);
|
con->setTargetVelocity(3+limitAxis, 100);
|
||||||
//this is max motor force impulse
|
con->setMaxMotorForce(3+limitAxis, torque);
|
||||||
btScalar torqueImpulse = torque*m_data->m_dynamicsWorld->getSolverInfo().m_timeStep;
|
|
||||||
con->setMaxMotorForce(3+limitAxis,torqueImpulse);
|
|
||||||
con->enableMotor(3+limitAxis,true);
|
con->enableMotor(3+limitAxis,true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -4992,9 +4988,7 @@ bool PhysicsServerCommandProcessor::processSendDesiredStateCommand(const struct
|
|||||||
{
|
{
|
||||||
con->enableMotor(limitAxis,true);
|
con->enableMotor(limitAxis,true);
|
||||||
con->setTargetVelocity(limitAxis, -qdotTarget);
|
con->setTargetVelocity(limitAxis, -qdotTarget);
|
||||||
//this is max motor force impulse
|
con->setMaxMotorForce(limitAxis, torque);
|
||||||
btScalar torqueImpulse = torque*m_data->m_dynamicsWorld->getSolverInfo().m_timeStep;
|
|
||||||
con->setMaxMotorForce(limitAxis,torqueImpulse);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CONTROL_MODE_POSITION_VELOCITY_PD:
|
case CONTROL_MODE_POSITION_VELOCITY_PD:
|
||||||
@@ -5004,9 +4998,7 @@ bool PhysicsServerCommandProcessor::processSendDesiredStateCommand(const struct
|
|||||||
//next one is the maximum velocity to reach target position.
|
//next one is the maximum velocity to reach target position.
|
||||||
//the maximum velocity is limited by maxMotorForce
|
//the maximum velocity is limited by maxMotorForce
|
||||||
con->setTargetVelocity(limitAxis, 100);
|
con->setTargetVelocity(limitAxis, 100);
|
||||||
//this is max motor force impulse
|
con->setMaxMotorForce(limitAxis, torque);
|
||||||
btScalar torqueImpulse = torque*m_data->m_dynamicsWorld->getSolverInfo().m_timeStep;
|
|
||||||
con->setMaxMotorForce(limitAxis,torqueImpulse);
|
|
||||||
con->enableMotor(limitAxis,true);
|
con->enableMotor(limitAxis,true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -313,11 +313,11 @@ void Dof6ConstraintTutorial::initPhysics()
|
|||||||
#ifdef USE_6DOF2
|
#ifdef USE_6DOF2
|
||||||
constraint->enableMotor(5,true);
|
constraint->enableMotor(5,true);
|
||||||
constraint->setTargetVelocity(5,3.f);
|
constraint->setTargetVelocity(5,3.f);
|
||||||
constraint->setMaxMotorForce(5,10.f);
|
constraint->setMaxMotorForce(5,600.f);
|
||||||
#else
|
#else
|
||||||
constraint->getRotationalLimitMotor(2)->m_enableMotor = true;
|
constraint->getRotationalLimitMotor(2)->m_enableMotor = true;
|
||||||
constraint->getRotationalLimitMotor(2)->m_targetVelocity = 3.f;
|
constraint->getRotationalLimitMotor(2)->m_targetVelocity = 3.f;
|
||||||
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 10;
|
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 600.f;
|
||||||
#endif
|
#endif
|
||||||
constraint->setDbgDrawSize(btScalar(2.f));
|
constraint->setDbgDrawSize(btScalar(2.f));
|
||||||
m_dynamicsWorld->addConstraint(constraint, true);
|
m_dynamicsWorld->addConstraint(constraint, true);
|
||||||
@@ -348,13 +348,13 @@ void Dof6ConstraintTutorial::initPhysics()
|
|||||||
#ifdef USE_6DOF2
|
#ifdef USE_6DOF2
|
||||||
constraint->enableMotor(5,true);
|
constraint->enableMotor(5,true);
|
||||||
constraint->setTargetVelocity(5,3.f);
|
constraint->setTargetVelocity(5,3.f);
|
||||||
constraint->setMaxMotorForce(5,10.f);
|
constraint->setMaxMotorForce(5,600.f);
|
||||||
constraint->setServo(5,true);
|
constraint->setServo(5,true);
|
||||||
constraint->setServoTarget(5, M_PI_2);
|
constraint->setServoTarget(5, M_PI_2);
|
||||||
#else
|
#else
|
||||||
constraint->getRotationalLimitMotor(2)->m_enableMotor = true;
|
constraint->getRotationalLimitMotor(2)->m_enableMotor = true;
|
||||||
constraint->getRotationalLimitMotor(2)->m_targetVelocity = 3.f;
|
constraint->getRotationalLimitMotor(2)->m_targetVelocity = 3.f;
|
||||||
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 10;
|
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 600.f;
|
||||||
//servo motor is not implemented in 6dofspring constraint
|
//servo motor is not implemented in 6dofspring constraint
|
||||||
#endif
|
#endif
|
||||||
constraint->setDbgDrawSize(btScalar(2.f));
|
constraint->setDbgDrawSize(btScalar(2.f));
|
||||||
|
|||||||
@@ -599,8 +599,8 @@ int b3Generic6DofConstraint::get_limit_motor_info2(
|
|||||||
tag_vel,
|
tag_vel,
|
||||||
info->fps * limot->m_stopERP);
|
info->fps * limot->m_stopERP);
|
||||||
info->m_constraintError[srow] += mot_fact * limot->m_targetVelocity;
|
info->m_constraintError[srow] += mot_fact * limot->m_targetVelocity;
|
||||||
info->m_lowerLimit[srow] = -limot->m_maxMotorForce;
|
info->m_lowerLimit[srow] = -limot->m_maxMotorForce / info->fps;
|
||||||
info->m_upperLimit[srow] = limot->m_maxMotorForce;
|
info->m_upperLimit[srow] = limot->m_maxMotorForce / info->fps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(limit)
|
if(limit)
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public:
|
|||||||
{
|
{
|
||||||
m_accumulatedImpulse = 0.f;
|
m_accumulatedImpulse = 0.f;
|
||||||
m_targetVelocity = 0;
|
m_targetVelocity = 0;
|
||||||
m_maxMotorForce = 0.1f;
|
m_maxMotorForce = 6.0f;
|
||||||
m_maxLimitForce = 300.0f;
|
m_maxLimitForce = 300.0f;
|
||||||
m_loLimit = 1.0f;
|
m_loLimit = 1.0f;
|
||||||
m_hiLimit = -1.0f;
|
m_hiLimit = -1.0f;
|
||||||
|
|||||||
@@ -855,8 +855,8 @@ int btGeneric6DofConstraint::get_limit_motor_info2(
|
|||||||
tag_vel,
|
tag_vel,
|
||||||
info->fps * limot->m_stopERP);
|
info->fps * limot->m_stopERP);
|
||||||
info->m_constraintError[srow] += mot_fact * limot->m_targetVelocity;
|
info->m_constraintError[srow] += mot_fact * limot->m_targetVelocity;
|
||||||
info->m_lowerLimit[srow] = -limot->m_maxMotorForce;
|
info->m_lowerLimit[srow] = -limot->m_maxMotorForce / info->fps;
|
||||||
info->m_upperLimit[srow] = limot->m_maxMotorForce;
|
info->m_upperLimit[srow] = limot->m_maxMotorForce / info->fps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(limit)
|
if(limit)
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public:
|
|||||||
{
|
{
|
||||||
m_accumulatedImpulse = 0.f;
|
m_accumulatedImpulse = 0.f;
|
||||||
m_targetVelocity = 0;
|
m_targetVelocity = 0;
|
||||||
m_maxMotorForce = 0.1f;
|
m_maxMotorForce = 6.0f;
|
||||||
m_maxLimitForce = 300.0f;
|
m_maxLimitForce = 300.0f;
|
||||||
m_loLimit = 1.0f;
|
m_loLimit = 1.0f;
|
||||||
m_hiLimit = -1.0f;
|
m_hiLimit = -1.0f;
|
||||||
|
|||||||
@@ -719,8 +719,8 @@ int btGeneric6DofSpring2Constraint::get_limit_motor_info2(
|
|||||||
tag_vel,
|
tag_vel,
|
||||||
info->fps * limot->m_motorERP);
|
info->fps * limot->m_motorERP);
|
||||||
info->m_constraintError[srow] = mot_fact * limot->m_targetVelocity;
|
info->m_constraintError[srow] = mot_fact * limot->m_targetVelocity;
|
||||||
info->m_lowerLimit[srow] = -limot->m_maxMotorForce;
|
info->m_lowerLimit[srow] = -limot->m_maxMotorForce / info->fps;
|
||||||
info->m_upperLimit[srow] = limot->m_maxMotorForce;
|
info->m_upperLimit[srow] = limot->m_maxMotorForce / info->fps;
|
||||||
info->cfm[srow] = limot->m_motorCFM;
|
info->cfm[srow] = limot->m_motorCFM;
|
||||||
srow += info->rowskip;
|
srow += info->rowskip;
|
||||||
++count;
|
++count;
|
||||||
@@ -769,8 +769,8 @@ int btGeneric6DofSpring2Constraint::get_limit_motor_info2(
|
|||||||
mot_fact = 0;
|
mot_fact = 0;
|
||||||
}
|
}
|
||||||
info->m_constraintError[srow] = mot_fact * targetvelocity * (rotational ? -1 : 1);
|
info->m_constraintError[srow] = mot_fact * targetvelocity * (rotational ? -1 : 1);
|
||||||
info->m_lowerLimit[srow] = -limot->m_maxMotorForce;
|
info->m_lowerLimit[srow] = -limot->m_maxMotorForce / info->fps;
|
||||||
info->m_upperLimit[srow] = limot->m_maxMotorForce;
|
info->m_upperLimit[srow] = limot->m_maxMotorForce / info->fps;
|
||||||
info->cfm[srow] = limot->m_motorCFM;
|
info->cfm[srow] = limot->m_motorCFM;
|
||||||
srow += info->rowskip;
|
srow += info->rowskip;
|
||||||
++count;
|
++count;
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public:
|
|||||||
m_motorCFM = 0.f;
|
m_motorCFM = 0.f;
|
||||||
m_enableMotor = false;
|
m_enableMotor = false;
|
||||||
m_targetVelocity = 0;
|
m_targetVelocity = 0;
|
||||||
m_maxMotorForce = 0.1f;
|
m_maxMotorForce = 6.0f;
|
||||||
m_servoMotor = false;
|
m_servoMotor = false;
|
||||||
m_servoTarget = 0;
|
m_servoTarget = 0;
|
||||||
m_enableSpring = false;
|
m_enableSpring = false;
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ void btGeneric6DofSpringConstraint::internalUpdateSprings(btConstraintInfo2* inf
|
|||||||
btScalar force = delta * m_springStiffness[i];
|
btScalar force = delta * m_springStiffness[i];
|
||||||
btScalar velFactor = info->fps * m_springDamping[i] / btScalar(info->m_numIterations);
|
btScalar velFactor = info->fps * m_springDamping[i] / btScalar(info->m_numIterations);
|
||||||
m_linearLimits.m_targetVelocity[i] = velFactor * force;
|
m_linearLimits.m_targetVelocity[i] = velFactor * force;
|
||||||
m_linearLimits.m_maxMotorForce[i] = btFabs(force) / info->fps;
|
m_linearLimits.m_maxMotorForce[i] = btFabs(force);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(i = 0; i < 3; i++)
|
for(i = 0; i < 3; i++)
|
||||||
@@ -146,7 +146,7 @@ void btGeneric6DofSpringConstraint::internalUpdateSprings(btConstraintInfo2* inf
|
|||||||
btScalar force = -delta * m_springStiffness[i+3];
|
btScalar force = -delta * m_springStiffness[i+3];
|
||||||
btScalar velFactor = info->fps * m_springDamping[i+3] / btScalar(info->m_numIterations);
|
btScalar velFactor = info->fps * m_springDamping[i+3] / btScalar(info->m_numIterations);
|
||||||
m_angularLimits[i].m_targetVelocity = velFactor * force;
|
m_angularLimits[i].m_targetVelocity = velFactor * force;
|
||||||
m_angularLimits[i].m_maxMotorForce = btFabs(force) / info->fps;
|
m_angularLimits[i].m_maxMotorForce = btFabs(force);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user