Fix issue with linear/angular damping
This commit is contained in:
parent
b15d46a95f
commit
63fb6261a3
|
@ -339,7 +339,8 @@ inline decimal RigidBody::getLinearDamping() const {
|
||||||
return mLinearDamping;
|
return mLinearDamping;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the linear damping factor
|
// Set the linear damping factor. This is the ratio of the linear velocity
|
||||||
|
// that the body will lose every at seconds of simulation.
|
||||||
/**
|
/**
|
||||||
* @param linearDamping The linear damping factor of this body
|
* @param linearDamping The linear damping factor of this body
|
||||||
*/
|
*/
|
||||||
|
@ -356,7 +357,8 @@ inline decimal RigidBody::getAngularDamping() const {
|
||||||
return mAngularDamping;
|
return mAngularDamping;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the angular damping factor
|
// Set the angular damping factor. This is the ratio of the angular velocity
|
||||||
|
// that the body will lose at every seconds of simulation.
|
||||||
/**
|
/**
|
||||||
* @param angularDamping The angular damping factor of this body
|
* @param angularDamping The angular damping factor of this body
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -338,14 +338,10 @@ void DynamicsWorld::integrateRigidBodiesVelocities() {
|
||||||
// => v2 = v1 * (1 - c * dt)
|
// => v2 = v1 * (1 - c * dt)
|
||||||
decimal linDampingFactor = bodies[b]->getLinearDamping();
|
decimal linDampingFactor = bodies[b]->getLinearDamping();
|
||||||
decimal angDampingFactor = bodies[b]->getAngularDamping();
|
decimal angDampingFactor = bodies[b]->getAngularDamping();
|
||||||
decimal linearDamping = clamp(decimal(1.0) - mTimeStep * linDampingFactor,
|
decimal linearDamping = pow(decimal(1.0) - linDampingFactor, mTimeStep);
|
||||||
decimal(0.0), decimal(1.0));
|
decimal angularDamping = pow(decimal(1.0) - angDampingFactor, mTimeStep);
|
||||||
decimal angularDamping = clamp(decimal(1.0) - mTimeStep * angDampingFactor,
|
mConstrainedLinearVelocities[indexBody] *= linearDamping;
|
||||||
decimal(0.0), decimal(1.0));
|
mConstrainedAngularVelocities[indexBody] *= angularDamping;
|
||||||
mConstrainedLinearVelocities[indexBody] *= clamp(linearDamping, decimal(0.0),
|
|
||||||
decimal(1.0));
|
|
||||||
mConstrainedAngularVelocities[indexBody] *= clamp(angularDamping, decimal(0.0),
|
|
||||||
decimal(1.0));
|
|
||||||
|
|
||||||
indexBody++;
|
indexBody++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user