- moved particle storage into FLevelLocals.

- moved parts of the render setup out of the separate render functions.

Things like particle and polyobject linking were duplicated several times for rendering different things in different renderers.
These things only need to be set up once before the renderer is started so it makes a lot more sense to consolidate them into one place outside the actual rendering code.
This commit is contained in:
Christoph Oelckers 2019-01-29 01:09:02 +01:00
commit 68667e5eaa
22 changed files with 139 additions and 128 deletions

View file

@ -351,6 +351,35 @@ void D_RemoveNextCharEvent()
}
}
//==========================================================================
//
// Render wrapper.
// This function contains all the needed setup and cleanup for starting a render job.
//
//==========================================================================
void D_Render(std::function<void()> action, bool interpolate)
{
for (auto Level : AllLevels())
{
// Check for the presence of dynamic lights at the start of the frame once.
if ((gl_lights && vid_rendermode == 4) || (r_dynlights && vid_rendermode != 4))
{
Level->HasDynamicLights = !!level.lights;
}
else Level->HasDynamicLights = false; // lights are off so effectively we have none.
if (interpolate) Level->interpolator.DoInterpolations(I_GetTimeFrac());
P_FindParticleSubsectors(Level);
PO_LinkToSubsectors(Level);
}
action();
if (interpolate) for (auto Level : AllLevels())
{
Level->interpolator.RestoreInterpolations();
}
}
//==========================================================================
//
// CVAR dmflags
@ -746,22 +775,10 @@ void D_Display ()
//E_RenderFrame();
//
for (auto Level : AllLevels())
D_Render([&]()
{
// Check for the presence of dynamic lights at the start of the frame once.
if ((gl_lights && vid_rendermode == 4) || (r_dynlights && vid_rendermode != 4))
{
Level->HasDynamicLights = !!level.lights;
}
else Level->HasDynamicLights = false; // lights are off so effectively we have none.
Level->interpolator.DoInterpolations(I_GetTimeFrac());
}
viewsec = screen->RenderView(&players[consoleplayer]);
for (auto Level : AllLevels())
{
Level->interpolator.RestoreInterpolations();
}
viewsec = screen->RenderView(&players[consoleplayer]);
}, true);
screen->Begin2D();
screen->DrawBlend(viewsec);