clamp dt for skipTimeForward to prevent near infinite loops

This commit is contained in:
ZappoMan 2015-02-04 15:16:18 -08:00
parent 698fcd8116
commit 8fd11e70cc

View file

@ -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
// 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.
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) {
#ifdef WANT_DEBUG
qDebug() << "skipTimeForward:" << skipTimeForward;