From 847a3a1f9e1fc914e45a5900fbcbedadb17097d7 Mon Sep 17 00:00:00 2001 From: danij Date: Wed, 11 Sep 2013 18:41:52 +0100 Subject: [PATCH] World|Plane|Client: Continuously interpolate plane movement It would seem the plane height delta must be continuously updated to ensure smooth movement. Naturally this means that change notification will run a little behind the actual interpolation. --- doomsday/client/src/world/plane.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/doomsday/client/src/world/plane.cpp b/doomsday/client/src/world/plane.cpp index 99899fe147..3518473dbc 100644 --- a/doomsday/client/src/world/plane.cpp +++ b/doomsday/client/src/world/plane.cpp @@ -226,39 +226,39 @@ coord_t Plane::heightSmoothedDelta() const void Plane::lerpSmoothedHeight() { - coord_t newSmoothedHeight = d->height + d->heightSmoothedDelta; - if(!de::fequal(d->heightSmoothed, newSmoothedHeight)) + // Interpolate. + d->heightSmoothedDelta = d->oldHeight[0] * (1 - frameTimePos) + + d->height * frameTimePos - d->height; + + coord_t newHeightSmoothed = d->height + d->heightSmoothedDelta; + if(!de::fequal(d->heightSmoothed, newHeightSmoothed)) { coord_t oldHeightSmoothed = d->heightSmoothed; - - d->heightSmoothed = newSmoothedHeight; - d->heightSmoothedDelta = d->oldHeight[0] * (1 - frameTimePos) + d->height * frameTimePos - d->height; - + d->heightSmoothed = newHeightSmoothed; d->notifySmoothedHeightChanged(oldHeightSmoothed); } } void Plane::resetSmoothedHeight() { - coord_t newSmoothedHeight = d->oldHeight[0] = d->oldHeight[1] = d->height; - if(!de::fequal(d->heightSmoothed, newSmoothedHeight)) + // Reset interpolation. + d->heightSmoothedDelta = 0; + + coord_t newHeightSmoothed = d->oldHeight[0] = d->oldHeight[1] = d->height; + if(!de::fequal(d->heightSmoothed, newHeightSmoothed)) { coord_t oldHeightSmoothed = d->heightSmoothed; - - d->heightSmoothed = newSmoothedHeight; - d->heightSmoothedDelta = 0; - + d->heightSmoothed = newHeightSmoothed; d->notifySmoothedHeightChanged(oldHeightSmoothed); } } void Plane::updateHeightTracking() { - // $smoothplane d->oldHeight[0] = d->oldHeight[1]; d->oldHeight[1] = d->height; - if(d->oldHeight[0] != d->oldHeight[1]) + if(!de::fequal(d->oldHeight[0], d->oldHeight[1])) { if(de::abs(d->oldHeight[0] - d->oldHeight[1]) >= MAX_SMOOTH_MOVE) {