mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-12-11 05:01:09 +00:00
- started cleanup of dependencies of the framebuffer class.
* made the portal state global, outside the framebuffer, because it is pure logic state without dependencies on the backend. * took the setup functions out of FDynLightData - there is no need to have them as members and they age game dependent.
This commit is contained in:
parent
9872065fc6
commit
59360f2d77
16 changed files with 46 additions and 36 deletions
|
@ -26,8 +26,9 @@
|
|||
**/
|
||||
|
||||
#include "actorinlines.h"
|
||||
|
||||
#include "a_dynlight.h"
|
||||
#include "hw_dynlightdata.h"
|
||||
#include "hwrenderer/scene/hw_drawstructs.h"
|
||||
|
||||
// If we want to share the array to avoid constant allocations it needs to be thread local unless it'd be littered with expensive synchronization.
|
||||
thread_local FDynLightData lightdata;
|
||||
|
@ -48,7 +49,7 @@ CVAR (Bool, gl_light_particles, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
|
|||
// Sets up the parameters to render one dynamic light onto one plane
|
||||
//
|
||||
//==========================================================================
|
||||
bool FDynLightData::GetLight(int group, Plane & p, FDynamicLight * light, bool checkside)
|
||||
bool GetLight(FDynLightData& dld, int group, Plane & p, FDynamicLight * light, bool checkside)
|
||||
{
|
||||
DVector3 pos = light->PosRelative(group);
|
||||
float radius = (light->GetRadius());
|
||||
|
@ -62,7 +63,7 @@ bool FDynLightData::GetLight(int group, Plane & p, FDynamicLight * light, bool c
|
|||
return false;
|
||||
}
|
||||
|
||||
AddLightToList(group, light, false);
|
||||
AddLightToList(dld, group, light, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -71,7 +72,7 @@ bool FDynLightData::GetLight(int group, Plane & p, FDynamicLight * light, bool c
|
|||
// Add one dynamic light to the light data list
|
||||
//
|
||||
//==========================================================================
|
||||
void FDynLightData::AddLightToList(int group, FDynamicLight * light, bool forceAttenuate)
|
||||
void AddLightToList(FDynLightData &dld, int group, FDynamicLight * light, bool forceAttenuate)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
|
@ -129,7 +130,7 @@ void FDynLightData::AddLightToList(int group, FDynamicLight * light, bool forceA
|
|||
spotDirZ = float(-Angle.Sin() * xzLen);
|
||||
}
|
||||
|
||||
float *data = &arrays[i][arrays[i].Reserve(16)];
|
||||
float *data = &dld.arrays[i][dld.arrays[i].Reserve(16)];
|
||||
data[0] = float(pos.X);
|
||||
data[1] = float(pos.Z);
|
||||
data[2] = float(pos.Y);
|
||||
|
|
|
@ -23,9 +23,6 @@
|
|||
#ifndef __GLC_DYNLIGHT_H
|
||||
#define __GLC_DYNLIGHT_H
|
||||
|
||||
#include "a_dynlight.h"
|
||||
|
||||
|
||||
struct FDynLightData
|
||||
{
|
||||
TArray<float> arrays[3];
|
||||
|
@ -53,8 +50,6 @@ struct FDynLightData
|
|||
if (siz[2] > max) siz[2] = max;
|
||||
}
|
||||
|
||||
bool GetLight(int group, Plane & p, FDynamicLight * light, bool checkside);
|
||||
void AddLightToList(int group, FDynamicLight * light, bool forceAttenuate);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ public:
|
|||
|
||||
};
|
||||
|
||||
int gl_SetDynModelLight(AActor *self, int dynlightindex);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "stats.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "v_video.h"
|
||||
#include "a_dynlight.h"
|
||||
|
||||
/*
|
||||
The 1D shadow maps are stored in a 1024x1024 texture as float depth values (R32F).
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "gl_system.h"
|
||||
#include "gi.h"
|
||||
#include "a_dynlight.h"
|
||||
#include "m_png.h"
|
||||
#include "doomstat.h"
|
||||
#include "r_data/r_interpolate.h"
|
||||
|
|
|
@ -62,7 +62,7 @@ void FHWModelRenderer::BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, con
|
|||
// TO-DO: Implement proper depth sorting.
|
||||
if (!(actor->RenderStyle == DefaultRenderStyle()) && !(smf->flags & MDL_DONTCULLBACKFACES))
|
||||
{
|
||||
state.SetCulling((mirrored ^ screen->mPortalState->isMirrored()) ? Cull_CCW : Cull_CW);
|
||||
state.SetCulling((mirrored ^ portalState.isMirrored()) ? Cull_CCW : Cull_CW);
|
||||
}
|
||||
|
||||
state.mModelMatrix = objectToWorldMatrix;
|
||||
|
@ -86,7 +86,7 @@ void FHWModelRenderer::BeginDrawHUDModel(AActor *actor, const VSMatrix &objectTo
|
|||
// TO-DO: Implement proper depth sorting.
|
||||
if (!(actor->RenderStyle == DefaultRenderStyle()))
|
||||
{
|
||||
state.SetCulling((mirrored ^ screen->mPortalState->isMirrored()) ? Cull_CW : Cull_CCW);
|
||||
state.SetCulling((mirrored ^ portalState.isMirrored()) ? Cull_CW : Cull_CCW);
|
||||
}
|
||||
|
||||
state.mModelMatrix = objectToWorldMatrix;
|
||||
|
|
|
@ -432,7 +432,7 @@ void HWDrawInfo::CreateScene(bool drawpsprites)
|
|||
mClipper->SafeAddClipRangeRealAngles(vp.Angles.Yaw.BAMs() + a1, vp.Angles.Yaw.BAMs() - a1);
|
||||
|
||||
// reset the portal manager
|
||||
screen->mPortalState->StartFrame();
|
||||
portalState.StartFrame();
|
||||
|
||||
ProcessAll.Clock();
|
||||
|
||||
|
@ -689,7 +689,7 @@ void HWDrawInfo::DrawScene(int drawmode)
|
|||
auto& RenderState = *screen->RenderState();
|
||||
|
||||
RenderState.SetDepthMask(true);
|
||||
if (!gl_no_skyclear) screen->mPortalState->RenderFirstSkyPortal(recursion, this, RenderState);
|
||||
if (!gl_no_skyclear) portalState.RenderFirstSkyPortal(recursion, this, RenderState);
|
||||
|
||||
RenderScene(RenderState);
|
||||
|
||||
|
@ -702,7 +702,7 @@ void HWDrawInfo::DrawScene(int drawmode)
|
|||
// Handle all portals after rendering the opaque objects but before
|
||||
// doing all translucent stuff
|
||||
recursion++;
|
||||
screen->mPortalState->EndFrame(this, RenderState);
|
||||
portalState.EndFrame(this, RenderState);
|
||||
recursion--;
|
||||
RenderTranslucent(RenderState);
|
||||
}
|
||||
|
@ -716,7 +716,7 @@ void HWDrawInfo::DrawScene(int drawmode)
|
|||
|
||||
void HWDrawInfo::ProcessScene(bool toscreen)
|
||||
{
|
||||
screen->mPortalState->BeginScene();
|
||||
portalState.BeginScene();
|
||||
|
||||
int mapsection = Level->PointInRenderSubsector(Viewpoint.Pos)->mapsection;
|
||||
CurrentMapSections.Set(mapsection);
|
||||
|
@ -735,7 +735,7 @@ void HWDrawInfo::AddSubsectorToPortal(FSectorPortalGroup *ptg, subsector_t *sub)
|
|||
auto portal = FindPortal(ptg);
|
||||
if (!portal)
|
||||
{
|
||||
portal = new HWSectorStackPortal(screen->mPortalState, ptg);
|
||||
portal = new HWSectorStackPortal(&portalState, ptg);
|
||||
Portals.Push(portal);
|
||||
}
|
||||
auto ptl = static_cast<HWSectorStackPortal*>(portal);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "hwrenderer/scene/hw_drawstructs.h"
|
||||
#include "hwrenderer/scene/hw_drawinfo.h"
|
||||
#include "hw_material.h"
|
||||
#include "actor.h"
|
||||
|
||||
EXTERN_CVAR(Bool, gl_seamless)
|
||||
|
||||
|
|
|
@ -430,3 +430,8 @@ bool hw_SetPlaneTextureRotation(const HWSectorPlane * secplane, FGameTexture * g
|
|||
void hw_GetDynModelLight(AActor *self, FDynLightData &modellightdata);
|
||||
|
||||
extern const float LARGE_VALUE;
|
||||
|
||||
struct FDynLightData;
|
||||
struct FDynamicLight;
|
||||
bool GetLight(FDynLightData& dld, int group, Plane& p, FDynamicLight* light, bool checkside);
|
||||
void AddLightToList(FDynLightData &dld, int group, FDynamicLight* light, bool forceAttenuate);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
*/
|
||||
|
||||
#include "a_sharedglobal.h"
|
||||
#include "a_dynlight.h"
|
||||
#include "r_defs.h"
|
||||
#include "r_sky.h"
|
||||
#include "r_utility.h"
|
||||
|
@ -168,7 +169,7 @@ void HWFlat::SetupLights(HWDrawInfo *di, FLightNode * node, FDynLightData &light
|
|||
}
|
||||
|
||||
p.Set(plane.plane.Normal(), plane.plane.fD());
|
||||
draw_dlightf += lightdata.GetLight(portalgroup, p, light, false);
|
||||
draw_dlightf += GetLight(lightdata, portalgroup, p, light, false);
|
||||
node = node->nextLight;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ CCMD(gl_portalinfo)
|
|||
}
|
||||
|
||||
static FString indent;
|
||||
FPortalSceneState portalState;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
|
|
|
@ -128,6 +128,8 @@ struct FPortalSceneState
|
|||
void RenderPortal(HWPortal *p, FRenderState &state, bool usestencil, HWDrawInfo *outer_di);
|
||||
};
|
||||
|
||||
extern FPortalSceneState portalState;
|
||||
|
||||
|
||||
class HWScenePortalBase : public HWPortal
|
||||
{
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
*/
|
||||
|
||||
#include "a_sharedglobal.h"
|
||||
#include "a_dynlight.h"
|
||||
#include "r_utility.h"
|
||||
#include "r_sky.h"
|
||||
#include "g_levellocals.h"
|
||||
|
@ -128,7 +129,7 @@ int HWDrawInfo::SetupLightsForOtherPlane(subsector_t * sub, FDynLightData &light
|
|||
iter_dlightf++;
|
||||
|
||||
p.Set(plane->Normal(), plane->fD());
|
||||
draw_dlightf += lightdata.GetLight(sub->sector->PortalGroup, p, light, true);
|
||||
draw_dlightf += GetLight(lightdata, sub->sector->PortalGroup, p, light, true);
|
||||
node = node->nextLight;
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ void HWDrawInfo::SetFog(FRenderState &state, int lightlevel, int rellight, bool
|
|||
}
|
||||
|
||||
// Make fog a little denser when inside a skybox
|
||||
if (screen->mPortalState->inskybox) fogdensity += fogdensity / 2;
|
||||
if (portalState.inskybox) fogdensity += fogdensity / 2;
|
||||
|
||||
|
||||
// no fog in enhanced vision modes!
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
*/
|
||||
|
||||
#include "c_dispatch.h"
|
||||
#include "a_dynlight.h"
|
||||
#include "p_local.h"
|
||||
#include "p_effect.h"
|
||||
#include "g_level.h"
|
||||
|
@ -34,6 +35,7 @@
|
|||
#include "hwrenderer/dynlights/hw_dynlightdata.h"
|
||||
#include "hwrenderer/dynlights/hw_shadowmap.h"
|
||||
#include "hwrenderer/scene/hw_drawinfo.h"
|
||||
#include "hwrenderer/scene/hw_drawstructs.h"
|
||||
#include "r_data/models/models.h"
|
||||
|
||||
template<class T>
|
||||
|
@ -182,7 +184,7 @@ void hw_GetDynModelLight(AActor *self, FDynLightData &modellightdata)
|
|||
{
|
||||
if (std::find(addedLights.begin(), addedLights.end(), light) == addedLights.end()) // Check if we already added this light from a different subsector
|
||||
{
|
||||
modellightdata.AddLightToList(group, light, true);
|
||||
AddLightToList(modellightdata, group, light, true);
|
||||
addedLights.Push(light);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "p_local.h"
|
||||
#include "p_lnspec.h"
|
||||
#include "a_dynlight.h"
|
||||
#include "a_sharedglobal.h"
|
||||
#include "r_defs.h"
|
||||
#include "r_sky.h"
|
||||
|
@ -412,7 +413,7 @@ void HWWall::SetupLights(HWDrawInfo *di, FDynLightData &lightdata)
|
|||
}
|
||||
if (outcnt[0]!=4 && outcnt[1]!=4 && outcnt[2]!=4 && outcnt[3]!=4)
|
||||
{
|
||||
draw_dlight += lightdata.GetLight(seg->frontsector->PortalGroup, p, node->lightsource, true);
|
||||
draw_dlight += GetLight(lightdata, seg->frontsector->PortalGroup, p, node->lightsource, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -497,7 +498,6 @@ void HWWall::PutWall(HWDrawInfo *di, bool translucent)
|
|||
|
||||
void HWWall::PutPortal(HWDrawInfo *di, int ptype, int plane)
|
||||
{
|
||||
auto pstate = screen->mPortalState;
|
||||
HWPortal * portal = nullptr;
|
||||
|
||||
MakeVertices(di, false);
|
||||
|
@ -506,11 +506,11 @@ void HWWall::PutPortal(HWDrawInfo *di, int ptype, int plane)
|
|||
// portals don't go into the draw list.
|
||||
// Instead they are added to the portal manager
|
||||
case PORTALTYPE_HORIZON:
|
||||
horizon = pstate->UniqueHorizons.Get(horizon);
|
||||
horizon = portalState.UniqueHorizons.Get(horizon);
|
||||
portal = di->FindPortal(horizon);
|
||||
if (!portal)
|
||||
{
|
||||
portal = new HWHorizonPortal(pstate, horizon, di->Viewpoint);
|
||||
portal = new HWHorizonPortal(&portalState, horizon, di->Viewpoint);
|
||||
di->Portals.Push(portal);
|
||||
}
|
||||
portal->AddLine(this);
|
||||
|
@ -521,10 +521,10 @@ void HWWall::PutPortal(HWDrawInfo *di, int ptype, int plane)
|
|||
if (!portal)
|
||||
{
|
||||
// either a regular skybox or an Eternity-style horizon
|
||||
if (secportal->mType != PORTS_SKYVIEWPOINT) portal = new HWEEHorizonPortal(pstate, secportal);
|
||||
if (secportal->mType != PORTS_SKYVIEWPOINT) portal = new HWEEHorizonPortal(&portalState, secportal);
|
||||
else
|
||||
{
|
||||
portal = new HWSkyboxPortal(pstate, secportal);
|
||||
portal = new HWSkyboxPortal(&portalState, secportal);
|
||||
di->Portals.Push(portal);
|
||||
}
|
||||
}
|
||||
|
@ -535,20 +535,20 @@ void HWWall::PutPortal(HWDrawInfo *di, int ptype, int plane)
|
|||
portal = di->FindPortal(this->portal);
|
||||
if (!portal)
|
||||
{
|
||||
portal = new HWSectorStackPortal(pstate, this->portal);
|
||||
portal = new HWSectorStackPortal(&portalState, this->portal);
|
||||
di->Portals.Push(portal);
|
||||
}
|
||||
portal->AddLine(this);
|
||||
break;
|
||||
|
||||
case PORTALTYPE_PLANEMIRROR:
|
||||
if (pstate->PlaneMirrorMode * planemirror->fC() <= 0)
|
||||
if (portalState.PlaneMirrorMode * planemirror->fC() <= 0)
|
||||
{
|
||||
planemirror = pstate->UniquePlaneMirrors.Get(planemirror);
|
||||
planemirror = portalState.UniquePlaneMirrors.Get(planemirror);
|
||||
portal = di->FindPortal(planemirror);
|
||||
if (!portal)
|
||||
{
|
||||
portal = new HWPlaneMirrorPortal(pstate, planemirror);
|
||||
portal = new HWPlaneMirrorPortal(&portalState, planemirror);
|
||||
di->Portals.Push(portal);
|
||||
}
|
||||
portal->AddLine(this);
|
||||
|
@ -559,7 +559,7 @@ void HWWall::PutPortal(HWDrawInfo *di, int ptype, int plane)
|
|||
portal = di->FindPortal(seg->linedef);
|
||||
if (!portal)
|
||||
{
|
||||
portal = new HWMirrorPortal(pstate, seg->linedef);
|
||||
portal = new HWMirrorPortal(&portalState, seg->linedef);
|
||||
di->Portals.Push(portal);
|
||||
}
|
||||
portal->AddLine(this);
|
||||
|
@ -581,18 +581,18 @@ void HWWall::PutPortal(HWDrawInfo *di, int ptype, int plane)
|
|||
{
|
||||
di->ProcessActorsInPortal(otherside->getPortal()->mGroup, di->in_area);
|
||||
}
|
||||
portal = new HWLineToLinePortal(pstate, lineportal);
|
||||
portal = new HWLineToLinePortal(&portalState, lineportal);
|
||||
di->Portals.Push(portal);
|
||||
}
|
||||
portal->AddLine(this);
|
||||
break;
|
||||
|
||||
case PORTALTYPE_SKY:
|
||||
sky = pstate->UniqueSkies.Get(sky);
|
||||
sky = portalState.UniqueSkies.Get(sky);
|
||||
portal = di->FindPortal(sky);
|
||||
if (!portal)
|
||||
{
|
||||
portal = new HWSkyPortal(screen->mSkyData, pstate, sky);
|
||||
portal = new HWSkyPortal(screen->mSkyData, &portalState, sky);
|
||||
di->Portals.Push(portal);
|
||||
}
|
||||
portal->AddLine(this);
|
||||
|
|
Loading…
Reference in a new issue