mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
- 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:
parent
6a43d6c7ff
commit
3364988680
14 changed files with 38 additions and 31 deletions
|
@ -754,9 +754,15 @@ void D_Display ()
|
||||||
Level->HasDynamicLights = !!level.lights;
|
Level->HasDynamicLights = !!level.lights;
|
||||||
}
|
}
|
||||||
else Level->HasDynamicLights = false; // lights are off so effectively we have none.
|
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->Begin2D();
|
||||||
screen->DrawBlend(viewsec);
|
screen->DrawBlend(viewsec);
|
||||||
if (automapactive)
|
if (automapactive)
|
||||||
|
|
|
@ -331,7 +331,6 @@ static void MarkRoot()
|
||||||
SectorMarker->SecNum = 0;
|
SectorMarker->SecNum = 0;
|
||||||
}
|
}
|
||||||
Mark(SectorMarker);
|
Mark(SectorMarker);
|
||||||
Mark(interpolator.Head);
|
|
||||||
// Mark bot stuff.
|
// Mark bot stuff.
|
||||||
Mark(bglobal.firstthing);
|
Mark(bglobal.firstthing);
|
||||||
Mark(bglobal.body1);
|
Mark(bglobal.body1);
|
||||||
|
|
|
@ -1983,6 +1983,7 @@ void FLevelLocals::Mark()
|
||||||
GC::Mark(FraggleScriptThinker);
|
GC::Mark(FraggleScriptThinker);
|
||||||
GC::Mark(ACSThinker);
|
GC::Mark(ACSThinker);
|
||||||
GC::Mark(automap);
|
GC::Mark(automap);
|
||||||
|
GC::Mark(interpolator.Head);
|
||||||
canvasTextureInfo.Mark();
|
canvasTextureInfo.Mark();
|
||||||
for (auto &c : CorpseQueue)
|
for (auto &c : CorpseQueue)
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
#include "p_destructible.h"
|
#include "p_destructible.h"
|
||||||
#include "r_data/r_sections.h"
|
#include "r_data/r_sections.h"
|
||||||
#include "r_data/r_canvastexture.h"
|
#include "r_data/r_canvastexture.h"
|
||||||
|
#include "r_data/r_interpolate.h"
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
//
|
//
|
||||||
|
@ -442,6 +443,7 @@ public:
|
||||||
FString F1Pic;
|
FString F1Pic;
|
||||||
EMapType maptype;
|
EMapType maptype;
|
||||||
FTagManager tagManager;
|
FTagManager tagManager;
|
||||||
|
FInterpolator interpolator;
|
||||||
|
|
||||||
uint64_t ShaderStartTime = 0; // tell the shader system when we started the level (forces a timer restart)
|
uint64_t ShaderStartTime = 0; // tell the shader system when we started the level (forces a timer restart)
|
||||||
|
|
||||||
|
|
|
@ -218,7 +218,6 @@ sector_t * FGLRenderer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * came
|
||||||
mBuffers->BlitToEyeTexture(eye_ix);
|
mBuffers->BlitToEyeTexture(eye_ix);
|
||||||
}
|
}
|
||||||
|
|
||||||
interpolator.RestoreInterpolations ();
|
|
||||||
return mainvp.sector;
|
return mainvp.sector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -964,7 +964,8 @@ void FLevelLocals::Serialize(FSerializer &arc, bool hubload)
|
||||||
("acsthinker", ACSThinker)
|
("acsthinker", ACSThinker)
|
||||||
("impactdecalcount", ImpactDecalCount)
|
("impactdecalcount", ImpactDecalCount)
|
||||||
("scrolls", Scrolls)
|
("scrolls", Scrolls)
|
||||||
("automap", automap);
|
("automap", automap)
|
||||||
|
("interpolator", interpolator);
|
||||||
|
|
||||||
|
|
||||||
// Hub transitions must keep the current total time
|
// Hub transitions must keep the current total time
|
||||||
|
|
|
@ -288,6 +288,7 @@ void FLevelLocals::ClearLevelData()
|
||||||
}
|
}
|
||||||
ClearPortals();
|
ClearPortals();
|
||||||
|
|
||||||
|
interpolator.ClearInterpolations(); // [RH] Nothing to interpolate on a fresh level.
|
||||||
tagManager.Clear();
|
tagManager.Clear();
|
||||||
ClearTIDHashes();
|
ClearTIDHashes();
|
||||||
Behaviors.UnloadModules();
|
Behaviors.UnloadModules();
|
||||||
|
@ -350,7 +351,6 @@ void P_FreeLevelData ()
|
||||||
R_FreePastViewers();
|
R_FreePastViewers();
|
||||||
P_ClearUDMFKeys();
|
P_ClearUDMFKeys();
|
||||||
|
|
||||||
interpolator.ClearInterpolations(); // [RH] Nothing to interpolate on a fresh level.
|
|
||||||
SN_StopAllSequences ();
|
SN_StopAllSequences ();
|
||||||
DThinker::DestroyAllThinkers ();
|
DThinker::DestroyAllThinkers ();
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,10 @@ void P_Ticker (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
interpolator.UpdateInterpolations ();
|
for (auto Level : AllLevels())
|
||||||
|
{
|
||||||
|
Level->interpolator.UpdateInterpolations();
|
||||||
|
}
|
||||||
r_NoInterpolate = true;
|
r_NoInterpolate = true;
|
||||||
|
|
||||||
if (!demoplayback)
|
if (!demoplayback)
|
||||||
|
|
|
@ -188,7 +188,6 @@ void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines)
|
||||||
|
|
||||||
if (Viewpoint.camera)
|
if (Viewpoint.camera)
|
||||||
Viewpoint.camera->renderflags = savedflags;
|
Viewpoint.camera->renderflags = savedflags;
|
||||||
interpolator.RestoreInterpolations ();
|
|
||||||
|
|
||||||
NetUpdate();
|
NetUpdate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "p_local.h"
|
#include "p_local.h"
|
||||||
#include "po_man.h"
|
#include "po_man.h"
|
||||||
#include "serializer.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);
|
Super::Serialize(arc);
|
||||||
arc("refcount", refcount);
|
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_Start3dMidtexInterpolations(attached, sector, ceiling);
|
||||||
P_StartLinkedSectorInterpolations(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;
|
sector = _sector;
|
||||||
ceiling = _plane;
|
ceiling = _plane;
|
||||||
UpdateInterpolation ();
|
UpdateInterpolation ();
|
||||||
interpolator.AddInterpolation(this);
|
sector->Level->interpolator.AddInterpolation(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -672,7 +679,7 @@ DWallScrollInterpolation::DWallScrollInterpolation(side_t *_side, int _part)
|
||||||
side = _side;
|
side = _side;
|
||||||
part = _part;
|
part = _part;
|
||||||
UpdateInterpolation ();
|
UpdateInterpolation ();
|
||||||
interpolator.AddInterpolation(this);
|
side->GetLevel()->interpolator.AddInterpolation(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -770,7 +777,7 @@ DPolyobjInterpolation::DPolyobjInterpolation(FPolyObj *po)
|
||||||
oldverts.Resize(po->Vertices.Size() << 1);
|
oldverts.Resize(po->Vertices.Size() << 1);
|
||||||
bakverts.Resize(po->Vertices.Size() << 1);
|
bakverts.Resize(po->Vertices.Size() << 1);
|
||||||
UpdateInterpolation ();
|
UpdateInterpolation ();
|
||||||
interpolator.AddInterpolation(this);
|
po->Level->interpolator.AddInterpolation(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -43,19 +43,13 @@ public:
|
||||||
|
|
||||||
struct FInterpolator
|
struct FInterpolator
|
||||||
{
|
{
|
||||||
TObjPtr<DInterpolation*> Head;
|
TObjPtr<DInterpolation*> Head = nullptr;
|
||||||
bool didInterp;
|
bool didInterp = false;
|
||||||
int count;
|
int count = 0;
|
||||||
|
|
||||||
int CountInterpolations ();
|
int CountInterpolations ();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FInterpolator()
|
|
||||||
{
|
|
||||||
Head = nullptr;
|
|
||||||
didInterp = false;
|
|
||||||
count = 0;
|
|
||||||
}
|
|
||||||
void UpdateInterpolations();
|
void UpdateInterpolations();
|
||||||
void AddInterpolation(DInterpolation *);
|
void AddInterpolation(DInterpolation *);
|
||||||
void RemoveInterpolation(DInterpolation *);
|
void RemoveInterpolation(DInterpolation *);
|
||||||
|
@ -64,9 +58,6 @@ public:
|
||||||
void ClearInterpolations();
|
void ClearInterpolations();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern FInterpolator interpolator;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -854,8 +854,6 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
|
||||||
|
|
||||||
viewpoint.SetViewAngle (viewwindow);
|
viewpoint.SetViewAngle (viewwindow);
|
||||||
|
|
||||||
interpolator.DoInterpolations (viewpoint.TicFrac);
|
|
||||||
|
|
||||||
// Keep the view within the sector's floor and ceiling
|
// Keep the view within the sector's floor and ceiling
|
||||||
if (viewpoint.sector->PortalBlocksMovement(sector_t::ceiling))
|
if (viewpoint.sector->PortalBlocksMovement(sector_t::ceiling))
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,7 @@ struct FDoorAnimation;
|
||||||
class FSoundID;
|
class FSoundID;
|
||||||
struct FPolyObj;
|
struct FPolyObj;
|
||||||
union FRenderStyle;
|
union FRenderStyle;
|
||||||
|
struct FInterpolator;
|
||||||
|
|
||||||
inline bool nullcmp(const void *buffer, size_t length)
|
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, NumericValue &sid, NumericValue *def);
|
||||||
FSerializer &Serialize(FSerializer &arc, const char *key, ticcmd_t &sid, ticcmd_t *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, usercmd_t &cmd, usercmd_t *def);
|
||||||
|
FSerializer &Serialize(FSerializer &arc, const char *key, FInterpolator &rs, FInterpolator *def);
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
FSerializer &Serialize(FSerializer &arc, const char *key, T *&value, T **)
|
FSerializer &Serialize(FSerializer &arc, const char *key, T *&value, T **)
|
||||||
|
|
|
@ -189,7 +189,6 @@ namespace swrenderer
|
||||||
RenderPSprites();
|
RenderPSprites();
|
||||||
|
|
||||||
MainThread()->Viewport->viewpoint.camera->renderflags = savedflags;
|
MainThread()->Viewport->viewpoint.camera->renderflags = savedflags;
|
||||||
interpolator.RestoreInterpolations();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderScene::RenderPSprites()
|
void RenderScene::RenderPSprites()
|
||||||
|
|
Loading…
Reference in a new issue