mirror of
https://github.com/lubosz/overte.git
synced 2025-08-16 08:13:40 +02:00
remove second-order term from kinematic motion
This commit is contained in:
parent
8cbec06616
commit
ad045bc439
2 changed files with 6 additions and 3 deletions
|
@ -947,9 +947,10 @@ bool EntityItem::stepKinematicMotion(float timeElapsed) {
|
||||||
&& glm::length2(linearVelocity) < MIN_KINEMATIC_LINEAR_SPEED_SQUARED) {
|
&& glm::length2(linearVelocity) < MIN_KINEMATIC_LINEAR_SPEED_SQUARED) {
|
||||||
linearVelocity = Vectors::ZERO;
|
linearVelocity = Vectors::ZERO;
|
||||||
} else {
|
} else {
|
||||||
// position's acceleration term uses deltaVelocity rather than raw gravity
|
// NOTE: we do NOT include the second-order acceleration term (0.5 * a * dt^2)
|
||||||
// for more accuracy (includes damping effects)
|
// when computing the displacement because Bullet also ignores that term. Yes,
|
||||||
position += timeElapsed * (linearVelocity + 0.5f * deltaVelocity);
|
// this is an approximation and it works best when dt is small.
|
||||||
|
position += timeElapsed * linearVelocity;
|
||||||
linearVelocity += deltaVelocity;
|
linearVelocity += deltaVelocity;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -309,6 +309,8 @@ bool EntityMotionState::remoteSimulationOutOfSync(uint32_t simulationStep) {
|
||||||
if (glm::length2(_serverVelocity) > 0.0f) {
|
if (glm::length2(_serverVelocity) > 0.0f) {
|
||||||
_serverVelocity += _serverAcceleration * dt;
|
_serverVelocity += _serverAcceleration * dt;
|
||||||
_serverVelocity *= powf(1.0f - _body->getLinearDamping(), dt);
|
_serverVelocity *= powf(1.0f - _body->getLinearDamping(), dt);
|
||||||
|
// NOTE: we ignore the second-order acceleration term when integrating
|
||||||
|
// the position forward because Bullet also does this.
|
||||||
_serverPosition += dt * _serverVelocity;
|
_serverPosition += dt * _serverVelocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue