mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 09:25:31 +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) {
|
||||
linearVelocity = Vectors::ZERO;
|
||||
} else {
|
||||
// position's acceleration term uses deltaVelocity rather than raw gravity
|
||||
// for more accuracy (includes damping effects)
|
||||
position += timeElapsed * (linearVelocity + 0.5f * deltaVelocity);
|
||||
// NOTE: we do NOT include the second-order acceleration term (0.5 * a * dt^2)
|
||||
// when computing the displacement because Bullet also ignores that term. Yes,
|
||||
// this is an approximation and it works best when dt is small.
|
||||
position += timeElapsed * linearVelocity;
|
||||
linearVelocity += deltaVelocity;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -309,6 +309,8 @@ bool EntityMotionState::remoteSimulationOutOfSync(uint32_t simulationStep) {
|
|||
if (glm::length2(_serverVelocity) > 0.0f) {
|
||||
_serverVelocity += _serverAcceleration * 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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue