Bug in the sign of linear motor force for btSliderConstraint fixed
This commit is contained in:
@@ -344,7 +344,8 @@ void btSliderConstraint::getInfo2(btConstraintInfo2* info)
|
||||
info->cfm[nrow] = btScalar(0.0);
|
||||
btScalar tag_vel = getTargetLinMotorVelocity();
|
||||
btScalar mot_fact = getMotorFactor(m_linPos, m_lowerLinLimit, m_upperLinLimit, tag_vel, info->fps * info->erp);
|
||||
info->m_constraintError[srow] += mot_fact * getTargetLinMotorVelocity();
|
||||
// info->m_constraintError[srow] += mot_fact * getTargetLinMotorVelocity();
|
||||
info->m_constraintError[srow] -= signFact * mot_fact * getTargetLinMotorVelocity();
|
||||
info->m_lowerLimit[srow] += -getMaxLinMotorForce() * info->fps;
|
||||
info->m_upperLimit[srow] += getMaxLinMotorForce() * info->fps;
|
||||
}
|
||||
|
||||
@@ -69,11 +69,11 @@ btScalar btTypedConstraint::getMotorFactor(btScalar pos, btScalar lowLim, btScal
|
||||
}
|
||||
btScalar lim_fact = btScalar(1.0f);
|
||||
btScalar delta_max = vel / timeFact;
|
||||
if(delta_max > btScalar(0.0f))
|
||||
if(delta_max < btScalar(0.0f))
|
||||
{
|
||||
if((pos > lowLim) && (pos < (lowLim + delta_max)))
|
||||
if((pos >= lowLim) && (pos < (lowLim - delta_max)))
|
||||
{
|
||||
lim_fact = (pos - lowLim) / delta_max;
|
||||
lim_fact = (lowLim - pos) / delta_max;
|
||||
}
|
||||
else if(pos < lowLim)
|
||||
{
|
||||
@@ -84,11 +84,11 @@ btScalar btTypedConstraint::getMotorFactor(btScalar pos, btScalar lowLim, btScal
|
||||
lim_fact = btScalar(1.0f);
|
||||
}
|
||||
}
|
||||
else if(delta_max < btScalar(0.0f))
|
||||
else if(delta_max > btScalar(0.0f))
|
||||
{
|
||||
if((pos < uppLim) && (pos > (uppLim + delta_max)))
|
||||
if((pos <= uppLim) && (pos > (uppLim - delta_max)))
|
||||
{
|
||||
lim_fact = (pos - uppLim) / delta_max;
|
||||
lim_fact = (uppLim - pos) / delta_max;
|
||||
}
|
||||
else if(pos > uppLim)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user