From d54a2364b9bcef99359705cfd29f5eb460ec0ec6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 30 Mar 2016 17:11:31 +0200 Subject: [PATCH] - floatified r_interpolate.cpp. --- src/r_data/r_interpolate.cpp | 78 ++++++++++++++++++------------------ src/r_data/r_interpolate.h | 4 +- src/r_utility.cpp | 11 ++--- src/r_utility.h | 1 - 4 files changed, 45 insertions(+), 49 deletions(-) diff --git a/src/r_data/r_interpolate.cpp b/src/r_data/r_interpolate.cpp index 284673e4b8..535173e307 100644 --- a/src/r_data/r_interpolate.cpp +++ b/src/r_data/r_interpolate.cpp @@ -52,8 +52,8 @@ class DSectorPlaneInterpolation : public DInterpolation DECLARE_CLASS(DSectorPlaneInterpolation, DInterpolation) sector_t *sector; - fixed_t oldheight, oldtexz; - fixed_t bakheight, baktexz; + double oldheight, oldtexz; + double bakheight, baktexz; bool ceiling; TArray attached; @@ -65,7 +65,7 @@ public: void Destroy(); void UpdateInterpolation(); void Restore(); - void Interpolate(fixed_t smoothratio); + void Interpolate(double smoothratio); void Serialize(FArchive &arc); size_t PointerSubstitution (DObject *old, DObject *notOld); size_t PropagateMark(); @@ -82,8 +82,8 @@ class DSectorScrollInterpolation : public DInterpolation DECLARE_CLASS(DSectorScrollInterpolation, DInterpolation) sector_t *sector; - fixed_t oldx, oldy; - fixed_t bakx, baky; + double oldx, oldy; + double bakx, baky; bool ceiling; public: @@ -93,7 +93,7 @@ public: void Destroy(); void UpdateInterpolation(); void Restore(); - void Interpolate(fixed_t smoothratio); + void Interpolate(double smoothratio); void Serialize(FArchive &arc); }; @@ -110,8 +110,8 @@ class DWallScrollInterpolation : public DInterpolation side_t *side; int part; - fixed_t oldx, oldy; - fixed_t bakx, baky; + double oldx, oldy; + double bakx, baky; public: @@ -120,7 +120,7 @@ public: void Destroy(); void UpdateInterpolation(); void Restore(); - void Interpolate(fixed_t smoothratio); + void Interpolate(double smoothratio); void Serialize(FArchive &arc); }; @@ -135,9 +135,9 @@ class DPolyobjInterpolation : public DInterpolation DECLARE_CLASS(DPolyobjInterpolation, DInterpolation) FPolyObj *poly; - TArray oldverts, bakverts; - fixed_t oldcx, oldcy; - fixed_t bakcx, bakcy; + TArray oldverts, bakverts; + double oldcx, oldcy; + double bakcx, bakcy; public: @@ -146,7 +146,7 @@ public: void Destroy(); void UpdateInterpolation(); void Restore(); - void Interpolate(fixed_t smoothratio); + void Interpolate(double smoothratio); void Serialize(FArchive &arc); }; @@ -251,9 +251,9 @@ void FInterpolator::RemoveInterpolation(DInterpolation *interp) // //========================================================================== -void FInterpolator::DoInterpolations(fixed_t smoothratio) +void FInterpolator::DoInterpolations(double smoothratio) { - if (smoothratio == FRACUNIT) + if (smoothratio >= 1.) { didInterp = false; return; @@ -440,13 +440,13 @@ void DSectorPlaneInterpolation::UpdateInterpolation() { if (!ceiling) { - oldheight = sector->floorplane.fixD(); - oldtexz = sector->GetPlaneTexZ(sector_t::floor); + oldheight = sector->floorplane.fD(); + oldtexz = sector->GetPlaneTexZF(sector_t::floor); } else { - oldheight = sector->ceilingplane.fixD(); - oldtexz = sector->GetPlaneTexZ(sector_t::ceiling); + oldheight = sector->ceilingplane.fD(); + oldtexz = sector->GetPlaneTexZF(sector_t::ceiling); } } @@ -478,7 +478,7 @@ void DSectorPlaneInterpolation::Restore() // //========================================================================== -void DSectorPlaneInterpolation::Interpolate(fixed_t smoothratio) +void DSectorPlaneInterpolation::Interpolate(double smoothratio) { secplane_t *pplane; int pos; @@ -503,8 +503,8 @@ void DSectorPlaneInterpolation::Interpolate(fixed_t smoothratio) } else { - pplane->setD(oldheight + FixedMul(bakheight - oldheight, smoothratio)); - sector->SetPlaneTexZ(pos, oldtexz + FixedMul(baktexz - oldtexz, smoothratio)); + pplane->setD(oldheight + (bakheight - oldheight) * smoothratio); + sector->SetPlaneTexZ(pos, oldtexz + (baktexz - oldtexz) * smoothratio); P_RecalculateAttached3DFloors(sector); sector->CheckPortalPlane(pos); } @@ -604,8 +604,8 @@ void DSectorScrollInterpolation::Destroy() void DSectorScrollInterpolation::UpdateInterpolation() { - oldx = sector->GetXOffset(ceiling); - oldy = sector->GetYOffset(ceiling, false); + oldx = sector->GetXOffsetF(ceiling); + oldy = sector->GetYOffsetF(ceiling, false); } //========================================================================== @@ -626,7 +626,7 @@ void DSectorScrollInterpolation::Restore() // //========================================================================== -void DSectorScrollInterpolation::Interpolate(fixed_t smoothratio) +void DSectorScrollInterpolation::Interpolate(double smoothratio) { bakx = sector->GetXOffset(ceiling); baky = sector->GetYOffset(ceiling, false); @@ -637,8 +637,8 @@ void DSectorScrollInterpolation::Interpolate(fixed_t smoothratio) } else { - sector->SetXOffset(ceiling, oldx + FixedMul(bakx - oldx, smoothratio)); - sector->SetYOffset(ceiling, oldy + FixedMul(baky - oldy, smoothratio)); + sector->SetXOffset(ceiling, oldx + (bakx - oldx) * smoothratio); + sector->SetYOffset(ceiling, oldy + (baky - oldy) * smoothratio); } } @@ -695,8 +695,8 @@ void DWallScrollInterpolation::Destroy() void DWallScrollInterpolation::UpdateInterpolation() { - oldx = side->GetTextureXOffset(part); - oldy = side->GetTextureYOffset(part); + oldx = side->GetTextureXOffsetF(part); + oldy = side->GetTextureYOffsetF(part); } //========================================================================== @@ -717,7 +717,7 @@ void DWallScrollInterpolation::Restore() // //========================================================================== -void DWallScrollInterpolation::Interpolate(fixed_t smoothratio) +void DWallScrollInterpolation::Interpolate(double smoothratio) { bakx = side->GetTextureXOffset(part); baky = side->GetTextureYOffset(part); @@ -728,8 +728,8 @@ void DWallScrollInterpolation::Interpolate(fixed_t smoothratio) } else { - side->SetTextureXOffset(part, oldx + FixedMul(bakx - oldx, smoothratio)); - side->SetTextureYOffset(part, oldy + FixedMul(baky - oldy, smoothratio)); + side->SetTextureXOffset(part, oldx + (bakx - oldx) * smoothratio); + side->SetTextureYOffset(part, oldy + (baky - oldy) * smoothratio); } } @@ -788,8 +788,8 @@ void DPolyobjInterpolation::UpdateInterpolation() { for(unsigned int i = 0; i < poly->Vertices.Size(); i++) { - oldverts[i*2 ] = poly->Vertices[i]->fixX(); - oldverts[i*2+1] = poly->Vertices[i]->fixY(); + oldverts[i*2 ] = poly->Vertices[i]->fX(); + oldverts[i*2+1] = poly->Vertices[i]->fY(); } oldcx = poly->CenterSpot.x; oldcy = poly->CenterSpot.y; @@ -818,7 +818,7 @@ void DPolyobjInterpolation::Restore() // //========================================================================== -void DPolyobjInterpolation::Interpolate(fixed_t smoothratio) +void DPolyobjInterpolation::Interpolate(double smoothratio) { bool changed = false; for(unsigned int i = 0; i < poly->Vertices.Size(); i++) @@ -830,8 +830,8 @@ void DPolyobjInterpolation::Interpolate(fixed_t smoothratio) { changed = true; poly->Vertices[i]->set( - oldverts[i * 2] + FixedMul(bakverts[i * 2] - oldverts[i * 2], smoothratio), - oldverts[i * 2 + 1] + FixedMul(bakverts[i * 2 + 1] - oldverts[i * 2 + 1], smoothratio)); + oldverts[i * 2] + (bakverts[i * 2] - oldverts[i * 2]) * smoothratio, + oldverts[i * 2 + 1] + (bakverts[i * 2 + 1] - oldverts[i * 2 + 1]) * smoothratio); } } if (refcount == 0 && !changed) @@ -842,8 +842,8 @@ void DPolyobjInterpolation::Interpolate(fixed_t smoothratio) { bakcx = poly->CenterSpot.x; bakcy = poly->CenterSpot.y; - poly->CenterSpot.x = bakcx + FixedMul(bakcx - oldcx, smoothratio); - poly->CenterSpot.y = bakcy + FixedMul(bakcy - oldcy, smoothratio); + poly->CenterSpot.x = bakcx + (bakcx - oldcx) * smoothratio; + poly->CenterSpot.y = bakcy + (bakcy - oldcy) * smoothratio; poly->ClearSubsectorLinks(); } diff --git a/src/r_data/r_interpolate.h b/src/r_data/r_interpolate.h index 4da89451c4..e49500e571 100644 --- a/src/r_data/r_interpolate.h +++ b/src/r_data/r_interpolate.h @@ -30,7 +30,7 @@ public: virtual void Destroy(); virtual void UpdateInterpolation() = 0; virtual void Restore() = 0; - virtual void Interpolate(fixed_t smoothratio) = 0; + virtual void Interpolate(double smoothratio) = 0; virtual void Serialize(FArchive &arc); }; @@ -58,7 +58,7 @@ public: void UpdateInterpolations(); void AddInterpolation(DInterpolation *); void RemoveInterpolation(DInterpolation *); - void DoInterpolations(fixed_t smoothratio); + void DoInterpolations(double smoothratio); void RestoreInterpolations(); void ClearInterpolations(); }; diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 8d0ac1fbe0..4fd9a1ca40 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -125,7 +125,6 @@ fixed_t viewsin, viewtansin; AActor *camera; // [RH] camera to draw from. doesn't have to be a player -fixed_t r_TicFrac; // [RH] Fractional tic to render double r_TicFracF; // same as floating point DWORD r_FrameTime; // [RH] Time this frame started drawing (in ms) bool r_NoInterpolate; @@ -572,9 +571,9 @@ static void R_Shutdown () //CVAR (Int, tf, 0, 0) EXTERN_CVAR (Bool, cl_noprediction) -void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *iview) +void R_InterpolateView (player_t *player, double Frac, InterpolationViewer *iview) { -// frac = tf; + fixed_t frac = FLOAT2FIXED(Frac); if (NoInterpolateView) { InterpolationPath.Clear(); @@ -1012,9 +1011,7 @@ void R_SetupFrame (AActor *actor) { r_TicFracF = 1.; } - r_TicFrac = FLOAT2FIXED(r_TicFracF); - - R_InterpolateView (player, r_TicFrac, iview); + R_InterpolateView (player, r_TicFracF, iview); #ifdef TEST_X viewx = TEST_X; @@ -1025,7 +1022,7 @@ void R_SetupFrame (AActor *actor) R_SetViewAngle (); - interpolator.DoInterpolations (r_TicFrac); + interpolator.DoInterpolations (r_TicFracF); // Keep the view within the sector's floor and ceiling if (viewsector->PortalBlocksMovement(sector_t::ceiling)) diff --git a/src/r_utility.h b/src/r_utility.h index ff7d552af8..b3cfb10ad1 100644 --- a/src/r_utility.h +++ b/src/r_utility.h @@ -33,7 +33,6 @@ extern int LocalViewPitch; // [RH] Used directly instead of consoleplayer's extern bool LocalKeyboardTurner; // [RH] The local player used the keyboard to turn, so interpolate extern int WidescreenRatio; -extern fixed_t r_TicFrac; extern double r_TicFracF; extern DWORD r_FrameTime; extern int extralight;