Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
danij-deng committed Sep 11, 2013
1 parent e41bdaf commit 847a3a1
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions doomsday/client/src/world/plane.cpp
Expand Up @@ -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)
{
Expand Down

0 comments on commit 847a3a1

Please sign in to comment.