- moved the interpolator into FLevelLocals and refactored its use to happen outside the renderers.

There is no need to do this deep inside the renderer where it required code duplication and made it problematic to execute on multiple levels.
This is now being done before and after the top level call into the renderer in d_main.cpp.
This also serializes the interpolator itself to avoid problems with the Serialize functions adding the interpolations into the list which can only work with a single global instance.
This commit is contained in:
Christoph Oelckers 2019-01-28 18:26:14 +01:00
parent 6a43d6c7ff
commit 3364988680
14 changed files with 38 additions and 31 deletions

View File

@ -754,9 +754,15 @@ void D_Display ()
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]);
screen->Begin2D();
screen->DrawBlend(viewsec);
if (automapactive)

View File

@ -331,7 +331,6 @@ static void MarkRoot()
SectorMarker->SecNum = 0;
}
Mark(SectorMarker);
Mark(interpolator.Head);
// Mark bot stuff.
Mark(bglobal.firstthing);
Mark(bglobal.body1);

View File

@ -1983,6 +1983,7 @@ void FLevelLocals::Mark()
GC::Mark(FraggleScriptThinker);
GC::Mark(ACSThinker);
GC::Mark(automap);
GC::Mark(interpolator.Head);
canvasTextureInfo.Mark();
for (auto &c : CorpseQueue)
{

View File

@ -50,6 +50,7 @@
#include "p_destructible.h"
#include "r_data/r_sections.h"
#include "r_data/r_canvastexture.h"
#include "r_data/r_interpolate.h"
//============================================================================
//
@ -442,6 +443,7 @@ public:
FString F1Pic;
EMapType maptype;
FTagManager tagManager;
FInterpolator interpolator;
uint64_t ShaderStartTime = 0; // tell the shader system when we started the level (forces a timer restart)

View File

@ -218,7 +218,6 @@ sector_t * FGLRenderer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * came
mBuffers->BlitToEyeTexture(eye_ix);
}
interpolator.RestoreInterpolations ();
return mainvp.sector;
}

View File

@ -964,7 +964,8 @@ void FLevelLocals::Serialize(FSerializer &arc, bool hubload)
("acsthinker", ACSThinker)
("impactdecalcount", ImpactDecalCount)
("scrolls", Scrolls)
("automap", automap);
("automap", automap)
("interpolator", interpolator);
// Hub transitions must keep the current total time

View File

@ -288,6 +288,7 @@ void FLevelLocals::ClearLevelData()
}
ClearPortals();
interpolator.ClearInterpolations(); // [RH] Nothing to interpolate on a fresh level.
tagManager.Clear();
ClearTIDHashes();
Behaviors.UnloadModules();
@ -350,7 +351,6 @@ void P_FreeLevelData ()
R_FreePastViewers();
P_ClearUDMFKeys();
interpolator.ClearInterpolations(); // [RH] Nothing to interpolate on a fresh level.
SN_StopAllSequences ();
DThinker::DestroyAllThinkers ();

View File

@ -75,7 +75,10 @@ void P_Ticker (void)
{
int i;
interpolator.UpdateInterpolations ();
for (auto Level : AllLevels())
{
Level->interpolator.UpdateInterpolations();
}
r_NoInterpolate = true;
if (!demoplayback)

View File

@ -188,7 +188,6 @@ void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines)
if (Viewpoint.camera)
Viewpoint.camera->renderflags = savedflags;
interpolator.RestoreInterpolations ();
NetUpdate();
}

View File

@ -39,6 +39,7 @@
#include "p_local.h"
#include "po_man.h"
#include "serializer.h"
#include "g_levellocals.h"
//==========================================================================
//
@ -312,6 +313,16 @@ void FInterpolator::ClearInterpolations()
}
}
FSerializer &Serialize(FSerializer &arc, const char *key, FInterpolator &rs, FInterpolator *def)
{
if (arc.BeginObject(key))
{
arc("head", rs.Head)
("count", rs.count)
.EndObject();
}
return arc;
}
//==========================================================================
//
@ -379,10 +390,6 @@ void DInterpolation::Serialize(FSerializer &arc)
{
Super::Serialize(arc);
arc("refcount", refcount);
if (arc.isReading())
{
interpolator.AddInterpolation(this);
}
}
//==========================================================================
@ -408,7 +415,7 @@ DSectorPlaneInterpolation::DSectorPlaneInterpolation(sector_t *_sector, bool _pl
P_Start3dMidtexInterpolations(attached, sector, ceiling);
P_StartLinkedSectorInterpolations(attached, sector, ceiling);
}
interpolator.AddInterpolation(this);
sector->Level->interpolator.AddInterpolation(this);
}
//==========================================================================
@ -567,7 +574,7 @@ DSectorScrollInterpolation::DSectorScrollInterpolation(sector_t *_sector, bool _
sector = _sector;
ceiling = _plane;
UpdateInterpolation ();
interpolator.AddInterpolation(this);
sector->Level->interpolator.AddInterpolation(this);
}
//==========================================================================
@ -672,7 +679,7 @@ DWallScrollInterpolation::DWallScrollInterpolation(side_t *_side, int _part)
side = _side;
part = _part;
UpdateInterpolation ();
interpolator.AddInterpolation(this);
side->GetLevel()->interpolator.AddInterpolation(this);
}
//==========================================================================
@ -770,7 +777,7 @@ DPolyobjInterpolation::DPolyobjInterpolation(FPolyObj *po)
oldverts.Resize(po->Vertices.Size() << 1);
bakverts.Resize(po->Vertices.Size() << 1);
UpdateInterpolation ();
interpolator.AddInterpolation(this);
po->Level->interpolator.AddInterpolation(this);
}
//==========================================================================

View File

@ -43,19 +43,13 @@ public:
struct FInterpolator
{
TObjPtr<DInterpolation*> Head;
bool didInterp;
int count;
TObjPtr<DInterpolation*> Head = nullptr;
bool didInterp = false;
int count = 0;
int CountInterpolations ();
public:
FInterpolator()
{
Head = nullptr;
didInterp = false;
count = 0;
}
void UpdateInterpolations();
void AddInterpolation(DInterpolation *);
void RemoveInterpolation(DInterpolation *);
@ -64,9 +58,6 @@ public:
void ClearInterpolations();
};
extern FInterpolator interpolator;
#endif

View File

@ -854,8 +854,6 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
viewpoint.SetViewAngle (viewwindow);
interpolator.DoInterpolations (viewpoint.TicFrac);
// Keep the view within the sector's floor and ceiling
if (viewpoint.sector->PortalBlocksMovement(sector_t::ceiling))
{

View File

@ -24,6 +24,7 @@ struct FDoorAnimation;
class FSoundID;
struct FPolyObj;
union FRenderStyle;
struct FInterpolator;
inline bool nullcmp(const void *buffer, size_t length)
{
@ -202,6 +203,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FString &sid, FString
FSerializer &Serialize(FSerializer &arc, const char *key, NumericValue &sid, NumericValue *def);
FSerializer &Serialize(FSerializer &arc, const char *key, ticcmd_t &sid, ticcmd_t *def);
FSerializer &Serialize(FSerializer &arc, const char *key, usercmd_t &cmd, usercmd_t *def);
FSerializer &Serialize(FSerializer &arc, const char *key, FInterpolator &rs, FInterpolator *def);
template<class T>
FSerializer &Serialize(FSerializer &arc, const char *key, T *&value, T **)

View File

@ -189,7 +189,6 @@ namespace swrenderer
RenderPSprites();
MainThread()->Viewport->viewpoint.camera->renderflags = savedflags;
interpolator.RestoreInterpolations();
}
void RenderScene::RenderPSprites()