diff --git a/src/r_data/models/models.cpp b/src/r_data/models/models.cpp index ce41e064d6..a0b76e581c 100644 --- a/src/r_data/models/models.cpp +++ b/src/r_data/models/models.cpp @@ -94,8 +94,8 @@ void FModelRenderer::RenderModel(float x, float y, float z, FSpriteModelFrame *s if (smf->flags & MDL_ROTATING) { - const double time = smf->rotationSpeed*GetTimeFloat() / 200.; - rotateOffset = double((time - xs_FloorToInt(time)) *360.); + double turns = (I_GetTime() % 200 + I_GetTimeFrac()) / 200.0; + rotateOffset = turns * 360.0; } // Added MDL_USEACTORPITCH and MDL_USEACTORROLL flags processing. @@ -164,7 +164,7 @@ void FModelRenderer::RenderModel(float x, float y, float z, FSpriteModelFrame *s objectToWorldMatrix.scale(1, stretch, 1); BeginDrawModel(actor, smf, objectToWorldMatrix); - RenderFrameModels(smf, actor->state, actor->tics, actor->GetClass(), nullptr, translation); + RenderFrameModels(smf, actor->state, actor->tics, actor->GetClass(), translation); EndDrawModel(actor, smf); } @@ -200,16 +200,11 @@ void FModelRenderer::RenderHUDModel(DPSprite *psp, float ofsX, float ofsY) objectToWorldMatrix.rotate(-smf->rolloffset, 1, 0, 0); BeginDrawHUDModel(playermo, objectToWorldMatrix); - RenderFrameModels(smf, psp->GetState(), psp->GetTics(), playermo->player->ReadyWeapon->GetClass(), nullptr, 0); + RenderFrameModels(smf, psp->GetState(), psp->GetTics(), playermo->player->ReadyWeapon->GetClass(), 0); EndDrawHUDModel(playermo); } -void FModelRenderer::RenderFrameModels(const FSpriteModelFrame *smf, - const FState *curState, - const int curTics, - const PClass *ti, - Matrix3x4 *normaltransform, - int translation) +void FModelRenderer::RenderFrameModels(const FSpriteModelFrame *smf, const FState *curState, const int curTics, const PClass *ti, int translation) { // [BB] Frame interpolation: Find the FSpriteModelFrame smfNext which follows after smf in the animation // and the scalar value inter ( element of [0,1) ), both necessary to determine the interpolated frame. @@ -225,14 +220,13 @@ void FModelRenderer::RenderFrameModels(const FSpriteModelFrame *smf, // [BB] In case the tic counter is frozen we have to leave ticFraction at zero. if (ConsoleState == c_up && menuactive != MENU_On && !(level.flags2 & LEVEL2_FROZEN)) { - double time = GetTimeFloat(); - ticFraction = (time - static_cast(time)); + ticFraction = I_GetTimeFrac(); } - inter = static_cast(curState->Tics - curTics - ticFraction) / static_cast(curState->Tics); + inter = static_cast(curState->Tics - curTics + ticFraction) / static_cast(curState->Tics); // [BB] For some actors (e.g. ZPoisonShroom) spr->actor->tics can be bigger than curState->Tics. // In this case inter is negative and we need to set it to zero. - if (inter < 0.) + if (curState->Tics < curTics) inter = 0.; else { @@ -279,11 +273,6 @@ void FModelRenderer::RenderFrameModels(const FSpriteModelFrame *smf, } } -double FModelRenderer::GetTimeFloat() -{ - return (double)I_msTime() * (double)TICRATE / 1000.; -} - ///////////////////////////////////////////////////////////////////////////// void gl_LoadModels() diff --git a/src/r_data/models/models.h b/src/r_data/models/models.h index 91d3d14d61..802f85214f 100644 --- a/src/r_data/models/models.h +++ b/src/r_data/models/models.h @@ -73,8 +73,7 @@ public: virtual void DrawElements(int numIndices, size_t offset) = 0; private: - void RenderFrameModels(const FSpriteModelFrame *smf, const FState *curState, const int curTics, const PClass *ti, Matrix3x4 *normaltransform, int translation); - static double GetTimeFloat(); + void RenderFrameModels(const FSpriteModelFrame *smf, const FState *curState, const int curTics, const PClass *ti, int translation); }; struct FModelVertex