- continued reorganization of GLWall.

This commit is contained in:
Christoph Oelckers 2018-04-26 07:07:46 +02:00
parent 1ae6ad2a82
commit 6e58f72329
3 changed files with 44 additions and 32 deletions

View file

@ -21,12 +21,9 @@
//
#include "gl/system/gl_system.h"
#include "gl/renderer/gl_renderer.h"
#include "gl/data/gl_vertexbuffer.h"
#include "gl/scene/gl_drawinfo.h"
#include "r_defs.h"
#include "hwrenderer/data/flatvertices.h"
#include "gl/scene/gl_wall.h"
EXTERN_CVAR(Bool, gl_seamless)
@ -170,3 +167,26 @@ void GLWall::SplitRightEdge(FFlatVertex *&ptr)
}
}
//==========================================================================
//
// Create vertices for one wall
//
//==========================================================================
void GLWall::CreateVertices(FFlatVertex *&ptr, bool nosplit)
{
bool split = (gl_seamless && !nosplit && seg->sidedef != nullptr && !(seg->sidedef->Flags & WALLF_POLYOBJ) && !(flags & GLWF_NOSPLIT));
ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[LOLFT].u, tcs[LOLFT].v);
ptr++;
if (split && glseg.fracleft == 0) SplitLeftEdge(ptr);
ptr->Set(glseg.x1, ztop[0], glseg.y1, tcs[UPLFT].u, tcs[UPLFT].v);
ptr++;
if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(ptr);
ptr->Set(glseg.x2, ztop[1], glseg.y2, tcs[UPRGT].u, tcs[UPRGT].v);
ptr++;
if (split && glseg.fracright == 1) SplitRightEdge(ptr);
ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[LORGT].u, tcs[LORGT].v);
ptr++;
if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(ptr);
}

View file

@ -10,6 +10,8 @@
#include "textures/textures.h"
#include "gl/renderer/gl_colormap.h"
#pragma warning(disable:4244)
struct GLHorizonInfo;
struct F3DFloor;
struct model_t;
@ -24,6 +26,7 @@ struct FSectorPortalGroup;
struct FFlatVertex;
struct FLinePortalSpan;
class GLSceneDrawer;
struct FDynLightData;
enum
{
@ -207,7 +210,7 @@ private:
bool SplitWallComplex(HWDrawInfo *di, sector_t * frontsector, bool translucent, float& maplightbottomleft, float& maplightbottomright);
void SplitWall(HWDrawInfo *di, sector_t * frontsector, bool translucent);
void SetupLights();
bool SetupLights(FDynLightData &lightdata);
void MakeVertices(bool nosplit);
void RenderWall(int textured);
void RenderTextured(int rflags);
@ -257,6 +260,7 @@ private:
void RenderMirrorSurface();
void RenderTranslucentWall();
void CreateVertices(FFlatVertex *&ptr, bool nosplit);
void SplitLeftEdge (FFlatVertex *&ptr);
void SplitRightEdge(FFlatVertex *&ptr);
void SplitUpperEdge(FFlatVertex *&ptr);

View file

@ -42,17 +42,17 @@
EXTERN_CVAR(Bool, gl_seamless)
FDynLightData lightdata;
//==========================================================================
//
// Collect lights for shader
//
//==========================================================================
FDynLightData lightdata;
void GLWall::SetupLights()
bool GLWall::SetupLights(FDynLightData &lightdata)
{
if (RenderStyle == STYLE_Add && !level.lightadditivesurfaces) return; // no lights on additively blended surfaces.
if (RenderStyle == STYLE_Add && !level.lightadditivesurfaces) return false; // 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)
@ -60,7 +60,7 @@ void GLWall::SetupLights()
case RENDERWALL_FOGBOUNDARY:
case RENDERWALL_MIRRORSURFACE:
case RENDERWALL_COLOR:
return;
return false;
}
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};
@ -141,8 +141,7 @@ void GLWall::SetupLights()
}
node = node->nextLight;
}
dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
return true;
}
//==========================================================================
@ -155,22 +154,8 @@ void GLWall::MakeVertices(bool nosplit)
{
if (vertcount == 0)
{
bool split = (gl_seamless && !nosplit && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ) && !(flags & GLWF_NOSPLIT));
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[LOLFT].u, tcs[LOLFT].v);
ptr++;
if (split && glseg.fracleft == 0) SplitLeftEdge(ptr);
ptr->Set(glseg.x1, ztop[0], glseg.y1, tcs[UPLFT].u, tcs[UPLFT].v);
ptr++;
if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(ptr);
ptr->Set(glseg.x2, ztop[1], glseg.y2, tcs[UPRGT].u, tcs[UPRGT].v);
ptr++;
if (split && glseg.fracright == 1) SplitRightEdge(ptr);
ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[LORGT].u, tcs[LORGT].v);
ptr++;
if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(ptr);
CreateVertices(ptr, nosplit);
vertcount = GLRenderer->mVBO->GetCount(ptr, &vertindex);
}
}
@ -389,7 +374,8 @@ void GLWall::RenderTranslucentWall()
{
if (mDrawer->FixedColormap == CM_DEFAULT && gl_lights && gl.lightmethod == LM_DIRECT)
{
SetupLights();
if (SetupLights(lightdata))
dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
}
if (!gltexture->tex->GetTranslucency()) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold);
else gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
@ -419,11 +405,13 @@ void GLWall::Draw(int pass)
switch (pass)
{
case GLPASS_LIGHTSONLY:
SetupLights();
if (SetupLights(lightdata))
dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
break;
case GLPASS_ALL:
SetupLights();
if (SetupLights(lightdata))
dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
// fall through
case GLPASS_PLAIN:
RenderTextured(RWF_TEXTURED);