From 790182a2f433abf4ec636b6be8f2528499dfe526 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 14 Apr 2018 20:20:43 +0200 Subject: [PATCH] - split GLWall::PutWall in two. --- src/gl/compatibility/gl_20.cpp | 20 +++---- src/gl/scene/gl_drawinfo.h | 3 ++ src/gl/scene/gl_wall.h | 11 ++-- src/gl/scene/gl_walls.cpp | 98 ++++++++++++++++++---------------- 4 files changed, 73 insertions(+), 59 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 28ceb6be6..ea32d58c2 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -534,32 +534,32 @@ static bool gl_CheckFog(FColormap *cm, int lightlevel) // //========================================================================== -bool GLWall::PutWallCompat(int passflag) +bool FDrawInfo::PutWallCompat(GLWall *wall, int passflag) { static int list_indices[2][2] = { { GLLDL_WALLS_PLAIN, GLLDL_WALLS_FOG },{ GLLDL_WALLS_MASKED, GLLDL_WALLS_FOGMASKED } }; // are lights possible? - if (mDrawer->FixedColormap != CM_DEFAULT || !gl_lights || seg->sidedef == nullptr || type == RENDERWALL_M2SNF || !gltexture) return false; + if (mDrawer->FixedColormap != CM_DEFAULT || !gl_lights || wall->seg->sidedef == nullptr || wall->type == RENDERWALL_M2SNF || !wall->gltexture) return false; // multipassing these is problematic. - if ((flags&GLWF_SKYHACK && type == RENDERWALL_M2S)) return false; + if ((wall->flags & GLWall::GLWF_SKYHACK && wall->type == RENDERWALL_M2S)) return false; // Any lights affecting this wall? - if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + if (!(wall->seg->sidedef->Flags & WALLF_POLYOBJ)) { - if (seg->sidedef->lighthead == nullptr) return false; + if (wall->seg->sidedef->lighthead == nullptr) return false; } - else if (sub) + else if (wall->sub) { - if (sub->lighthead == nullptr) return false; + if (wall->sub->lighthead == nullptr) return false; } - bool foggy = gl_CheckFog(&Colormap, lightlevel) || (level.flags&LEVEL_HASFADETABLE) || gl_lights_additive; - bool masked = passflag == 2 && gltexture->isMasked(); + bool foggy = gl_CheckFog(&wall->Colormap, wall->lightlevel) || (level.flags&LEVEL_HASFADETABLE) || gl_lights_additive; + bool masked = passflag == 2 && wall->gltexture->isMasked(); int list = list_indices[masked][foggy]; - gl_drawinfo->dldrawlists[list].AddWall(this); + dldrawlists[list].AddWall(wall); return true; } diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index eb2faaa52..0c2607632 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -236,6 +236,9 @@ struct FDrawInfo ~FDrawInfo(); void ClearBuffers(); + void AddWall(GLWall *wall); + bool PutWallCompat(GLWall *wall, int passflag); // Legacy GL only. + bool DoOneSectorUpper(subsector_t * subsec, float planez); bool DoOneSectorLower(subsector_t * subsec, float planez); bool DoFakeBridge(subsector_t * subsec, float planez); diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 7151b1809..a2fa33eca 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -106,10 +106,13 @@ struct GLSectorPlane } }; +class FDrawInfo; class GLWall { + friend class FDrawInfo; public: + static const char passflag[]; enum { @@ -120,6 +123,7 @@ public: GLWF_NOSPLITUPPER=16, GLWF_NOSPLITLOWER=32, GLWF_NOSPLIT=64, + GLWF_TRANSLUCENT = 128 }; enum @@ -142,19 +146,20 @@ public: friend class GLPortal; GLSceneDrawer *mDrawer; - GLSeg glseg; vertex_t * vertexes[2]; // required for polygon splitting + FMaterial *gltexture; + TArray *lightlist; + + GLSeg glseg; float ztop[2],zbottom[2]; texcoord tcs[4]; float alpha; - FMaterial *gltexture; FColormap Colormap; ERenderStyle RenderStyle; float ViewDistance; - TArray *lightlist; int lightlevel; uint8_t type; uint8_t flags; diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index b7eb40393..919ce374c 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -46,6 +46,56 @@ #include "gl/shaders/gl_shader.h" +void FDrawInfo::AddWall(GLWall *wall) +{ + bool translucent = !!(wall->flags & GLWall::GLWF_TRANSLUCENT); + int list; + + if (translucent) // translucent walls + { + wall->ViewDistance = (r_viewpoint.Pos - (wall->seg->linedef->v1->fPos() + wall->seg->linedef->Delta() / 2)).XY().LengthSquared(); + if (gl.buffermethod == BM_DEFERRED) wall->MakeVertices(true); + drawlists[GLDL_TRANSLUCENT].AddWall(wall); + } + else + { + if (gl.legacyMode) + { + if (PutWallCompat(wall, GLWall::passflag[wall->type])) return; + } + + bool masked; + + masked = GLWall::passflag[wall->type] == 1 ? false : (wall->gltexture && wall->gltexture->isMasked()); + + if ((wall->flags & GLWall::GLWF_SKYHACK && wall->type == RENDERWALL_M2S)) + { + list = GLDL_MASKEDWALLSOFS; + } + else + { + list = masked ? GLDL_MASKEDWALLS : GLDL_PLAINWALLS; + } + if (gl.buffermethod == BM_DEFERRED) wall->MakeVertices(false); + drawlists[list].AddWall(wall); + + } +} + + +const char GLWall::passflag[] = { + 0, //RENDERWALL_NONE, + 1, //RENDERWALL_TOP, // unmasked + 1, //RENDERWALL_M1S, // unmasked + 2, //RENDERWALL_M2S, // depends on render and texture settings + 1, //RENDERWALL_BOTTOM, // unmasked + 3, //RENDERWALL_FOGBOUNDARY, // translucent + 1, //RENDERWALL_MIRRORSURFACE, // only created from PORTALTYPE_MIRROR + 2, //RENDERWALL_M2SNF, // depends on render and texture settings, no fog, used on mid texture lines with a fog boundary. + 3, //RENDERWALL_COLOR, // translucent + 2, //RENDERWALL_FFBLOCK // depends on render and texture settings +}; + //========================================================================== // // @@ -53,26 +103,11 @@ //========================================================================== void GLWall::PutWall(bool translucent) { - int list; - - static char passflag[] = { - 0, //RENDERWALL_NONE, - 1, //RENDERWALL_TOP, // unmasked - 1, //RENDERWALL_M1S, // unmasked - 2, //RENDERWALL_M2S, // depends on render and texture settings - 1, //RENDERWALL_BOTTOM, // unmasked - 3, //RENDERWALL_FOGBOUNDARY, // translucent - 1, //RENDERWALL_MIRRORSURFACE, // only created from PORTALTYPE_MIRROR - 2, //RENDERWALL_M2SNF, // depends on render and texture settings, no fog, used on mid texture lines with a fog boundary. - 3, //RENDERWALL_COLOR, // translucent - 2, //RENDERWALL_FFBLOCK // depends on render and texture settings - }; - - if (gltexture && gltexture->tex->GetTranslucency() && passflag[type] == 2) { translucent = true; } + if (translucent) flags |= GLWF_TRANSLUCENT; if (mDrawer->FixedColormap) { @@ -81,36 +116,7 @@ void GLWall::PutWall(bool translucent) Colormap.Clear(); } if (mDrawer->isFullbright(Colormap.LightColor, lightlevel)) flags &= ~GLWF_GLOW; - - if (translucent) // translucent walls - { - ViewDistance = (r_viewpoint.Pos - (seg->linedef->v1->fPos() + seg->linedef->Delta() / 2)).XY().LengthSquared(); - if (gl.buffermethod == BM_DEFERRED) MakeVertices(true); - gl_drawinfo->drawlists[GLDL_TRANSLUCENT].AddWall(this); - } - else - { - if (gl.legacyMode && !translucent) - { - if (PutWallCompat(passflag[type])) return; - } - - bool masked; - - masked = passflag[type] == 1 ? false : (gltexture && gltexture->isMasked()); - - if ((flags&GLWF_SKYHACK && type == RENDERWALL_M2S)) - { - list = GLDL_MASKEDWALLSOFS; - } - else - { - list = masked ? GLDL_MASKEDWALLS : GLDL_PLAINWALLS; - } - if (gl.buffermethod == BM_DEFERRED) MakeVertices(false); - gl_drawinfo->drawlists[list].AddWall(this); - - } + gl_drawinfo->AddWall(this); lightlist = NULL; vertcount = 0; // make sure that following parts of the same linedef do not get this one's vertex info. }