- fixed: Interpolations were deleted too early.

They were immediately deleted when the associated thinker was destroyed. But this was too early because it missed the final tic of movement, resulting in a visible jump when a moving platform with a player on it came to a halt.
Changed it so that DelRef no longer destroys the interpolation itself. Instead the ::Interpolate method will check if the reference count is 0, and if so and there was no more movement, will then destroy the interpolation.
This ensures that it keeps running until it has interpolated all remaining bits of movement induced by the thinker.

Now moving up a lift is 100% smooth, even with movement interpolation on.
This commit is contained in:
Christoph Oelckers 2016-01-21 11:58:44 +01:00
parent d347415aee
commit cf2ee1eb3f
2 changed files with 49 additions and 19 deletions

View file

@ -344,10 +344,6 @@ int DInterpolation::AddRef()
int DInterpolation::DelRef()
{
if (refcount > 0) --refcount;
if (refcount <= 0 && !(ObjectFlags & OF_EuthanizeMe))
{
Destroy();
}
return refcount;
}
@ -496,10 +492,17 @@ void DSectorPlaneInterpolation::Interpolate(fixed_t smoothratio)
bakheight = *pheight;
baktexz = sector->GetPlaneTexZ(pos);
if (refcount == 0 && oldheight == bakheight)
{
Destroy();
}
else
{
*pheight = oldheight + FixedMul(bakheight - oldheight, smoothratio);
sector->SetPlaneTexZ(pos, oldtexz + FixedMul(baktexz - oldtexz, smoothratio));
P_RecalculateAttached3DFloors(sector);
}
}
//==========================================================================
//
@ -622,9 +625,16 @@ void DSectorScrollInterpolation::Interpolate(fixed_t smoothratio)
bakx = sector->GetXOffset(ceiling);
baky = sector->GetYOffset(ceiling, false);
if (refcount == 0 && oldx == bakx && oldy == baky)
{
Destroy();
}
else
{
sector->SetXOffset(ceiling, oldx + FixedMul(bakx - oldx, smoothratio));
sector->SetYOffset(ceiling, oldy + FixedMul(baky - oldy, smoothratio));
}
}
//==========================================================================
//
@ -706,9 +716,16 @@ void DWallScrollInterpolation::Interpolate(fixed_t smoothratio)
bakx = side->GetTextureXOffset(part);
baky = side->GetTextureYOffset(part);
if (refcount == 0 && oldx == bakx && oldy == baky)
{
Destroy();
}
else
{
side->SetTextureXOffset(part, oldx + FixedMul(bakx - oldx, smoothratio));
side->SetTextureYOffset(part, oldy + FixedMul(baky - oldy, smoothratio));
}
}
//==========================================================================
//
@ -798,6 +815,7 @@ void DPolyobjInterpolation::Restore()
void DPolyobjInterpolation::Interpolate(fixed_t smoothratio)
{
bool changed = false;
for(unsigned int i = 0; i < poly->Vertices.Size(); i++)
{
fixed_t *px = &poly->Vertices[i]->x;
@ -806,9 +824,19 @@ void DPolyobjInterpolation::Interpolate(fixed_t smoothratio)
bakverts[i*2 ] = *px;
bakverts[i*2+1] = *py;
if (bakverts[i * 2] != oldverts[i * 2] || bakverts[i * 2 + i] != oldverts[i * 2 + 1])
{
changed = true;
*px = oldverts[i * 2] + FixedMul(bakverts[i * 2] - oldverts[i * 2], smoothratio);
*py = oldverts[i * 2 + 1] + FixedMul(bakverts[i * 2 + 1] - oldverts[i * 2 + 1], smoothratio);
}
}
if (refcount == 0 && !changed)
{
Destroy();
}
else
{
bakcx = poly->CenterSpot.x;
bakcy = poly->CenterSpot.y;
poly->CenterSpot.x = bakcx + FixedMul(bakcx - oldcx, smoothratio);
@ -816,6 +844,7 @@ void DPolyobjInterpolation::Interpolate(fixed_t smoothratio)
poly->ClearSubsectorLinks();
}
}
//==========================================================================
//

View file

@ -17,9 +17,10 @@ class DInterpolation : public DObject
TObjPtr<DInterpolation> Next;
TObjPtr<DInterpolation> Prev;
int refcount;
protected:
int refcount;
DInterpolation();
public: