From 23c9386addf5cb6088df8fdd2e670cdf2548248c Mon Sep 17 00:00:00 2001 From: ZZYZX Date: Mon, 23 Jan 2017 23:05:51 +0200 Subject: [PATCH] Removed RenderCamera, RenderBeforeThing, RenderAfterThing. Serialization preparations. --- src/events.cpp | 47 ++++++-------------------------------- src/events.h | 40 ++++---------------------------- src/gl/scene/gl_scene.cpp | 3 --- src/gl/scene/gl_sprite.cpp | 2 -- src/p_saveg.cpp | 3 +++ src/r_main.cpp | 6 ----- src/r_plane.cpp | 2 -- src/r_things.cpp | 2 -- 8 files changed, 14 insertions(+), 91 deletions(-) diff --git a/src/events.cpp b/src/events.cpp index 504b2667f..60e2e3a49 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -53,10 +53,16 @@ bool E_CheckHandler(DStaticEventHandler* handler) 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))); } +void E_SerializeEvents(FSerializer& arc) +{ + // todo : stuff +} + static void E_InitStaticHandler(PClass* type, FString typestring, bool map) { if (type == nullptr) @@ -136,24 +142,6 @@ void E_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 IMPLEMENT_CLASS(DStaticEventHandler, 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, FracTic); DEFINE_FIELD_X(StaticRenderEventHandler, DStaticRenderEventHandler, Camera); -DEFINE_FIELD_X(StaticRenderEventHandler, DStaticRenderEventHandler, CurrentThing); DEFINE_ACTION_FUNCTION(DEventHandler, Create) @@ -246,9 +233,6 @@ void cls::funcname(args) \ DEFINE_EVENT_HANDLER(DStaticEventHandler, MapLoaded,) DEFINE_EVENT_HANDLER(DStaticEventHandler, MapUnloading,) 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() @@ -273,20 +257,3 @@ void DStaticRenderEventHandler::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); -} \ No newline at end of file diff --git a/src/events.h b/src/events.h index 8be072735..4ea37c513 100755 --- a/src/events.h +++ b/src/events.h @@ -2,6 +2,7 @@ #define EVENTS_H #include "dobject.h" +#include "serializer.h" class DStaticEventHandler; @@ -22,12 +23,9 @@ void E_MapLoaded(); void E_MapUnloading(); // called on each render frame once. void E_RenderFrame(); -// called before entering each actor's view (including RenderFrame) -void E_RenderCamera(); -// called before adding each actor to the render list -void E_RenderBeforeThing(AActor* thing); -// called after adding each actor to the render list -void E_RenderAfterThing(AActor* thing); + +// serialization stuff +void E_SerializeEvents(FSerializer& arc); class DStaticEventHandler : public DObject // make it a part of normal GC process { @@ -52,12 +50,6 @@ public: virtual void MapUnloading(); // called on each render frame once. 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 { @@ -77,33 +69,9 @@ public: DAngle ViewPitch; DAngle ViewRoll; double FracTic; // 0..1 value that describes where we are inside the current gametic, render-wise. - // this makes sense in RenderCamera AActor* Camera; - // this is for RenderBeforeThing and RenderAfterThing - AActor* CurrentThing; 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: void Setup(); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index f3b37ffb5..870af02dd 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -478,9 +478,6 @@ void FGLRenderer::RenderTranslucent() void FGLRenderer::DrawScene(int drawmode) { - // [ZZ] call event hook - E_RenderCamera(); - static int recursion=0; static int ssao_portals_available = 0; diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index e2dc6feff..9ca52e18f 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -650,8 +650,6 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) if (thing == nullptr) return; - DStaticRenderEventHandler::AutoThing autoRenderThingEvent(thing); - // [ZZ] allow CustomSprite-style direct picnum specification bool isPicnumOverride = thing->picnum.isValid(); diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 04c35d157..7a660129b 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -63,6 +63,7 @@ #include "r_renderer.h" #include "serializer.h" #include "g_levellocals.h" +#include "events.h" static TStaticArray loadsectors; static TStaticArray loadlines; @@ -967,6 +968,8 @@ void G_SerializeLevel(FSerializer &arc, bool hubload) arc("sectorportals", level.sectorPortals); if (arc.isReading()) P_CollectLinkedPortals(); + // [ZZ] serialize events + E_SerializeEvents(arc); DThinker::SerializeThinkers(arc, !hubload); arc.Array("polyobjs", polyobjs, po_NumPolyobjs); arc("subsectors", subsectors); diff --git a/src/r_main.cpp b/src/r_main.cpp index 1ae22ba3f..4a8e796ad 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -720,9 +720,6 @@ void R_EnterPortal (PortalDrawseg* pds, int depth) R_CopyStackedViewParameters(); - // [ZZ] portal hook - E_RenderCamera(); - validcount++; PortalDrawseg* prevpds = CurrentPortal; CurrentPortal = pds; @@ -844,9 +841,6 @@ void R_RenderActorView (AActor *actor, bool dontmaplines) R_SetupBuffer (); R_SetupFrame (actor); - // [ZZ] call event hook - E_RenderCamera(); - // Clear buffers. R_ClearClipSegs (0, viewwidth); R_ClearDrawSegs (); diff --git a/src/r_plane.cpp b/src/r_plane.cpp index b452d97a0..62730e731 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1179,8 +1179,6 @@ void R_DrawPortals () R_SetViewAngle (); validcount++; // Make sure we see all sprites - E_RenderCamera(); - R_ClearPlanes (false); R_ClearClipSegs (pl->left, pl->right); WindowLeft = pl->left; diff --git a/src/r_things.cpp b/src/r_things.cpp index a4709b483..a468e4c58 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1245,8 +1245,6 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside) if (thing->validcount == validcount) continue; thing->validcount = validcount; - DStaticRenderEventHandler::AutoThing autoRenderThingEvent(thing); - FIntCVar *cvar = thing->GetClass()->distancecheck; if (cvar != NULL && *cvar >= 0) {