- 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 "r_defs.h"
#include "gl/system/gl_system.h" #include "hwrenderer/data/flatvertices.h"
#include "gl/scene/gl_wall.h"
#include "gl/renderer/gl_renderer.h"
#include "gl/data/gl_vertexbuffer.h"
#include "gl/scene/gl_drawinfo.h"
EXTERN_CVAR(Bool, gl_seamless) 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 "textures/textures.h"
#include "gl/renderer/gl_colormap.h" #include "gl/renderer/gl_colormap.h"
#pragma warning(disable:4244)
struct GLHorizonInfo; struct GLHorizonInfo;
struct F3DFloor; struct F3DFloor;
struct model_t; struct model_t;
@ -24,6 +26,7 @@ struct FSectorPortalGroup;
struct FFlatVertex; struct FFlatVertex;
struct FLinePortalSpan; struct FLinePortalSpan;
class GLSceneDrawer; class GLSceneDrawer;
struct FDynLightData;
enum enum
{ {
@ -207,7 +210,7 @@ private:
bool SplitWallComplex(HWDrawInfo *di, sector_t * frontsector, bool translucent, float& maplightbottomleft, float& maplightbottomright); bool SplitWallComplex(HWDrawInfo *di, sector_t * frontsector, bool translucent, float& maplightbottomleft, float& maplightbottomright);
void SplitWall(HWDrawInfo *di, sector_t * frontsector, bool translucent); void SplitWall(HWDrawInfo *di, sector_t * frontsector, bool translucent);
void SetupLights(); bool SetupLights(FDynLightData &lightdata);
void MakeVertices(bool nosplit); void MakeVertices(bool nosplit);
void RenderWall(int textured); void RenderWall(int textured);
void RenderTextured(int rflags); void RenderTextured(int rflags);
@ -257,6 +260,7 @@ private:
void RenderMirrorSurface(); void RenderMirrorSurface();
void RenderTranslucentWall(); void RenderTranslucentWall();
void CreateVertices(FFlatVertex *&ptr, bool nosplit);
void SplitLeftEdge (FFlatVertex *&ptr); void SplitLeftEdge (FFlatVertex *&ptr);
void SplitRightEdge(FFlatVertex *&ptr); void SplitRightEdge(FFlatVertex *&ptr);
void SplitUpperEdge(FFlatVertex *&ptr); void SplitUpperEdge(FFlatVertex *&ptr);

View file

@ -42,17 +42,17 @@
EXTERN_CVAR(Bool, gl_seamless) EXTERN_CVAR(Bool, gl_seamless)
FDynLightData lightdata;
//========================================================================== //==========================================================================
// //
// Collect lights for shader // Collect lights for shader
// //
//========================================================================== //==========================================================================
FDynLightData lightdata;
bool GLWall::SetupLights(FDynLightData &lightdata)
void GLWall::SetupLights()
{ {
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.) // 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) switch (type)
@ -60,7 +60,7 @@ void GLWall::SetupLights()
case RENDERWALL_FOGBOUNDARY: case RENDERWALL_FOGBOUNDARY:
case RENDERWALL_MIRRORSURFACE: case RENDERWALL_MIRRORSURFACE:
case RENDERWALL_COLOR: 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}; 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; node = node->nextLight;
} }
return true;
dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
} }
//========================================================================== //==========================================================================
@ -155,22 +154,8 @@ void GLWall::MakeVertices(bool nosplit)
{ {
if (vertcount == 0) if (vertcount == 0)
{ {
bool split = (gl_seamless && !nosplit && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ) && !(flags & GLWF_NOSPLIT));
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
CreateVertices(ptr, 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);
vertcount = GLRenderer->mVBO->GetCount(ptr, &vertindex); vertcount = GLRenderer->mVBO->GetCount(ptr, &vertindex);
} }
} }
@ -389,7 +374,8 @@ void GLWall::RenderTranslucentWall()
{ {
if (mDrawer->FixedColormap == CM_DEFAULT && gl_lights && gl.lightmethod == LM_DIRECT) 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); if (!gltexture->tex->GetTranslucency()) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold);
else gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); else gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
@ -419,11 +405,13 @@ void GLWall::Draw(int pass)
switch (pass) switch (pass)
{ {
case GLPASS_LIGHTSONLY: case GLPASS_LIGHTSONLY:
SetupLights(); if (SetupLights(lightdata))
dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
break; break;
case GLPASS_ALL: case GLPASS_ALL:
SetupLights(); if (SetupLights(lightdata))
dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
// fall through // fall through
case GLPASS_PLAIN: case GLPASS_PLAIN:
RenderTextured(RWF_TEXTURED); RenderTextured(RWF_TEXTURED);