diff --git a/src/r_data/models/models.cpp b/src/r_data/models/models.cpp index 756fdfa95a..446a5840b1 100644 --- a/src/r_data/models/models.cpp +++ b/src/r_data/models/models.cpp @@ -57,7 +57,10 @@ extern TDeletingArray VoxelDefs; TDeletingArray Models; -void FModelRenderer::RenderModel(float x, float y, float z, FSpriteModelFrame *smf, AActor *actor, double ticFrac) +void RenderFrameModels(FModelRenderer* renderer, FLevelLocals* Level, const FSpriteModelFrame* smf, const FState* curState, const int curTics, const PClass* ti, int translation); + + +void RenderModel(FModelRenderer *renderer, float x, float y, float z, FSpriteModelFrame *smf, AActor *actor, double ticFrac) { // Setup transformation. @@ -174,12 +177,12 @@ void FModelRenderer::RenderModel(float x, float y, float z, FSpriteModelFrame *s float orientation = scaleFactorX * scaleFactorY * scaleFactorZ; - BeginDrawModel(actor->RenderStyle, smf, objectToWorldMatrix, orientation < 0); - RenderFrameModels(actor->Level, smf, actor->state, actor->tics, actor->GetClass(), translation); - EndDrawModel(actor->RenderStyle, smf); + renderer->BeginDrawModel(actor->RenderStyle, smf, objectToWorldMatrix, orientation < 0); + RenderFrameModels(renderer, actor->Level, smf, actor->state, actor->tics, actor->GetClass(), translation); + renderer->EndDrawModel(actor->RenderStyle, smf); } -void FModelRenderer::RenderHUDModel(DPSprite *psp, float ofsX, float ofsY) +void RenderHUDModel(FModelRenderer *renderer, DPSprite *psp, float ofsX, float ofsY) { AActor * playermo = players[consoleplayer].camera; FSpriteModelFrame *smf = FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetSprite(), psp->GetFrame(), false); @@ -190,7 +193,7 @@ void FModelRenderer::RenderHUDModel(DPSprite *psp, float ofsX, float ofsY) // The model position and orientation has to be drawn independently from the position of the player, // but we need to position it correctly in the world for light to work properly. - VSMatrix objectToWorldMatrix = GetViewToWorldMatrix(); + VSMatrix objectToWorldMatrix = renderer->GetViewToWorldMatrix(); // Scaling model (y scale for a sprite means height, i.e. z in the world!). objectToWorldMatrix.scale(smf->xscale, smf->zscale, smf->yscale); @@ -212,12 +215,12 @@ void FModelRenderer::RenderHUDModel(DPSprite *psp, float ofsX, float ofsY) float orientation = smf->xscale * smf->yscale * smf->zscale; - BeginDrawHUDModel(playermo->RenderStyle, objectToWorldMatrix, orientation < 0); - RenderFrameModels(playermo->Level, smf, psp->GetState(), psp->GetTics(), playermo->player->ReadyWeapon->GetClass(), psp->Flags & PSPF_PLAYERTRANSLATED ? psp->Owner->mo->Translation : 0); - EndDrawHUDModel(playermo->RenderStyle); + renderer->BeginDrawHUDModel(playermo->RenderStyle, objectToWorldMatrix, orientation < 0); + RenderFrameModels(renderer, playermo->Level, smf, psp->GetState(), psp->GetTics(), playermo->player->ReadyWeapon->GetClass(), psp->Flags & PSPF_PLAYERTRANSLATED ? psp->Owner->mo->Translation : 0); + renderer->EndDrawHUDModel(playermo->RenderStyle); } -void FModelRenderer::RenderFrameModels(FLevelLocals *Level, const FSpriteModelFrame *smf, const FState *curState, const int curTics, const PClass *ti, int translation) +void RenderFrameModels(FModelRenderer *renderer, FLevelLocals *Level, 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. @@ -271,14 +274,14 @@ void FModelRenderer::RenderFrameModels(FLevelLocals *Level, const FSpriteModelFr { FModel * mdl = Models[smf->modelIDs[i]]; auto tex = smf->skinIDs[i].isValid() ? TexMan.GetGameTexture(smf->skinIDs[i], true) : nullptr; - mdl->BuildVertexBuffer(this); + mdl->BuildVertexBuffer(renderer); mdl->PushSpriteMDLFrame(smf, i); if (smfNext && smf->modelframes[i] != smfNext->modelframes[i]) - mdl->RenderFrame(this, tex, smf->modelframes[i], smfNext->modelframes[i], inter, translation); + mdl->RenderFrame(renderer, tex, smf->modelframes[i], smfNext->modelframes[i], inter, translation); else - mdl->RenderFrame(this, tex, smf->modelframes[i], smf->modelframes[i], 0.f, translation); + mdl->RenderFrame(renderer, tex, smf->modelframes[i], smf->modelframes[i], 0.f, translation); } } } diff --git a/src/r_data/models/models.h b/src/r_data/models/models.h index 2ab61ee579..ad36f7190a 100644 --- a/src/r_data/models/models.h +++ b/src/r_data/models/models.h @@ -441,4 +441,7 @@ void BSPWalkCircle(FLevelLocals *Level, float x, float y, float radiusSquared, c BSPNodeWalkCircle(Level->HeadNode(), x, y, radiusSquared, callback); } +void RenderModel(FModelRenderer* renderer, float x, float y, float z, FSpriteModelFrame* smf, AActor* actor, double ticFrac); +void RenderHUDModel(FModelRenderer* renderer, DPSprite* psp, float ofsX, float ofsY); + #endif diff --git a/src/rendering/hwrenderer/scene/hw_sprites.cpp b/src/rendering/hwrenderer/scene/hw_sprites.cpp index 93e56cca38..c0dd3bd1ef 100644 --- a/src/rendering/hwrenderer/scene/hw_sprites.cpp +++ b/src/rendering/hwrenderer/scene/hw_sprites.cpp @@ -293,7 +293,7 @@ void HWSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent) else { FHWModelRenderer renderer(di, state, dynlightindex); - renderer.RenderModel(x, y, z, modelframe, actor, di->Viewpoint.TicFrac); + RenderModel(&renderer, x, y, z, modelframe, actor, di->Viewpoint.TicFrac); state.SetVertexBuffer(screen->mVertexData); } } diff --git a/src/rendering/hwrenderer/scene/hw_weapon.cpp b/src/rendering/hwrenderer/scene/hw_weapon.cpp index acca62c9a2..20ac4848b9 100644 --- a/src/rendering/hwrenderer/scene/hw_weapon.cpp +++ b/src/rendering/hwrenderer/scene/hw_weapon.cpp @@ -89,7 +89,7 @@ void HWDrawInfo::DrawPSprite(HUDSprite *huds, FRenderState &state) state.AlphaFunc(Alpha_GEqual, 0); FHWModelRenderer renderer(this, state, huds->lightindex); - renderer.RenderHUDModel(huds->weapon, huds->mx, huds->my); + RenderHUDModel(&renderer, huds->weapon, huds->mx, huds->my); state.SetVertexBuffer(screen->mVertexData); } else diff --git a/src/rendering/swrenderer/things/r_model.cpp b/src/rendering/swrenderer/things/r_model.cpp index 60f8a9865c..ec7a5273cc 100644 --- a/src/rendering/swrenderer/things/r_model.cpp +++ b/src/rendering/swrenderer/things/r_model.cpp @@ -94,7 +94,7 @@ namespace swrenderer renderer.Translation = actor->Translation; renderer.AddLights(actor); - renderer.RenderModel(x, y, z, smf, actor, r_viewpoint.TicFrac); + RenderModel(&renderer, x, y, z, smf, actor, r_viewpoint.TicFrac); PolyTriangleDrawer::SetModelVertexShader(thread->DrawQueue, -1, -1, 0.0f); #endif } @@ -143,7 +143,7 @@ namespace swrenderer renderer.fillcolor = fullbrightSprite ? ThingColor : ThingColor.Modulate(playermo->Sector->SpecialColors[sector_t::sprites]); renderer.Translation = 0xffffffff;// playermo->Translation; - renderer.RenderHUDModel(psp, ofsx, ofsy); + RenderHUDModel(&renderer, psp, ofsx, ofsy); PolyTriangleDrawer::SetModelVertexShader(thread->DrawQueue, -1, -1, 0.0f); #endif }