mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +02:00
clamp dt for skipTimeForward to prevent near infinite loops
This commit is contained in:
parent
698fcd8116
commit
8fd11e70cc
1 changed files with 4 additions and 1 deletions
|
@ -548,7 +548,10 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
||||||
// is sending us data with a known "last simulated" time. That time is likely in the past, and therefore
|
// is sending us data with a known "last simulated" time. That time is likely in the past, and therefore
|
||||||
// this "new" data is actually slightly out of date. We calculate the time we need to skip forward and
|
// this "new" data is actually slightly out of date. We calculate the time we need to skip forward and
|
||||||
// use our simulation helper routine to get a best estimate of where the entity should be.
|
// use our simulation helper routine to get a best estimate of where the entity should be.
|
||||||
float skipTimeForward = (float)(now - _lastSimulated) / (float)(USECS_PER_SECOND);
|
const float MIN_TIME_SKIP = 0.0f;
|
||||||
|
const float MAX_TIME_SKIP = 1.0f; // in seconds
|
||||||
|
float skipTimeForward = glm::clamp((float)(now - _lastSimulated) / (float)(USECS_PER_SECOND),
|
||||||
|
MIN_TIME_SKIP, MAX_TIME_SKIP);
|
||||||
if (skipTimeForward > 0.0f) {
|
if (skipTimeForward > 0.0f) {
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qDebug() << "skipTimeForward:" << skipTimeForward;
|
qDebug() << "skipTimeForward:" << skipTimeForward;
|
||||||
|
|
Loading…
Reference in a new issue