mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 20:43:15 +00:00
Removed RenderCamera, RenderBeforeThing, RenderAfterThing. Serialization preparations.
This commit is contained in:
parent
278741efa9
commit
23c9386add
8 changed files with 14 additions and 91 deletions
|
@ -53,10 +53,16 @@ bool E_CheckHandler(DStaticEventHandler* handler)
|
||||||
|
|
||||||
bool E_IsStaticType(PClass* type)
|
bool E_IsStaticType(PClass* type)
|
||||||
{
|
{
|
||||||
return (!type->IsDescendantOf(RUNTIME_CLASS(DEventHandler)) &&
|
return (type->IsDescendantOf(RUNTIME_CLASS(DStaticEventHandler)) && // make sure it's from our hierarchy at all.
|
||||||
|
!type->IsDescendantOf(RUNTIME_CLASS(DEventHandler)) &&
|
||||||
!type->IsDescendantOf(RUNTIME_CLASS(DRenderEventHandler)));
|
!type->IsDescendantOf(RUNTIME_CLASS(DRenderEventHandler)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void E_SerializeEvents(FSerializer& arc)
|
||||||
|
{
|
||||||
|
// todo : stuff
|
||||||
|
}
|
||||||
|
|
||||||
static void E_InitStaticHandler(PClass* type, FString typestring, bool map)
|
static void E_InitStaticHandler(PClass* type, FString typestring, bool map)
|
||||||
{
|
{
|
||||||
if (type == nullptr)
|
if (type == nullptr)
|
||||||
|
@ -136,24 +142,6 @@ void E_RenderFrame()
|
||||||
handler->RenderFrame();
|
handler->RenderFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void E_RenderCamera()
|
|
||||||
{
|
|
||||||
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
|
|
||||||
handler->RenderCamera();
|
|
||||||
}
|
|
||||||
|
|
||||||
void E_RenderBeforeThing(AActor* thing)
|
|
||||||
{
|
|
||||||
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
|
|
||||||
handler->RenderBeforeThing(thing);
|
|
||||||
}
|
|
||||||
|
|
||||||
void E_RenderAfterThing(AActor* thing)
|
|
||||||
{
|
|
||||||
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
|
|
||||||
handler->RenderAfterThing(thing);
|
|
||||||
}
|
|
||||||
|
|
||||||
// declarations
|
// declarations
|
||||||
IMPLEMENT_CLASS(DStaticEventHandler, false, false);
|
IMPLEMENT_CLASS(DStaticEventHandler, false, false);
|
||||||
IMPLEMENT_CLASS(DStaticRenderEventHandler, false, false);
|
IMPLEMENT_CLASS(DStaticRenderEventHandler, false, false);
|
||||||
|
@ -166,7 +154,6 @@ DEFINE_FIELD_X(StaticRenderEventHandler, DStaticRenderEventHandler, ViewPitch);
|
||||||
DEFINE_FIELD_X(StaticRenderEventHandler, DStaticRenderEventHandler, ViewRoll);
|
DEFINE_FIELD_X(StaticRenderEventHandler, DStaticRenderEventHandler, ViewRoll);
|
||||||
DEFINE_FIELD_X(StaticRenderEventHandler, DStaticRenderEventHandler, FracTic);
|
DEFINE_FIELD_X(StaticRenderEventHandler, DStaticRenderEventHandler, FracTic);
|
||||||
DEFINE_FIELD_X(StaticRenderEventHandler, DStaticRenderEventHandler, Camera);
|
DEFINE_FIELD_X(StaticRenderEventHandler, DStaticRenderEventHandler, Camera);
|
||||||
DEFINE_FIELD_X(StaticRenderEventHandler, DStaticRenderEventHandler, CurrentThing);
|
|
||||||
|
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(DEventHandler, Create)
|
DEFINE_ACTION_FUNCTION(DEventHandler, Create)
|
||||||
|
@ -246,9 +233,6 @@ void cls::funcname(args) \
|
||||||
DEFINE_EVENT_HANDLER(DStaticEventHandler, MapLoaded,)
|
DEFINE_EVENT_HANDLER(DStaticEventHandler, MapLoaded,)
|
||||||
DEFINE_EVENT_HANDLER(DStaticEventHandler, MapUnloading,)
|
DEFINE_EVENT_HANDLER(DStaticEventHandler, MapUnloading,)
|
||||||
DEFINE_EVENT_HANDLER(DStaticEventHandler, RenderFrame,)
|
DEFINE_EVENT_HANDLER(DStaticEventHandler, RenderFrame,)
|
||||||
DEFINE_EVENT_HANDLER(DStaticEventHandler, RenderCamera,)
|
|
||||||
DEFINE_EVENT_HANDLER(DStaticEventHandler, RenderBeforeThing, AActor*)
|
|
||||||
DEFINE_EVENT_HANDLER(DStaticEventHandler, RenderAfterThing, AActor*)
|
|
||||||
|
|
||||||
//
|
//
|
||||||
void DStaticEventHandler::OnDestroy()
|
void DStaticEventHandler::OnDestroy()
|
||||||
|
@ -273,20 +257,3 @@ void DStaticRenderEventHandler::RenderFrame()
|
||||||
DStaticEventHandler::RenderFrame();
|
DStaticEventHandler::RenderFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DStaticRenderEventHandler::RenderCamera()
|
|
||||||
{
|
|
||||||
Setup();
|
|
||||||
DStaticEventHandler::RenderCamera();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DStaticRenderEventHandler::RenderBeforeThing(AActor* thing)
|
|
||||||
{
|
|
||||||
CurrentThing = thing;
|
|
||||||
DStaticEventHandler::RenderBeforeThing(thing);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DStaticRenderEventHandler::RenderAfterThing(AActor* thing)
|
|
||||||
{
|
|
||||||
CurrentThing = thing;
|
|
||||||
DStaticEventHandler::RenderAfterThing(thing);
|
|
||||||
}
|
|
40
src/events.h
40
src/events.h
|
@ -2,6 +2,7 @@
|
||||||
#define EVENTS_H
|
#define EVENTS_H
|
||||||
|
|
||||||
#include "dobject.h"
|
#include "dobject.h"
|
||||||
|
#include "serializer.h"
|
||||||
|
|
||||||
class DStaticEventHandler;
|
class DStaticEventHandler;
|
||||||
|
|
||||||
|
@ -22,12 +23,9 @@ void E_MapLoaded();
|
||||||
void E_MapUnloading();
|
void E_MapUnloading();
|
||||||
// called on each render frame once.
|
// called on each render frame once.
|
||||||
void E_RenderFrame();
|
void E_RenderFrame();
|
||||||
// called before entering each actor's view (including RenderFrame)
|
|
||||||
void E_RenderCamera();
|
// serialization stuff
|
||||||
// called before adding each actor to the render list
|
void E_SerializeEvents(FSerializer& arc);
|
||||||
void E_RenderBeforeThing(AActor* thing);
|
|
||||||
// called after adding each actor to the render list
|
|
||||||
void E_RenderAfterThing(AActor* thing);
|
|
||||||
|
|
||||||
class DStaticEventHandler : public DObject // make it a part of normal GC process
|
class DStaticEventHandler : public DObject // make it a part of normal GC process
|
||||||
{
|
{
|
||||||
|
@ -52,12 +50,6 @@ public:
|
||||||
virtual void MapUnloading();
|
virtual void MapUnloading();
|
||||||
// called on each render frame once.
|
// called on each render frame once.
|
||||||
virtual void RenderFrame();
|
virtual void RenderFrame();
|
||||||
// called before entering each actor's view (including RenderFrame)
|
|
||||||
virtual void RenderCamera();
|
|
||||||
// called before adding each actor to the render list
|
|
||||||
virtual void RenderBeforeThing(AActor* thing);
|
|
||||||
// called after adding each actor to the render list
|
|
||||||
virtual void RenderAfterThing(AActor* thing);
|
|
||||||
};
|
};
|
||||||
class DEventHandler : public DStaticEventHandler
|
class DEventHandler : public DStaticEventHandler
|
||||||
{
|
{
|
||||||
|
@ -77,33 +69,9 @@ public:
|
||||||
DAngle ViewPitch;
|
DAngle ViewPitch;
|
||||||
DAngle ViewRoll;
|
DAngle ViewRoll;
|
||||||
double FracTic; // 0..1 value that describes where we are inside the current gametic, render-wise.
|
double FracTic; // 0..1 value that describes where we are inside the current gametic, render-wise.
|
||||||
// this makes sense in RenderCamera
|
|
||||||
AActor* Camera;
|
AActor* Camera;
|
||||||
// this is for RenderBeforeThing and RenderAfterThing
|
|
||||||
AActor* CurrentThing;
|
|
||||||
|
|
||||||
void RenderFrame() override;
|
void RenderFrame() override;
|
||||||
void RenderCamera() override;
|
|
||||||
void RenderBeforeThing(AActor* thing) override;
|
|
||||||
void RenderAfterThing(AActor* thing) override;
|
|
||||||
|
|
||||||
// this is a class that I use to automatically call RenderAfterThing.
|
|
||||||
// C++ is really horrible for not providing try-finally statement.
|
|
||||||
struct AutoThing
|
|
||||||
{
|
|
||||||
AActor* thing;
|
|
||||||
|
|
||||||
AutoThing(AActor* thing)
|
|
||||||
{
|
|
||||||
this->thing = thing;
|
|
||||||
E_RenderBeforeThing(this->thing);
|
|
||||||
}
|
|
||||||
|
|
||||||
~AutoThing()
|
|
||||||
{
|
|
||||||
E_RenderAfterThing(this->thing);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Setup();
|
void Setup();
|
||||||
|
|
|
@ -478,9 +478,6 @@ void FGLRenderer::RenderTranslucent()
|
||||||
|
|
||||||
void FGLRenderer::DrawScene(int drawmode)
|
void FGLRenderer::DrawScene(int drawmode)
|
||||||
{
|
{
|
||||||
// [ZZ] call event hook
|
|
||||||
E_RenderCamera();
|
|
||||||
|
|
||||||
static int recursion=0;
|
static int recursion=0;
|
||||||
static int ssao_portals_available = 0;
|
static int ssao_portals_available = 0;
|
||||||
|
|
||||||
|
|
|
@ -650,8 +650,6 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
|
||||||
if (thing == nullptr)
|
if (thing == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DStaticRenderEventHandler::AutoThing autoRenderThingEvent(thing);
|
|
||||||
|
|
||||||
// [ZZ] allow CustomSprite-style direct picnum specification
|
// [ZZ] allow CustomSprite-style direct picnum specification
|
||||||
bool isPicnumOverride = thing->picnum.isValid();
|
bool isPicnumOverride = thing->picnum.isValid();
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
#include "r_renderer.h"
|
#include "r_renderer.h"
|
||||||
#include "serializer.h"
|
#include "serializer.h"
|
||||||
#include "g_levellocals.h"
|
#include "g_levellocals.h"
|
||||||
|
#include "events.h"
|
||||||
|
|
||||||
static TStaticArray<sector_t> loadsectors;
|
static TStaticArray<sector_t> loadsectors;
|
||||||
static TStaticArray<line_t> loadlines;
|
static TStaticArray<line_t> loadlines;
|
||||||
|
@ -967,6 +968,8 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
|
||||||
arc("sectorportals", level.sectorPortals);
|
arc("sectorportals", level.sectorPortals);
|
||||||
if (arc.isReading()) P_CollectLinkedPortals();
|
if (arc.isReading()) P_CollectLinkedPortals();
|
||||||
|
|
||||||
|
// [ZZ] serialize events
|
||||||
|
E_SerializeEvents(arc);
|
||||||
DThinker::SerializeThinkers(arc, !hubload);
|
DThinker::SerializeThinkers(arc, !hubload);
|
||||||
arc.Array("polyobjs", polyobjs, po_NumPolyobjs);
|
arc.Array("polyobjs", polyobjs, po_NumPolyobjs);
|
||||||
arc("subsectors", subsectors);
|
arc("subsectors", subsectors);
|
||||||
|
|
|
@ -720,9 +720,6 @@ void R_EnterPortal (PortalDrawseg* pds, int depth)
|
||||||
|
|
||||||
R_CopyStackedViewParameters();
|
R_CopyStackedViewParameters();
|
||||||
|
|
||||||
// [ZZ] portal hook
|
|
||||||
E_RenderCamera();
|
|
||||||
|
|
||||||
validcount++;
|
validcount++;
|
||||||
PortalDrawseg* prevpds = CurrentPortal;
|
PortalDrawseg* prevpds = CurrentPortal;
|
||||||
CurrentPortal = pds;
|
CurrentPortal = pds;
|
||||||
|
@ -844,9 +841,6 @@ void R_RenderActorView (AActor *actor, bool dontmaplines)
|
||||||
R_SetupBuffer ();
|
R_SetupBuffer ();
|
||||||
R_SetupFrame (actor);
|
R_SetupFrame (actor);
|
||||||
|
|
||||||
// [ZZ] call event hook
|
|
||||||
E_RenderCamera();
|
|
||||||
|
|
||||||
// Clear buffers.
|
// Clear buffers.
|
||||||
R_ClearClipSegs (0, viewwidth);
|
R_ClearClipSegs (0, viewwidth);
|
||||||
R_ClearDrawSegs ();
|
R_ClearDrawSegs ();
|
||||||
|
|
|
@ -1179,8 +1179,6 @@ void R_DrawPortals ()
|
||||||
R_SetViewAngle ();
|
R_SetViewAngle ();
|
||||||
validcount++; // Make sure we see all sprites
|
validcount++; // Make sure we see all sprites
|
||||||
|
|
||||||
E_RenderCamera();
|
|
||||||
|
|
||||||
R_ClearPlanes (false);
|
R_ClearPlanes (false);
|
||||||
R_ClearClipSegs (pl->left, pl->right);
|
R_ClearClipSegs (pl->left, pl->right);
|
||||||
WindowLeft = pl->left;
|
WindowLeft = pl->left;
|
||||||
|
|
|
@ -1245,8 +1245,6 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside)
|
||||||
if (thing->validcount == validcount) continue;
|
if (thing->validcount == validcount) continue;
|
||||||
thing->validcount = validcount;
|
thing->validcount = validcount;
|
||||||
|
|
||||||
DStaticRenderEventHandler::AutoThing autoRenderThingEvent(thing);
|
|
||||||
|
|
||||||
FIntCVar *cvar = thing->GetClass()->distancecheck;
|
FIntCVar *cvar = thing->GetClass()->distancecheck;
|
||||||
if (cvar != NULL && *cvar >= 0)
|
if (cvar != NULL && *cvar >= 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue