- split GLWall::PutWall in two.

This commit is contained in:
Christoph Oelckers 2018-04-14 20:20:43 +02:00
parent 59a08ce0df
commit 790182a2f4
4 changed files with 73 additions and 59 deletions

View file

@ -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] = static int list_indices[2][2] =
{ { GLLDL_WALLS_PLAIN, GLLDL_WALLS_FOG },{ GLLDL_WALLS_MASKED, GLLDL_WALLS_FOGMASKED } }; { { GLLDL_WALLS_PLAIN, GLLDL_WALLS_FOG },{ GLLDL_WALLS_MASKED, GLLDL_WALLS_FOGMASKED } };
// are lights possible? // 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. // 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? // 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 foggy = gl_CheckFog(&wall->Colormap, wall->lightlevel) || (level.flags&LEVEL_HASFADETABLE) || gl_lights_additive;
bool masked = passflag == 2 && gltexture->isMasked(); bool masked = passflag == 2 && wall->gltexture->isMasked();
int list = list_indices[masked][foggy]; int list = list_indices[masked][foggy];
gl_drawinfo->dldrawlists[list].AddWall(this); dldrawlists[list].AddWall(wall);
return true; return true;
} }

View file

@ -236,6 +236,9 @@ struct FDrawInfo
~FDrawInfo(); ~FDrawInfo();
void ClearBuffers(); void ClearBuffers();
void AddWall(GLWall *wall);
bool PutWallCompat(GLWall *wall, int passflag); // Legacy GL only.
bool DoOneSectorUpper(subsector_t * subsec, float planez); bool DoOneSectorUpper(subsector_t * subsec, float planez);
bool DoOneSectorLower(subsector_t * subsec, float planez); bool DoOneSectorLower(subsector_t * subsec, float planez);
bool DoFakeBridge(subsector_t * subsec, float planez); bool DoFakeBridge(subsector_t * subsec, float planez);

View file

@ -106,10 +106,13 @@ struct GLSectorPlane
} }
}; };
class FDrawInfo;
class GLWall class GLWall
{ {
friend class FDrawInfo;
public: public:
static const char passflag[];
enum enum
{ {
@ -120,6 +123,7 @@ public:
GLWF_NOSPLITUPPER=16, GLWF_NOSPLITUPPER=16,
GLWF_NOSPLITLOWER=32, GLWF_NOSPLITLOWER=32,
GLWF_NOSPLIT=64, GLWF_NOSPLIT=64,
GLWF_TRANSLUCENT = 128
}; };
enum enum
@ -142,19 +146,20 @@ public:
friend class GLPortal; friend class GLPortal;
GLSceneDrawer *mDrawer; GLSceneDrawer *mDrawer;
GLSeg glseg;
vertex_t * vertexes[2]; // required for polygon splitting vertex_t * vertexes[2]; // required for polygon splitting
FMaterial *gltexture;
TArray<lightlist_t> *lightlist;
GLSeg glseg;
float ztop[2],zbottom[2]; float ztop[2],zbottom[2];
texcoord tcs[4]; texcoord tcs[4];
float alpha; float alpha;
FMaterial *gltexture;
FColormap Colormap; FColormap Colormap;
ERenderStyle RenderStyle; ERenderStyle RenderStyle;
float ViewDistance; float ViewDistance;
TArray<lightlist_t> *lightlist;
int lightlevel; int lightlevel;
uint8_t type; uint8_t type;
uint8_t flags; uint8_t flags;

View file

@ -46,16 +46,44 @@
#include "gl/shaders/gl_shader.h" #include "gl/shaders/gl_shader.h"
//========================================================================== void FDrawInfo::AddWall(GLWall *wall)
//
//
//
//==========================================================================
void GLWall::PutWall(bool translucent)
{ {
bool translucent = !!(wall->flags & GLWall::GLWF_TRANSLUCENT);
int list; int list;
static char passflag[] = { 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, 0, //RENDERWALL_NONE,
1, //RENDERWALL_TOP, // unmasked 1, //RENDERWALL_TOP, // unmasked
1, //RENDERWALL_M1S, // unmasked 1, //RENDERWALL_M1S, // unmasked
@ -68,11 +96,18 @@ void GLWall::PutWall(bool translucent)
2, //RENDERWALL_FFBLOCK // depends on render and texture settings 2, //RENDERWALL_FFBLOCK // depends on render and texture settings
}; };
//==========================================================================
//
//
//
//==========================================================================
void GLWall::PutWall(bool translucent)
{
if (gltexture && gltexture->tex->GetTranslucency() && passflag[type] == 2) if (gltexture && gltexture->tex->GetTranslucency() && passflag[type] == 2)
{ {
translucent = true; translucent = true;
} }
if (translucent) flags |= GLWF_TRANSLUCENT;
if (mDrawer->FixedColormap) if (mDrawer->FixedColormap)
{ {
@ -81,36 +116,7 @@ void GLWall::PutWall(bool translucent)
Colormap.Clear(); Colormap.Clear();
} }
if (mDrawer->isFullbright(Colormap.LightColor, lightlevel)) flags &= ~GLWF_GLOW; if (mDrawer->isFullbright(Colormap.LightColor, lightlevel)) flags &= ~GLWF_GLOW;
gl_drawinfo->AddWall(this);
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);
}
lightlist = NULL; lightlist = NULL;
vertcount = 0; // make sure that following parts of the same linedef do not get this one's vertex info. vertcount = 0; // make sure that following parts of the same linedef do not get this one's vertex info.
} }