mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-25 05:31:00 +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)
|
||||
{
|
||||
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);
|
||||
}
|
40
src/events.h
40
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();
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#include "r_renderer.h"
|
||||
#include "serializer.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "events.h"
|
||||
|
||||
static TStaticArray<sector_t> loadsectors;
|
||||
static TStaticArray<line_t> 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);
|
||||
|
|
|
@ -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 ();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue