From e309fd1f3d8fe16efff48c9e8869f7a9197932ab Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 3 May 2018 22:14:25 +0200 Subject: [PATCH] - moved a bit more of the wall setup to the API independent side. --- src/gl/scene/gl_walls_draw.cpp | 27 ++--------------- src/hwrenderer/scene/hw_drawstructs.h | 2 +- src/hwrenderer/scene/hw_walls.cpp | 43 ++++++++++++++++++++------- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 19d97ac000..4ab11868f5 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -303,19 +303,8 @@ void FDrawInfo::DrawWall(GLWall *wall, int pass) void FDrawInfo::AddWall(GLWall *wall) { - bool translucent = !!(wall->flags & GLWall::GLWF_TRANSLUCENT); - int list; - - wall->MakeVertices(this, translucent); - - if (translucent) // translucent walls + if (wall->flags & GLWall::GLWF_TRANSLUCENT) { - if (!gl.legacyMode && mDrawer->FixedColormap == CM_DEFAULT && wall->gltexture != nullptr) - { - if (wall->SetupLights(lightdata)) - wall->dynlightindex = GLRenderer->mLights->UploadLights(lightdata); - } - wall->ViewDistance = (r_viewpoint.Pos - (wall->seg->linedef->v1->fPos() + wall->seg->linedef->Delta() / 2)).XY().LengthSquared(); auto newwall = drawlists[GLDL_TRANSLUCENT].NewWall(); *newwall = *wall; } @@ -325,16 +314,9 @@ void FDrawInfo::AddWall(GLWall *wall) { if (PutWallCompat(wall, GLWall::passflag[wall->type])) return; } - else if (mDrawer->FixedColormap == CM_DEFAULT) - { - if (wall->SetupLights(lightdata)) - wall->dynlightindex = GLRenderer->mLights->UploadLights(lightdata); - } - - bool masked; - - masked = GLWall::passflag[wall->type] == 1 ? false : (wall->gltexture && wall->gltexture->isMasked()); + bool masked = GLWall::passflag[wall->type] == 1 ? false : (wall->gltexture && wall->gltexture->isMasked()); + int list; if ((wall->flags & GLWall::GLWF_SKYHACK && wall->type == RENDERWALL_M2S)) { @@ -346,10 +328,7 @@ void FDrawInfo::AddWall(GLWall *wall) } auto newwall = drawlists[list].NewWall(); *newwall = *wall; - if (!masked) newwall->ProcessDecals(this); } - wall->dynlightindex = -1; - wall->vertcount = 0; } //========================================================================== diff --git a/src/hwrenderer/scene/hw_drawstructs.h b/src/hwrenderer/scene/hw_drawstructs.h index b70db68fb7..7aa7e0b7df 100644 --- a/src/hwrenderer/scene/hw_drawstructs.h +++ b/src/hwrenderer/scene/hw_drawstructs.h @@ -205,7 +205,7 @@ public: bool SplitWallComplex(HWDrawInfo *di, sector_t * frontsector, bool translucent, float& maplightbottomleft, float& maplightbottomright); void SplitWall(HWDrawInfo *di, sector_t * frontsector, bool translucent); - bool SetupLights(FDynLightData &lightdata); + void SetupLights(HWDrawInfo *di, FDynLightData &lightdata); void MakeVertices(HWDrawInfo *di, bool nosplit); diff --git a/src/hwrenderer/scene/hw_walls.cpp b/src/hwrenderer/scene/hw_walls.cpp index 16e144d3ec..de3a786e42 100644 --- a/src/hwrenderer/scene/hw_walls.cpp +++ b/src/hwrenderer/scene/hw_walls.cpp @@ -46,10 +46,12 @@ // //========================================================================== -bool GLWall::SetupLights(FDynLightData &lightdata) +void GLWall::SetupLights(HWDrawInfo *di, FDynLightData &lightdata) { - if (screen->hwcaps & RFL_NO_SHADERS) return false; // useless in OpenGL 2. - if (RenderStyle == STYLE_Add && !level.lightadditivesurfaces) return false; // no lights on additively blended surfaces. + lightdata.Clear(); + + if (screen->hwcaps & RFL_NO_SHADERS) return; // useless in OpenGL 2. + if (RenderStyle == STYLE_Add && !level.lightadditivesurfaces) return; // no lights on additively blended surfaces. // check for wall types which cannot have dynamic lights on them (portal types never get here so they don't need to be checked.) switch (type) @@ -57,13 +59,12 @@ bool GLWall::SetupLights(FDynLightData &lightdata) case RENDERWALL_FOGBOUNDARY: case RENDERWALL_MIRRORSURFACE: case RENDERWALL_COLOR: - return false; + return; } float vtx[]={glseg.x1,zbottom[0],glseg.y1, glseg.x1,ztop[0],glseg.y1, glseg.x2,ztop[1],glseg.y2, glseg.x2,zbottom[1],glseg.y2}; Plane p; - lightdata.Clear(); auto normal = glseg.Normal(); p.Set(normal, -normal.X * glseg.x1 - normal.Z * glseg.y1); @@ -138,7 +139,7 @@ bool GLWall::SetupLights(FDynLightData &lightdata) } node = node->nextLight; } - return true; + dynlightindex = di->UploadLights(lightdata); } @@ -166,8 +167,12 @@ void GLWall::PutWall(HWDrawInfo *di, bool translucent) { translucent = true; } - if (translucent) flags |= GLWF_TRANSLUCENT; - + if (translucent) + { + flags |= GLWF_TRANSLUCENT; + ViewDistance = (r_viewpoint.Pos - (seg->linedef->v1->fPos() + seg->linedef->Delta() / 2)).XY().LengthSquared(); + } + if (di->FixedColormap) { // light planes don't get drawn with fullbright rendering @@ -178,9 +183,25 @@ void GLWall::PutWall(HWDrawInfo *di, bool translucent) if (di->FixedColormap != CM_DEFAULT || (Colormap.LightColor.isWhite() && lightlevel == 255)) flags &= ~GLWF_GLOW; - di->AddWall(this); - lightlist = NULL; - vertcount = 0; // make sure that following parts of the same linedef do not get this one's vertex info. + if (level.HasDynamicLights && di->FixedColormap == CM_DEFAULT && gltexture != nullptr && !(screen->hwcaps & RFL_NO_SHADERS)) + { + SetupLights(di, lightdata); + } + MakeVertices(di, translucent); + + + bool solid; + if (passflag[type] == 1) solid = true; + else if (type == RENDERWALL_FFBLOCK) solid = (gltexture && gltexture->isMasked()); + else solid = false; + if (solid) ProcessDecals(di); + + di->AddWall(this); + + lightlist = nullptr; + // make sure that following parts of the same linedef do not get this one's vertex and lighting info. + vertcount = 0; + dynlightindex = -1; } void GLWall::PutPortal(HWDrawInfo *di, int ptype)