2016-09-14 18:01:13 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Copyright(C) 2000-2016 Christoph Oelckers
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with this program. If not, see http://www.gnu.org/licenses/
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
#include "gl/system/gl_system.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "p_lnspec.h"
|
|
|
|
#include "a_sharedglobal.h"
|
|
|
|
#include "g_level.h"
|
|
|
|
#include "templates.h"
|
|
|
|
#include "vectors.h"
|
|
|
|
#include "r_defs.h"
|
|
|
|
#include "r_sky.h"
|
2016-02-16 21:01:04 +00:00
|
|
|
#include "r_utility.h"
|
|
|
|
#include "p_maputl.h"
|
|
|
|
#include "doomdata.h"
|
2016-02-10 19:49:06 +00:00
|
|
|
#include "portal.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
#include "gl/system/gl_cvars.h"
|
|
|
|
#include "gl/renderer/gl_lightdata.h"
|
|
|
|
#include "gl/data/gl_data.h"
|
|
|
|
#include "gl/dynlights/gl_dynlight.h"
|
|
|
|
#include "gl/dynlights/gl_glow.h"
|
|
|
|
#include "gl/scene/gl_drawinfo.h"
|
|
|
|
#include "gl/scene/gl_portal.h"
|
|
|
|
#include "gl/textures/gl_material.h"
|
|
|
|
#include "gl/utility/gl_clock.h"
|
|
|
|
#include "gl/utility/gl_geometric.h"
|
|
|
|
#include "gl/utility/gl_templates.h"
|
|
|
|
#include "gl/shaders/gl_shader.h"
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Checks whether a wall should glow
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
void GLWall::CheckGlowing()
|
|
|
|
{
|
|
|
|
bottomglowcolor[3] = topglowcolor[3] = 0;
|
2014-06-21 13:50:32 +00:00
|
|
|
if (!gl_isFullbright(Colormap.LightColor, lightlevel))
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
FTexture *tex = TexMan[topflat];
|
|
|
|
if (tex != NULL && tex->isGlowing())
|
|
|
|
{
|
|
|
|
flags |= GLWall::GLWF_GLOW;
|
|
|
|
tex->GetGlowColor(topglowcolor);
|
|
|
|
topglowcolor[3] = tex->gl_info.GlowHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
tex = TexMan[bottomflat];
|
|
|
|
if (tex != NULL && tex->isGlowing())
|
|
|
|
{
|
|
|
|
flags |= GLWall::GLWF_GLOW;
|
|
|
|
tex->GetGlowColor(bottomglowcolor);
|
|
|
|
bottomglowcolor[3] = tex->gl_info.GlowHeight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2016-02-05 00:48:53 +00:00
|
|
|
void GLWall::PutWall(bool translucent)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
int list;
|
|
|
|
|
2016-02-01 00:49:49 +00:00
|
|
|
static char passflag[] = {
|
2013-06-23 07:49:34 +00:00
|
|
|
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
|
2016-02-01 00:49:49 +00:00
|
|
|
1, //RENDERWALL_MIRRORSURFACE, // only created from PORTALTYPE_MIRROR
|
2014-07-15 18:49:21 +00:00
|
|
|
2, //RENDERWALL_M2SNF, // depends on render and texture settings, no fog, used on mid texture lines with a fog boundary.
|
2013-06-23 07:49:34 +00:00
|
|
|
3, //RENDERWALL_COLOR, // translucent
|
|
|
|
2, //RENDERWALL_FFBLOCK // depends on render and texture settings
|
|
|
|
};
|
2016-02-01 00:49:49 +00:00
|
|
|
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
if (gltexture && gltexture->GetTransparent() && passflag[type] == 2)
|
|
|
|
{
|
|
|
|
translucent = true;
|
|
|
|
}
|
|
|
|
|
2016-02-01 00:49:49 +00:00
|
|
|
if (gl_fixedcolormap)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
// light planes don't get drawn with fullbright rendering
|
2016-02-01 00:49:49 +00:00
|
|
|
if (gltexture == NULL) return;
|
2014-05-11 20:57:42 +00:00
|
|
|
Colormap.Clear();
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CheckGlowing();
|
|
|
|
|
|
|
|
if (translucent) // translucent walls
|
|
|
|
{
|
2016-04-02 21:17:16 +00:00
|
|
|
ViewDistance = (ViewPos - (seg->linedef->v1->fPos() + seg->linedef->Delta() / 2)).XY().LengthSquared();
|
2016-08-25 21:13:49 +00:00
|
|
|
if (gl.buffermethod == BM_DEFERRED) MakeVertices(true);
|
2013-06-23 07:49:34 +00:00
|
|
|
gl_drawinfo->drawlists[GLDL_TRANSLUCENT].AddWall(this);
|
|
|
|
}
|
2016-02-01 00:49:49 +00:00
|
|
|
else
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-09-01 09:52:52 +00:00
|
|
|
if (gl.legacyMode && !translucent)
|
2016-05-03 21:28:42 +00:00
|
|
|
{
|
2016-05-04 20:14:39 +00:00
|
|
|
if (PutWallCompat(passflag[type])) return;
|
2016-05-03 21:28:42 +00:00
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
bool masked;
|
|
|
|
|
2016-02-01 00:49:49 +00:00
|
|
|
masked = passflag[type] == 1 ? false : (gltexture && gltexture->isMasked());
|
2014-07-15 19:16:59 +00:00
|
|
|
|
|
|
|
if ((flags&GLWF_SKYHACK && type == RENDERWALL_M2S))
|
|
|
|
{
|
2014-08-30 11:04:41 +00:00
|
|
|
list = GLDL_MASKEDWALLSOFS;
|
2014-07-15 19:16:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-08-30 11:04:41 +00:00
|
|
|
list = masked ? GLDL_MASKEDWALLS : GLDL_PLAINWALLS;
|
2014-07-15 19:16:59 +00:00
|
|
|
}
|
2016-08-25 21:13:49 +00:00
|
|
|
if (gl.buffermethod == BM_DEFERRED) MakeVertices(false);
|
2013-06-23 07:49:34 +00:00
|
|
|
gl_drawinfo->drawlists[list].AddWall(this);
|
|
|
|
|
|
|
|
}
|
2016-02-01 00:49:49 +00:00
|
|
|
lightlist = NULL;
|
2016-08-25 21:13:49 +00:00
|
|
|
vertcount = 0; // make sure that following parts of the same linedef do not get this one's vertex info.
|
2016-02-01 00:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GLWall::PutPortal(int ptype)
|
|
|
|
{
|
|
|
|
GLPortal * portal;
|
|
|
|
|
2016-08-25 21:13:49 +00:00
|
|
|
if (gl.buffermethod == BM_DEFERRED) MakeVertices(false);
|
2016-02-01 00:49:49 +00:00
|
|
|
switch (ptype)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
// portals don't go into the draw list.
|
|
|
|
// Instead they are added to the portal manager
|
2016-02-01 00:49:49 +00:00
|
|
|
case PORTALTYPE_HORIZON:
|
2013-06-23 07:49:34 +00:00
|
|
|
horizon=UniqueHorizons.Get(horizon);
|
|
|
|
portal=GLPortal::FindPortal(horizon);
|
|
|
|
if (!portal) portal=new GLHorizonPortal(horizon);
|
|
|
|
portal->AddLine(this);
|
|
|
|
break;
|
|
|
|
|
2016-02-01 00:49:49 +00:00
|
|
|
case PORTALTYPE_SKYBOX:
|
2016-04-20 18:08:53 +00:00
|
|
|
portal = GLPortal::FindPortal(secportal);
|
2016-01-11 14:07:58 +00:00
|
|
|
if (!portal)
|
|
|
|
{
|
2016-02-15 12:11:31 +00:00
|
|
|
// either a regular skybox or an Eternity-style horizon
|
2016-04-20 18:08:53 +00:00
|
|
|
if (secportal->mType != PORTS_SKYVIEWPOINT) portal = new GLEEHorizonPortal(secportal);
|
|
|
|
else portal = new GLSkyboxPortal(secportal);
|
2016-01-11 14:07:58 +00:00
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
portal->AddLine(this);
|
|
|
|
break;
|
|
|
|
|
2016-02-01 00:49:49 +00:00
|
|
|
case PORTALTYPE_SECTORSTACK:
|
2016-04-20 09:39:41 +00:00
|
|
|
portal = this->portal->GetRenderState();
|
2013-06-23 07:49:34 +00:00
|
|
|
portal->AddLine(this);
|
|
|
|
break;
|
|
|
|
|
2016-02-01 00:49:49 +00:00
|
|
|
case PORTALTYPE_PLANEMIRROR:
|
2016-03-29 11:45:50 +00:00
|
|
|
if (GLPortal::PlaneMirrorMode * planemirror->fC() <=0)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
//@sync-portal
|
|
|
|
planemirror=UniquePlaneMirrors.Get(planemirror);
|
|
|
|
portal=GLPortal::FindPortal(planemirror);
|
|
|
|
if (!portal) portal=new GLPlaneMirrorPortal(planemirror);
|
|
|
|
portal->AddLine(this);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-02-01 00:49:49 +00:00
|
|
|
case PORTALTYPE_MIRROR:
|
2013-06-23 07:49:34 +00:00
|
|
|
portal=GLPortal::FindPortal(seg->linedef);
|
|
|
|
if (!portal) portal=new GLMirrorPortal(seg->linedef);
|
|
|
|
portal->AddLine(this);
|
|
|
|
if (gl_mirror_envmap)
|
|
|
|
{
|
|
|
|
// draw a reflective layer over the mirror
|
|
|
|
type=RENDERWALL_MIRRORSURFACE;
|
|
|
|
gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].AddWall(this);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-02-06 04:17:47 +00:00
|
|
|
case PORTALTYPE_LINETOLINE:
|
2016-03-04 13:10:13 +00:00
|
|
|
portal=GLPortal::FindPortal(lineportal);
|
2016-04-30 21:18:37 +00:00
|
|
|
if (!portal)
|
|
|
|
{
|
|
|
|
line_t *otherside = lineportal->lines[0]->mDestination;
|
2016-05-02 17:47:27 +00:00
|
|
|
if (otherside != NULL && otherside->portalindex < linePortals.Size())
|
2016-04-30 21:18:37 +00:00
|
|
|
{
|
|
|
|
gl_RenderActorsInPortal(linePortalToGL[otherside->portalindex]);
|
|
|
|
}
|
|
|
|
portal = new GLLineToLinePortal(lineportal);
|
|
|
|
}
|
2016-02-06 04:17:47 +00:00
|
|
|
portal->AddLine(this);
|
|
|
|
break;
|
|
|
|
|
2016-02-01 00:49:49 +00:00
|
|
|
case PORTALTYPE_SKY:
|
2013-06-23 07:49:34 +00:00
|
|
|
portal=GLPortal::FindPortal(sky);
|
|
|
|
if (!portal) portal=new GLSkyPortal(sky);
|
|
|
|
portal->AddLine(this);
|
|
|
|
break;
|
|
|
|
}
|
2016-08-25 21:13:49 +00:00
|
|
|
vertcount = 0;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-02-04 14:34:12 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Sets 3D-floor lighting info
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void GLWall::Put3DWall(lightlist_t * lightlist, bool translucent)
|
|
|
|
{
|
|
|
|
// only modify the light level if it doesn't originate from the seg's frontsector. This is to account for light transferring effects
|
|
|
|
if (lightlist->p_lightlevel != &seg->sidedef->sector->lightlevel)
|
|
|
|
{
|
|
|
|
lightlevel = gl_ClampLight(*lightlist->p_lightlevel);
|
|
|
|
}
|
|
|
|
// relative light won't get changed here. It is constant across the entire wall.
|
|
|
|
|
|
|
|
Colormap.CopyFrom3DLight(lightlist);
|
2016-02-05 00:48:53 +00:00
|
|
|
PutWall(translucent);
|
2016-02-04 14:34:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Splits a wall vertically if a 3D-floor
|
|
|
|
// creates different lighting across the wall
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2016-08-07 11:50:48 +00:00
|
|
|
bool GLWall::SplitWallComplex(sector_t * frontsector, bool translucent, float& maplightbottomleft, float& maplightbottomright)
|
2016-04-26 19:42:15 +00:00
|
|
|
{
|
|
|
|
GLWall copyWall1, copyWall2;
|
|
|
|
|
|
|
|
// check for an intersection with the upper plane
|
|
|
|
if ((maplightbottomleft<ztop[0] && maplightbottomright>ztop[1]) ||
|
|
|
|
(maplightbottomleft>ztop[0] && maplightbottomright<ztop[1]))
|
|
|
|
{
|
2016-06-29 08:34:14 +00:00
|
|
|
float clen = MAX<float>(fabsf(glseg.x2 - glseg.x1), fabsf(glseg.y2 - glseg.y1));
|
2016-04-26 19:42:15 +00:00
|
|
|
|
|
|
|
float dch = ztop[1] - ztop[0];
|
|
|
|
float dfh = maplightbottomright - maplightbottomleft;
|
|
|
|
float coeff = (ztop[0] - maplightbottomleft) / (dfh - dch);
|
|
|
|
|
|
|
|
// check for inaccuracies - let's be a little generous here!
|
|
|
|
if (coeff*clen<.1f)
|
|
|
|
{
|
|
|
|
maplightbottomleft = ztop[0];
|
|
|
|
}
|
|
|
|
else if (coeff*clen>clen - .1f)
|
|
|
|
{
|
|
|
|
maplightbottomright = ztop[1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// split the wall in two at the intersection and recursively split both halves
|
|
|
|
copyWall1 = copyWall2 = *this;
|
|
|
|
|
|
|
|
copyWall1.glseg.x2 = copyWall2.glseg.x1 = glseg.x1 + coeff * (glseg.x2 - glseg.x1);
|
|
|
|
copyWall1.glseg.y2 = copyWall2.glseg.y1 = glseg.y1 + coeff * (glseg.y2 - glseg.y1);
|
|
|
|
copyWall1.ztop[1] = copyWall2.ztop[0] = ztop[0] + coeff * (ztop[1] - ztop[0]);
|
|
|
|
copyWall1.zbottom[1] = copyWall2.zbottom[0] = zbottom[0] + coeff * (zbottom[1] - zbottom[0]);
|
|
|
|
copyWall1.glseg.fracright = copyWall2.glseg.fracleft = glseg.fracleft + coeff * (glseg.fracright - glseg.fracleft);
|
2016-05-05 09:48:39 +00:00
|
|
|
copyWall1.tcs[UPRGT].u = copyWall2.tcs[UPLFT].u = tcs[UPLFT].u + coeff * (tcs[UPRGT].u - tcs[UPLFT].u);
|
|
|
|
copyWall1.tcs[UPRGT].v = copyWall2.tcs[UPLFT].v = tcs[UPLFT].v + coeff * (tcs[UPRGT].v - tcs[UPLFT].v);
|
|
|
|
copyWall1.tcs[LORGT].u = copyWall2.tcs[LOLFT].u = tcs[LOLFT].u + coeff * (tcs[LORGT].u - tcs[LOLFT].u);
|
|
|
|
copyWall1.tcs[LORGT].v = copyWall2.tcs[LOLFT].v = tcs[LOLFT].v + coeff * (tcs[LORGT].v - tcs[LOLFT].v);
|
2016-04-26 19:42:15 +00:00
|
|
|
|
|
|
|
copyWall1.SplitWall(frontsector, translucent);
|
|
|
|
copyWall2.SplitWall(frontsector, translucent);
|
2016-08-07 11:50:48 +00:00
|
|
|
return true;
|
2016-04-26 19:42:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// check for an intersection with the lower plane
|
|
|
|
if ((maplightbottomleft<zbottom[0] && maplightbottomright>zbottom[1]) ||
|
|
|
|
(maplightbottomleft>zbottom[0] && maplightbottomright<zbottom[1]))
|
|
|
|
{
|
2016-06-29 08:34:14 +00:00
|
|
|
float clen = MAX<float>(fabsf(glseg.x2 - glseg.x1), fabsf(glseg.y2 - glseg.y1));
|
2016-04-26 19:42:15 +00:00
|
|
|
|
|
|
|
float dch = zbottom[1] - zbottom[0];
|
|
|
|
float dfh = maplightbottomright - maplightbottomleft;
|
|
|
|
float coeff = (zbottom[0] - maplightbottomleft) / (dfh - dch);
|
|
|
|
|
|
|
|
// check for inaccuracies - let's be a little generous here because there's
|
|
|
|
// some conversions between floats and fixed_t's involved
|
|
|
|
if (coeff*clen<.1f)
|
|
|
|
{
|
|
|
|
maplightbottomleft = zbottom[0];
|
|
|
|
}
|
|
|
|
else if (coeff*clen>clen - .1f)
|
|
|
|
{
|
|
|
|
maplightbottomright = zbottom[1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// split the wall in two at the intersection and recursively split both halves
|
|
|
|
copyWall1 = copyWall2 = *this;
|
|
|
|
|
|
|
|
copyWall1.glseg.x2 = copyWall2.glseg.x1 = glseg.x1 + coeff * (glseg.x2 - glseg.x1);
|
|
|
|
copyWall1.glseg.y2 = copyWall2.glseg.y1 = glseg.y1 + coeff * (glseg.y2 - glseg.y1);
|
|
|
|
copyWall1.ztop[1] = copyWall2.ztop[0] = ztop[0] + coeff * (ztop[1] - ztop[0]);
|
|
|
|
copyWall1.zbottom[1] = copyWall2.zbottom[0] = zbottom[0] + coeff * (zbottom[1] - zbottom[0]);
|
|
|
|
copyWall1.glseg.fracright = copyWall2.glseg.fracleft = glseg.fracleft + coeff * (glseg.fracright - glseg.fracleft);
|
2016-05-05 09:48:39 +00:00
|
|
|
copyWall1.tcs[UPRGT].u = copyWall2.tcs[UPLFT].u = tcs[UPLFT].u + coeff * (tcs[UPRGT].u - tcs[UPLFT].u);
|
|
|
|
copyWall1.tcs[UPRGT].v = copyWall2.tcs[UPLFT].v = tcs[UPLFT].v + coeff * (tcs[UPRGT].v - tcs[UPLFT].v);
|
|
|
|
copyWall1.tcs[LORGT].u = copyWall2.tcs[LOLFT].u = tcs[LOLFT].u + coeff * (tcs[LORGT].u - tcs[LOLFT].u);
|
|
|
|
copyWall1.tcs[LORGT].v = copyWall2.tcs[LOLFT].v = tcs[LOLFT].v + coeff * (tcs[LORGT].v - tcs[LOLFT].v);
|
2016-04-26 19:42:15 +00:00
|
|
|
|
|
|
|
copyWall1.SplitWall(frontsector, translucent);
|
|
|
|
copyWall2.SplitWall(frontsector, translucent);
|
2016-08-07 11:50:48 +00:00
|
|
|
return true;
|
2016-04-26 19:42:15 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-07 11:50:48 +00:00
|
|
|
|
|
|
|
return false;
|
2016-04-26 19:42:15 +00:00
|
|
|
}
|
|
|
|
|
2016-02-04 14:34:12 +00:00
|
|
|
void GLWall::SplitWall(sector_t * frontsector, bool translucent)
|
|
|
|
{
|
2016-04-26 19:42:15 +00:00
|
|
|
GLWall copyWall1;
|
2016-02-04 14:34:12 +00:00
|
|
|
float maplightbottomleft;
|
|
|
|
float maplightbottomright;
|
|
|
|
unsigned int i;
|
|
|
|
int origlight = lightlevel;
|
|
|
|
FColormap origcm=Colormap;
|
|
|
|
|
|
|
|
TArray<lightlist_t> & lightlist=frontsector->e->XFloor.lightlist;
|
|
|
|
|
|
|
|
if (glseg.x1==glseg.x2 && glseg.y1==glseg.y2)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//::SplitWall.Clock();
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
if (seg->linedef-lines==1)
|
|
|
|
{
|
|
|
|
int a = 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (lightlist.Size()>1)
|
|
|
|
{
|
|
|
|
for(i=0;i<lightlist.Size()-1;i++)
|
|
|
|
{
|
|
|
|
if (i<lightlist.Size()-1)
|
|
|
|
{
|
|
|
|
secplane_t &p = lightlist[i+1].plane;
|
2016-04-03 00:07:37 +00:00
|
|
|
maplightbottomleft = p.ZatPoint(glseg.x1,glseg.y1);
|
|
|
|
maplightbottomright= p.ZatPoint(glseg.x2,glseg.y2);
|
2016-02-04 14:34:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
maplightbottomright = maplightbottomleft = -32000;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The light is completely above the wall!
|
|
|
|
if (maplightbottomleft>=ztop[0] && maplightbottomright>=ztop[1])
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-06-05 09:38:23 +00:00
|
|
|
// check for an intersection with the upper and lower planes of the wall segment
|
|
|
|
if ((maplightbottomleft<ztop[0] && maplightbottomright>ztop[1]) ||
|
|
|
|
(maplightbottomleft > ztop[0] && maplightbottomright < ztop[1]) ||
|
|
|
|
(maplightbottomleft<zbottom[0] && maplightbottomright>zbottom[1]) ||
|
|
|
|
(maplightbottomleft > zbottom[0] && maplightbottomright < zbottom[1]))
|
2016-02-04 14:34:12 +00:00
|
|
|
{
|
2016-08-08 10:55:09 +00:00
|
|
|
if (!(gl.flags & RFL_NO_CLIP_PLANES))
|
2016-04-26 19:42:15 +00:00
|
|
|
{
|
|
|
|
// Use hardware clipping if this cannot be done cleanly.
|
|
|
|
this->lightlist = &lightlist;
|
|
|
|
PutWall(translucent);
|
2016-08-07 11:50:48 +00:00
|
|
|
|
|
|
|
goto out;
|
2016-04-26 19:42:15 +00:00
|
|
|
}
|
2016-08-07 11:50:48 +00:00
|
|
|
// crappy fallback if no clip planes available
|
|
|
|
else if (SplitWallComplex(frontsector, translucent, maplightbottomleft, maplightbottomright))
|
2016-06-05 09:38:23 +00:00
|
|
|
{
|
2016-08-07 11:50:48 +00:00
|
|
|
goto out;
|
2016-06-05 09:38:23 +00:00
|
|
|
}
|
2016-02-04 14:34:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 3D floor is completely within this light
|
|
|
|
if (maplightbottomleft<=zbottom[0] && maplightbottomright<=zbottom[1])
|
|
|
|
{
|
|
|
|
Put3DWall(&lightlist[i], translucent);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (maplightbottomleft<=ztop[0] && maplightbottomright<=ztop[1] &&
|
|
|
|
(maplightbottomleft!=ztop[0] || maplightbottomright!=ztop[1]))
|
|
|
|
{
|
|
|
|
copyWall1=*this;
|
|
|
|
|
|
|
|
copyWall1.flags |= GLWF_NOSPLITLOWER;
|
|
|
|
flags |= GLWF_NOSPLITUPPER;
|
|
|
|
ztop[0]=copyWall1.zbottom[0]=maplightbottomleft;
|
|
|
|
ztop[1]=copyWall1.zbottom[1]=maplightbottomright;
|
2016-05-05 09:48:39 +00:00
|
|
|
tcs[UPLFT].v=copyWall1.tcs[LOLFT].v=copyWall1.tcs[UPLFT].v+
|
|
|
|
(maplightbottomleft-copyWall1.ztop[0])*(copyWall1.tcs[LOLFT].v-copyWall1.tcs[UPLFT].v)/(zbottom[0]-copyWall1.ztop[0]);
|
|
|
|
tcs[UPRGT].v=copyWall1.tcs[LORGT].v=copyWall1.tcs[UPRGT].v+
|
|
|
|
(maplightbottomright-copyWall1.ztop[1])*(copyWall1.tcs[LORGT].v-copyWall1.tcs[UPRGT].v)/(zbottom[1]-copyWall1.ztop[1]);
|
2016-02-04 14:34:12 +00:00
|
|
|
copyWall1.Put3DWall(&lightlist[i], translucent);
|
|
|
|
}
|
|
|
|
if (ztop[0]==zbottom[0] && ztop[1]==zbottom[1])
|
|
|
|
{
|
|
|
|
//::SplitWall.Unclock();
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Put3DWall(&lightlist[lightlist.Size()-1], translucent);
|
|
|
|
|
|
|
|
out:
|
|
|
|
lightlevel=origlight;
|
|
|
|
Colormap=origcm;
|
|
|
|
flags &= ~GLWF_NOSPLITUPPER;
|
|
|
|
this->lightlist = NULL;
|
|
|
|
//::SplitWall.Unclock();
|
|
|
|
}
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2)
|
|
|
|
{
|
|
|
|
GLHorizonInfo hi;
|
|
|
|
lightlist_t * light;
|
|
|
|
|
|
|
|
// ZDoom doesn't support slopes in a horizon sector so I won't either!
|
2016-04-24 11:35:43 +00:00
|
|
|
ztop[1] = ztop[0] = fs->GetPlaneTexZ(sector_t::ceiling);
|
|
|
|
zbottom[1] = zbottom[0] = fs->GetPlaneTexZ(sector_t::floor);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-24 11:35:43 +00:00
|
|
|
if (ViewPos.Z < fs->GetPlaneTexZ(sector_t::ceiling))
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-24 11:35:43 +00:00
|
|
|
if (ViewPos.Z > fs->GetPlaneTexZ(sector_t::floor))
|
2016-04-02 21:17:16 +00:00
|
|
|
zbottom[1] = zbottom[0] = ViewPos.Z;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
if (fs->GetTexture(sector_t::ceiling) == skyflatnum)
|
|
|
|
{
|
|
|
|
SkyPlane(fs, sector_t::ceiling, false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-03 14:09:32 +00:00
|
|
|
hi.plane.GetFromSector(fs, sector_t::ceiling);
|
2013-06-23 07:49:34 +00:00
|
|
|
hi.lightlevel = gl_ClampLight(fs->GetCeilingLight());
|
|
|
|
hi.colormap = fs->ColorMap;
|
|
|
|
|
|
|
|
if (fs->e->XFloor.ffloors.Size())
|
|
|
|
{
|
|
|
|
light = P_GetPlaneLight(fs, &fs->ceilingplane, true);
|
|
|
|
|
|
|
|
if(!(fs->GetFlags(sector_t::ceiling)&PLANEF_ABSLIGHTING)) hi.lightlevel = gl_ClampLight(*light->p_lightlevel);
|
|
|
|
hi.colormap.LightColor = (light->extra_colormap)->Color;
|
|
|
|
}
|
|
|
|
|
2014-05-11 20:57:42 +00:00
|
|
|
if (gl_fixedcolormap) hi.colormap.Clear();
|
2013-06-23 07:49:34 +00:00
|
|
|
horizon = &hi;
|
2016-02-01 00:49:49 +00:00
|
|
|
PutPortal(PORTALTYPE_HORIZON);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
ztop[1] = ztop[0] = zbottom[0];
|
2016-02-05 00:48:53 +00:00
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-24 11:35:43 +00:00
|
|
|
if (ViewPos.Z > fs->GetPlaneTexZ(sector_t::floor))
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-24 11:35:43 +00:00
|
|
|
zbottom[1] = zbottom[0] = fs->GetPlaneTexZ(sector_t::floor);
|
2013-06-23 07:49:34 +00:00
|
|
|
if (fs->GetTexture(sector_t::floor) == skyflatnum)
|
|
|
|
{
|
|
|
|
SkyPlane(fs, sector_t::floor, false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-03 14:09:32 +00:00
|
|
|
hi.plane.GetFromSector(fs, sector_t::floor);
|
2013-06-23 07:49:34 +00:00
|
|
|
hi.lightlevel = gl_ClampLight(fs->GetFloorLight());
|
|
|
|
hi.colormap = fs->ColorMap;
|
|
|
|
|
|
|
|
if (fs->e->XFloor.ffloors.Size())
|
|
|
|
{
|
|
|
|
light = P_GetPlaneLight(fs, &fs->floorplane, false);
|
|
|
|
|
|
|
|
if(!(fs->GetFlags(sector_t::floor)&PLANEF_ABSLIGHTING)) hi.lightlevel = gl_ClampLight(*light->p_lightlevel);
|
|
|
|
hi.colormap.LightColor = (light->extra_colormap)->Color;
|
|
|
|
}
|
|
|
|
|
2014-05-11 20:57:42 +00:00
|
|
|
if (gl_fixedcolormap) hi.colormap.Clear();
|
|
|
|
horizon = &hi;
|
2016-02-01 00:49:49 +00:00
|
|
|
PutPortal(PORTALTYPE_HORIZON);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float texturetop,
|
2016-04-07 22:19:51 +00:00
|
|
|
float topleft, float topright, float bottomleft, float bottomright, float t_ofs)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// set up texture coordinate stuff
|
|
|
|
//
|
|
|
|
//
|
|
|
|
float l_ul;
|
|
|
|
float texlength;
|
|
|
|
|
2016-04-07 15:00:13 +00:00
|
|
|
if (gltexture)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-07 15:00:13 +00:00
|
|
|
float length = seg->sidedef ? seg->sidedef->TexelLength : Dist2(glseg.x1, glseg.y1, glseg.x2, glseg.y2);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-07 22:19:51 +00:00
|
|
|
l_ul = tci->FloatToTexU(tci->TextureOffset(t_ofs));
|
2013-06-23 07:49:34 +00:00
|
|
|
texlength = tci->FloatToTexU(length);
|
|
|
|
}
|
2016-04-07 15:00:13 +00:00
|
|
|
else
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-07 15:00:13 +00:00
|
|
|
tci = NULL;
|
|
|
|
l_ul = 0;
|
|
|
|
texlength = 0;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// set up coordinates for the left side of the polygon
|
|
|
|
//
|
|
|
|
// check left side for intersections
|
2016-04-07 15:00:13 +00:00
|
|
|
if (topleft >= bottomleft)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
// normal case
|
2016-04-07 15:00:13 +00:00
|
|
|
ztop[0] = topleft;
|
|
|
|
zbottom[0] = bottomleft;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
if (tci)
|
|
|
|
{
|
2016-05-05 09:48:39 +00:00
|
|
|
tcs[UPLFT].v = tci->FloatToTexV(-ztop[0] + texturetop);
|
|
|
|
tcs[LOLFT].v = tci->FloatToTexV(-zbottom[0] + texturetop);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// ceiling below floor - clip to the visible part of the wall
|
2016-04-07 15:00:13 +00:00
|
|
|
float dch = topright - topleft;
|
|
|
|
float dfh = bottomright - bottomleft;
|
|
|
|
float inter_x = (bottomleft - topleft) / (dch - dfh);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-07 15:00:13 +00:00
|
|
|
float inter_y = topleft + inter_x * dch;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
glseg.x1 = glseg.x1 + inter_x * (glseg.x2 - glseg.x1);
|
|
|
|
glseg.y1 = glseg.y1 + inter_x * (glseg.y2 - glseg.y1);
|
|
|
|
glseg.fracleft = inter_x;
|
|
|
|
|
2016-04-07 15:00:13 +00:00
|
|
|
zbottom[0] = ztop[0] = inter_y;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
if (tci)
|
|
|
|
{
|
2016-05-05 09:48:39 +00:00
|
|
|
tcs[LOLFT].v = tcs[UPLFT].v = tci->FloatToTexV(-ztop[0] + texturetop);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// set up coordinates for the right side of the polygon
|
|
|
|
//
|
|
|
|
// check left side for intersections
|
|
|
|
if (topright >= bottomright)
|
|
|
|
{
|
|
|
|
// normal case
|
2016-04-07 15:00:13 +00:00
|
|
|
ztop[1] = topright;
|
|
|
|
zbottom[1] = bottomright;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
if (tci)
|
|
|
|
{
|
2016-05-05 09:48:39 +00:00
|
|
|
tcs[UPRGT].v = tci->FloatToTexV(-ztop[1] + texturetop);
|
|
|
|
tcs[LORGT].v = tci->FloatToTexV(-zbottom[1] + texturetop);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// ceiling below floor - clip to the visible part of the wall
|
2016-04-07 15:00:13 +00:00
|
|
|
float dch = topright - topleft;
|
|
|
|
float dfh = bottomright - bottomleft;
|
|
|
|
float inter_x = (bottomleft - topleft) / (dch - dfh);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-07 15:00:13 +00:00
|
|
|
float inter_y = topleft + inter_x * dch;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
glseg.x2 = glseg.x1 + inter_x * (glseg.x2 - glseg.x1);
|
|
|
|
glseg.y2 = glseg.y1 + inter_x * (glseg.y2 - glseg.y1);
|
|
|
|
glseg.fracright = inter_x;
|
|
|
|
|
2016-04-07 15:00:13 +00:00
|
|
|
zbottom[1] = ztop[1] = inter_y;
|
2013-06-23 07:49:34 +00:00
|
|
|
if (tci)
|
|
|
|
{
|
2016-05-05 09:48:39 +00:00
|
|
|
tcs[LORGT].v = tcs[UPRGT].v = tci->FloatToTexV(-ztop[1] + texturetop);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-05 09:48:39 +00:00
|
|
|
tcs[UPLFT].u = tcs[LOLFT].u = l_ul + texlength * glseg.fracleft;
|
|
|
|
tcs[UPRGT].u = tcs[LORGT].u = l_ul + texlength * glseg.fracright;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-12-26 10:53:38 +00:00
|
|
|
if (gltexture != NULL)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-12-26 10:53:38 +00:00
|
|
|
bool normalize = false;
|
|
|
|
if (gltexture->tex->bHasCanvas) normalize = true;
|
|
|
|
else if (flags & GLT_CLAMPY)
|
|
|
|
{
|
|
|
|
// for negative scales we can get negative coordinates here.
|
2016-05-05 09:48:39 +00:00
|
|
|
normalize = (tcs[UPLFT].v > tcs[LOLFT].v || tcs[UPRGT].v > tcs[LORGT].v);
|
2014-12-26 10:53:38 +00:00
|
|
|
}
|
|
|
|
if (normalize)
|
|
|
|
{
|
|
|
|
// we have to shift the y-coordinate from [-1..0] to [0..1] when using texture clamping with a negative scale
|
2016-05-05 09:48:39 +00:00
|
|
|
tcs[UPLFT].v += 1.f;
|
|
|
|
tcs[UPRGT].v += 1.f;
|
|
|
|
tcs[LOLFT].v += 1.f;
|
|
|
|
tcs[LORGT].v += 1.f;
|
2014-12-26 10:53:38 +00:00
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-04-07 15:00:13 +00:00
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Do some tweaks with the texture coordinates to reduce visual glitches
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void GLWall::CheckTexturePosition()
|
|
|
|
{
|
|
|
|
float sub;
|
|
|
|
|
|
|
|
if (gltexture->tex->bHasCanvas) return;
|
|
|
|
|
|
|
|
// clamp texture coordinates to a reasonable range.
|
|
|
|
// Extremely large values can cause visual problems
|
2016-05-05 09:48:39 +00:00
|
|
|
if (tcs[UPLFT].v < tcs[UPRGT].v)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-05-05 09:48:39 +00:00
|
|
|
sub = float(xs_FloorToInt(tcs[UPLFT].v));
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-05 09:48:39 +00:00
|
|
|
sub = float(xs_FloorToInt(tcs[UPRGT].v));
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-05-05 09:48:39 +00:00
|
|
|
tcs[UPLFT].v -= sub;
|
|
|
|
tcs[UPRGT].v -= sub;
|
|
|
|
tcs[LOLFT].v -= sub;
|
|
|
|
tcs[LORGT].v -= sub;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-05-05 09:48:39 +00:00
|
|
|
if ((tcs[UPLFT].v == 0.f && tcs[UPRGT].v == 0.f && tcs[LOLFT].v <= 1.f && tcs[LORGT].v <= 1.f) ||
|
|
|
|
(tcs[UPLFT].v >= 0.f && tcs[UPRGT].v >= 0.f && tcs[LOLFT].v == 1.f && tcs[LORGT].v == 1.f))
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-14 11:22:15 +00:00
|
|
|
flags |= GLT_CLAMPY;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if this is marked as a skybox and if so, do the same for x.
|
|
|
|
// This intentionally only tests the seg's frontsector.
|
|
|
|
if (seg->frontsector->special == GLSector_Skybox)
|
|
|
|
{
|
2016-05-05 09:48:39 +00:00
|
|
|
sub = (float)xs_FloorToInt(tcs[UPLFT].u);
|
|
|
|
tcs[UPLFT].u -= sub;
|
|
|
|
tcs[UPRGT].u -= sub;
|
|
|
|
tcs[LOLFT].u -= sub;
|
|
|
|
tcs[LORGT].u -= sub;
|
|
|
|
if ((tcs[UPLFT].u == 0.f && tcs[LOLFT].u == 0.f && tcs[UPRGT].u <= 1.f && tcs[LORGT].u <= 1.f) ||
|
|
|
|
(tcs[UPLFT].u >= 0.f && tcs[LOLFT].u >= 0.f && tcs[UPRGT].u == 1.f && tcs[LORGT].u == 1.f))
|
2016-04-14 11:22:15 +00:00
|
|
|
{
|
|
|
|
flags |= GLT_CLAMPX;
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Handle one sided walls, upper and lower texture
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
void GLWall::DoTexture(int _type,seg_t * seg, int peg,
|
2016-04-07 22:19:51 +00:00
|
|
|
float ceilingrefheight,float floorrefheight,
|
2016-04-07 15:00:13 +00:00
|
|
|
float topleft,float topright,
|
|
|
|
float bottomleft,float bottomright,
|
2016-04-07 22:19:51 +00:00
|
|
|
float v_offset)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
if (topleft<=bottomleft && topright<=bottomright) return;
|
|
|
|
|
|
|
|
// The Vertex values can be destroyed in this function and must be restored aferward!
|
|
|
|
GLSeg glsave=glseg;
|
2016-04-07 22:19:51 +00:00
|
|
|
float flh=ceilingrefheight-floorrefheight;
|
2013-06-23 07:49:34 +00:00
|
|
|
int texpos;
|
2016-04-14 11:22:15 +00:00
|
|
|
BYTE savedflags = flags;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
switch (_type)
|
|
|
|
{
|
|
|
|
case RENDERWALL_TOP:
|
|
|
|
texpos = side_t::top;
|
|
|
|
break;
|
|
|
|
case RENDERWALL_BOTTOM:
|
|
|
|
texpos = side_t::bottom;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
texpos = side_t::mid;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
FTexCoordInfo tci;
|
|
|
|
|
2016-04-07 23:42:43 +00:00
|
|
|
gltexture->GetTexCoordInfo(&tci, seg->sidedef, texpos);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-02-01 00:49:49 +00:00
|
|
|
type = _type;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-23 09:38:33 +00:00
|
|
|
float floatceilingref = ceilingrefheight + tci.RowOffset(seg->sidedef->GetTextureYOffset(texpos));
|
2016-04-07 22:19:51 +00:00
|
|
|
if (peg) floatceilingref += tci.mRenderHeight - flh - v_offset;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
if (!SetWallCoordinates(seg, &tci, floatceilingref, topleft, topright, bottomleft, bottomright,
|
2016-04-23 09:38:33 +00:00
|
|
|
seg->sidedef->GetTextureXOffset(texpos))) return;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-02-01 00:49:49 +00:00
|
|
|
if (seg->linedef->special == Line_Mirror && _type == RENDERWALL_M1S && gl_mirrors)
|
|
|
|
{
|
|
|
|
PutPortal(PORTALTYPE_MIRROR);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-14 11:22:15 +00:00
|
|
|
|
2016-02-01 00:49:49 +00:00
|
|
|
CheckTexturePosition();
|
2016-02-04 14:34:12 +00:00
|
|
|
|
2016-04-14 11:22:15 +00:00
|
|
|
// Add this wall to the render list
|
|
|
|
sector_t * sec = sub ? sub->sector : seg->frontsector;
|
2016-02-05 00:48:53 +00:00
|
|
|
if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(false);
|
2016-02-04 14:34:12 +00:00
|
|
|
else SplitWall(sec, false);
|
2016-02-01 00:49:49 +00:00
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-14 11:22:15 +00:00
|
|
|
glseg = glsave;
|
|
|
|
flags = savedflags;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary,
|
|
|
|
sector_t * front, sector_t * back,
|
|
|
|
sector_t * realfront, sector_t * realback,
|
2016-04-07 21:19:37 +00:00
|
|
|
float fch1, float fch2, float ffh1, float ffh2,
|
|
|
|
float bch1, float bch2, float bfh1, float bfh2)
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
FTexCoordInfo tci;
|
2016-04-07 21:19:37 +00:00
|
|
|
float topleft,bottomleft,topright,bottomright;
|
2013-06-23 07:49:34 +00:00
|
|
|
GLSeg glsave=glseg;
|
2016-04-07 21:19:37 +00:00
|
|
|
float texturetop, texturebottom;
|
2013-06-23 07:49:34 +00:00
|
|
|
bool wrap = (seg->linedef->flags&ML_WRAP_MIDTEX) || (seg->sidedef->Flags&WALLF_WRAP_MIDTEX);
|
2016-02-14 13:33:52 +00:00
|
|
|
bool mirrory = false;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Get the base coordinates for the texture
|
|
|
|
//
|
|
|
|
//
|
|
|
|
if (gltexture)
|
|
|
|
{
|
|
|
|
// Align the texture to the ORIGINAL sector's height!!
|
|
|
|
// At this point slopes don't matter because they don't affect the texture's z-position
|
|
|
|
|
2016-04-07 23:42:43 +00:00
|
|
|
gltexture->GetTexCoordInfo(&tci, seg->sidedef, side_t::mid);
|
2016-02-14 13:33:52 +00:00
|
|
|
if (tci.mRenderHeight < 0)
|
|
|
|
{
|
|
|
|
mirrory = true;
|
|
|
|
tci.mRenderHeight = -tci.mRenderHeight;
|
2016-04-07 23:42:43 +00:00
|
|
|
tci.mScale.Y = -tci.mScale.Y;
|
2016-02-14 13:33:52 +00:00
|
|
|
}
|
2016-04-23 09:38:33 +00:00
|
|
|
float rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid));
|
2016-02-14 13:33:52 +00:00
|
|
|
if ((seg->linedef->flags & ML_DONTPEGBOTTOM) >0)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-24 11:35:43 +00:00
|
|
|
texturebottom = MAX(realfront->GetPlaneTexZ(sector_t::floor), realback->GetPlaneTexZ(sector_t::floor)) + rowoffset;
|
2016-04-07 21:19:37 +00:00
|
|
|
texturetop = texturebottom + tci.mRenderHeight;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-24 11:35:43 +00:00
|
|
|
texturetop = MIN(realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling)) + rowoffset;
|
2016-04-07 21:19:37 +00:00
|
|
|
texturebottom = texturetop - tci.mRenderHeight;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else texturetop=texturebottom=0;
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Depending on missing textures and possible plane intersections
|
|
|
|
// decide which planes to use for the polygon
|
|
|
|
//
|
|
|
|
//
|
|
|
|
if (realfront!=realback || drawfogboundary || wrap || realfront->GetHeightSec())
|
|
|
|
{
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Set up the top
|
|
|
|
//
|
|
|
|
//
|
|
|
|
FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::top));
|
|
|
|
if (!tex || tex->UseType==FTexture::TEX_Null)
|
|
|
|
{
|
|
|
|
if (front->GetTexture(sector_t::ceiling) == skyflatnum &&
|
|
|
|
back->GetTexture(sector_t::ceiling) == skyflatnum)
|
|
|
|
{
|
|
|
|
// intra-sky lines do not clip the texture at all if there's no upper texture
|
|
|
|
topleft = topright = texturetop;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// texture is missing - use the higher plane
|
|
|
|
topleft = MAX(bch1,fch1);
|
|
|
|
topright = MAX(bch2,fch2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((bch1>fch1 || bch2>fch2) &&
|
|
|
|
(seg->frontsector->GetTexture(sector_t::ceiling)!=skyflatnum || seg->backsector->GetTexture(sector_t::ceiling)==skyflatnum))
|
|
|
|
// (!((bch1<=fch1 && bch2<=fch2) || (bch1>=fch1 && bch2>=fch2)))
|
|
|
|
{
|
|
|
|
// Use the higher plane and let the geometry clip the extruding part
|
|
|
|
topleft = bch1;
|
|
|
|
topright = bch2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// But not if there can be visual artifacts.
|
|
|
|
topleft = MIN(bch1,fch1);
|
|
|
|
topright = MIN(bch2,fch2);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Set up the bottom
|
|
|
|
//
|
|
|
|
//
|
|
|
|
tex = TexMan(seg->sidedef->GetTexture(side_t::bottom));
|
|
|
|
if (!tex || tex->UseType==FTexture::TEX_Null)
|
|
|
|
{
|
|
|
|
// texture is missing - use the lower plane
|
|
|
|
bottomleft = MIN(bfh1,ffh1);
|
|
|
|
bottomright = MIN(bfh2,ffh2);
|
|
|
|
}
|
|
|
|
else if (bfh1<ffh1 || bfh2<ffh2) // (!((bfh1<=ffh1 && bfh2<=ffh2) || (bfh1>=ffh1 && bfh2>=ffh2)))
|
|
|
|
{
|
|
|
|
// the floor planes intersect. Use the backsector's floor for drawing so that
|
|
|
|
// drawing the front sector's plane clips the polygon automatically.
|
|
|
|
bottomleft = bfh1;
|
|
|
|
bottomright = bfh2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// normal case - use the higher plane
|
|
|
|
bottomleft = MAX(bfh1,ffh1);
|
|
|
|
bottomright = MAX(bfh2,ffh2);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// if we don't need a fog sheet let's clip away some unnecessary parts of the polygon
|
|
|
|
//
|
|
|
|
//
|
|
|
|
if (!drawfogboundary && !wrap)
|
|
|
|
{
|
|
|
|
if (texturetop<topleft && texturetop<topright) topleft=topright=texturetop;
|
|
|
|
if (texturebottom>bottomleft && texturebottom>bottomright) bottomleft=bottomright=texturebottom;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// if both sides of the line are in the same sector and the sector
|
|
|
|
// doesn't have a Transfer_Heights special don't clip to the planes
|
|
|
|
// Clipping to the planes is not necessary and can even produce
|
|
|
|
// unwanted side effects.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
topleft=topright=texturetop;
|
|
|
|
bottomleft=bottomright=texturebottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
// nothing visible - skip the rest
|
|
|
|
if (topleft<=bottomleft && topright<=bottomright) return;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// set up texture coordinate stuff
|
|
|
|
//
|
|
|
|
//
|
2016-04-23 09:38:33 +00:00
|
|
|
float t_ofs = seg->sidedef->GetTextureXOffset(side_t::mid);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
if (gltexture)
|
|
|
|
{
|
|
|
|
// First adjust the texture offset so that the left edge of the linedef is inside the range [0..1].
|
2016-04-07 21:19:37 +00:00
|
|
|
float texwidth = tci.TextureAdjustWidth();
|
|
|
|
|
|
|
|
if (t_ofs >= 0)
|
|
|
|
{
|
|
|
|
float div = t_ofs / texwidth;
|
|
|
|
t_ofs = (div - xs_FloorToInt(div)) * texwidth;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float div = (-t_ofs) / texwidth;
|
|
|
|
t_ofs = texwidth - (div - xs_FloorToInt(div)) * texwidth;
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Now check whether the linedef is completely within the texture range of [0..1].
|
|
|
|
// If so we should use horizontal texture clamping to prevent filtering artifacts
|
|
|
|
// at the edges.
|
|
|
|
|
2016-04-07 22:19:51 +00:00
|
|
|
float textureoffset = tci.TextureOffset(t_ofs);
|
|
|
|
int righttex = int(textureoffset) + seg->sidedef->TexelLength;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2015-02-10 19:16:25 +00:00
|
|
|
if ((textureoffset == 0 && righttex <= tci.mRenderWidth) ||
|
|
|
|
(textureoffset >= 0 && righttex == tci.mRenderWidth))
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2015-02-10 19:16:25 +00:00
|
|
|
flags |= GLT_CLAMPX;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-14 11:22:15 +00:00
|
|
|
flags &= ~GLT_CLAMPX;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
if (!wrap)
|
|
|
|
{
|
2016-04-14 11:22:15 +00:00
|
|
|
flags |= GLT_CLAMPY;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
2016-02-14 13:33:52 +00:00
|
|
|
if (mirrory)
|
|
|
|
{
|
|
|
|
tci.mRenderHeight = -tci.mRenderHeight;
|
2016-04-07 23:42:43 +00:00
|
|
|
tci.mScale.Y = -tci.mScale.Y;
|
2016-02-14 13:33:52 +00:00
|
|
|
}
|
2016-04-07 22:19:51 +00:00
|
|
|
SetWallCoordinates(seg, &tci, texturetop, topleft, topright, bottomleft, bottomright, t_ofs);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// draw fog sheet if required
|
|
|
|
//
|
|
|
|
//
|
|
|
|
if (drawfogboundary)
|
|
|
|
{
|
|
|
|
flags |= GLWF_NOSPLITUPPER|GLWF_NOSPLITLOWER;
|
|
|
|
type=RENDERWALL_FOGBOUNDARY;
|
2016-02-01 00:49:49 +00:00
|
|
|
FMaterial *savetex = gltexture;
|
|
|
|
gltexture = NULL;
|
2016-02-05 00:48:53 +00:00
|
|
|
PutWall(true);
|
2016-02-01 00:49:49 +00:00
|
|
|
if (!savetex)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
flags &= ~(GLWF_NOSPLITUPPER|GLWF_NOSPLITLOWER);
|
|
|
|
return;
|
|
|
|
}
|
2016-02-01 00:49:49 +00:00
|
|
|
gltexture = savetex;
|
2013-06-23 07:49:34 +00:00
|
|
|
type=RENDERWALL_M2SNF;
|
|
|
|
}
|
|
|
|
else type=RENDERWALL_M2S;
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// set up alpha blending
|
|
|
|
//
|
|
|
|
//
|
2016-04-24 11:35:43 +00:00
|
|
|
if (seg->linedef->alpha != 0)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
bool translucent = false;
|
|
|
|
|
|
|
|
switch (seg->linedef->flags& ML_ADDTRANS)//TRANSBITS)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
RenderStyle=STYLE_Translucent;
|
2016-04-24 11:35:43 +00:00
|
|
|
alpha = seg->linedef->alpha;
|
|
|
|
translucent =alpha < 1. || (gltexture && gltexture->GetTransparent());
|
2013-06-23 07:49:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ML_ADDTRANS:
|
|
|
|
RenderStyle=STYLE_Add;
|
2016-04-24 11:35:43 +00:00
|
|
|
alpha = seg->linedef->alpha;
|
2013-06-23 07:49:34 +00:00
|
|
|
translucent=true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// for textures with large empty areas only the visible parts are drawn.
|
|
|
|
// If these textures come too close to the camera they severely affect performance
|
|
|
|
// if stacked closely together
|
|
|
|
// Recognizing vertical gaps is rather simple and well worth the effort.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
FloatRect *splitrect;
|
|
|
|
int v = gltexture->GetAreas(&splitrect);
|
2014-08-04 21:00:40 +00:00
|
|
|
if (seg->frontsector == seg->backsector) flags |= GLWF_NOSPLIT; // we don't need to do vertex splits if a line has both sides in the same sector
|
2013-06-23 07:49:34 +00:00
|
|
|
if (v>0 && !drawfogboundary && !(seg->linedef->flags&ML_WRAP_MIDTEX))
|
|
|
|
{
|
|
|
|
// split the poly!
|
|
|
|
GLWall split;
|
|
|
|
int i,t=0;
|
2016-05-05 09:48:39 +00:00
|
|
|
float v_factor=(zbottom[0]-ztop[0])/(tcs[LOLFT].v-tcs[UPLFT].v);
|
2013-06-23 07:49:34 +00:00
|
|
|
// only split the vertical area of the polygon that does not contain slopes.
|
2016-05-05 09:48:39 +00:00
|
|
|
float splittopv = MAX(tcs[UPLFT].v, tcs[UPRGT].v);
|
|
|
|
float splitbotv = MIN(tcs[LOLFT].v, tcs[LORGT].v);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
// this is split vertically into sections.
|
|
|
|
for(i=0;i<v;i++)
|
|
|
|
{
|
|
|
|
// the current segment is below the bottom line of the splittable area
|
|
|
|
// (IOW. the whole wall has been done)
|
|
|
|
if (splitrect[i].top>=splitbotv) break;
|
|
|
|
|
|
|
|
float splitbot=splitrect[i].top+splitrect[i].height;
|
|
|
|
|
|
|
|
// the current segment is above the top line of the splittable area
|
|
|
|
if (splitbot<=splittopv) continue;
|
|
|
|
|
|
|
|
split=*this;
|
|
|
|
|
|
|
|
// the top line of the current segment is inside the splittable area
|
|
|
|
// use the splitrect's top as top of this segment
|
|
|
|
// if not use the top of the remaining polygon
|
|
|
|
if (splitrect[i].top>splittopv)
|
|
|
|
{
|
2016-05-05 09:48:39 +00:00
|
|
|
split.ztop[0]=split.ztop[1]= ztop[0]+v_factor*(splitrect[i].top-tcs[UPLFT].v);
|
|
|
|
split.tcs[UPLFT].v=split.tcs[UPRGT].v=splitrect[i].top;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
// the bottom line of the current segment is inside the splittable area
|
|
|
|
// use the splitrect's bottom as bottom of this segment
|
|
|
|
// if not use the bottom of the remaining polygon
|
|
|
|
if (splitbot<=splitbotv)
|
|
|
|
{
|
2016-05-05 09:48:39 +00:00
|
|
|
split.zbottom[0]=split.zbottom[1]=ztop[0]+v_factor*(splitbot-tcs[UPLFT].v);
|
|
|
|
split.tcs[LOLFT].v=split.tcs[LORGT].v=splitbot;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Draw the stuff
|
|
|
|
//
|
|
|
|
//
|
2016-02-05 00:48:53 +00:00
|
|
|
if (realfront->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) split.PutWall(translucent);
|
2016-02-04 14:34:12 +00:00
|
|
|
else split.SplitWall(realfront, translucent);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
t=1;
|
|
|
|
}
|
|
|
|
render_texsplit+=t;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-04 14:34:12 +00:00
|
|
|
//
|
|
|
|
//
|
|
|
|
// Draw the stuff without splitting
|
|
|
|
//
|
|
|
|
//
|
2016-02-05 00:48:53 +00:00
|
|
|
if (realfront->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(translucent);
|
2016-02-04 14:34:12 +00:00
|
|
|
else SplitWall(realfront, translucent);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
alpha=1.0f;
|
|
|
|
}
|
|
|
|
// restore some values that have been altered in this function
|
|
|
|
glseg=glsave;
|
|
|
|
flags&=~(GLT_CLAMPX|GLT_CLAMPY|GLWF_NOSPLITUPPER|GLWF_NOSPLITLOWER);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover,
|
2016-04-07 21:19:37 +00:00
|
|
|
float ff_topleft, float ff_topright,
|
|
|
|
float ff_bottomleft, float ff_bottomright)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
side_t * mastersd = rover->master->sidedef[0];
|
|
|
|
float to;
|
|
|
|
lightlist_t * light;
|
|
|
|
bool translucent;
|
2016-04-07 21:19:37 +00:00
|
|
|
int savelight = lightlevel;
|
|
|
|
FColormap savecolor = Colormap;
|
2013-06-23 07:49:34 +00:00
|
|
|
float ul;
|
|
|
|
float texlength;
|
|
|
|
FTexCoordInfo tci;
|
|
|
|
|
|
|
|
if (rover->flags&FF_FOG)
|
|
|
|
{
|
|
|
|
if (!gl_fixedcolormap)
|
|
|
|
{
|
2013-06-23 08:17:58 +00:00
|
|
|
// this may not yet be done
|
2016-04-07 21:19:37 +00:00
|
|
|
light = P_GetPlaneLight(rover->target, rover->top.plane, true);
|
2013-06-23 07:49:34 +00:00
|
|
|
Colormap.Clear();
|
2016-04-07 21:19:37 +00:00
|
|
|
Colormap.LightColor = (light->extra_colormap)->Fade;
|
2013-06-23 08:17:58 +00:00
|
|
|
// the fog plane defines the light level, not the front sector
|
|
|
|
lightlevel = gl_ClampLight(*light->p_lightlevel);
|
2016-04-07 21:19:37 +00:00
|
|
|
gltexture = NULL;
|
|
|
|
type = RENDERWALL_FFBLOCK;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-07 21:19:37 +00:00
|
|
|
|
|
|
|
if (rover->flags&FF_UPPERTEXTURE)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-07 21:19:37 +00:00
|
|
|
gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::top), false, true);
|
2013-06-23 07:49:34 +00:00
|
|
|
if (!gltexture) return;
|
2016-04-07 23:42:43 +00:00
|
|
|
gltexture->GetTexCoordInfo(&tci, seg->sidedef, side_t::top);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-04-07 21:19:37 +00:00
|
|
|
else if (rover->flags&FF_LOWERTEXTURE)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-08-22 21:50:38 +00:00
|
|
|
gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), false, true);
|
2013-06-23 07:49:34 +00:00
|
|
|
if (!gltexture) return;
|
2016-04-07 23:42:43 +00:00
|
|
|
gltexture->GetTexCoordInfo(&tci, seg->sidedef, side_t::bottom);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-04-07 21:19:37 +00:00
|
|
|
else
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-08-22 21:50:38 +00:00
|
|
|
gltexture = FMaterial::ValidateTexture(mastersd->GetTexture(side_t::mid), false, true);
|
2013-06-23 07:49:34 +00:00
|
|
|
if (!gltexture) return;
|
2016-04-07 23:42:43 +00:00
|
|
|
gltexture->GetTexCoordInfo(&tci, mastersd, side_t::mid);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-04-07 21:19:37 +00:00
|
|
|
|
2016-04-23 09:38:33 +00:00
|
|
|
to = (rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ? 0 : tci.TextureOffset(mastersd->GetTextureXOffset(side_t::mid));
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-23 09:38:33 +00:00
|
|
|
ul = tci.FloatToTexU(to + tci.TextureOffset(seg->sidedef->GetTextureXOffset(side_t::mid)));
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
texlength = tci.FloatToTexU(seg->sidedef->TexelLength);
|
|
|
|
|
2016-05-05 09:48:39 +00:00
|
|
|
tcs[UPLFT].u = tcs[LOLFT].u = ul + texlength * glseg.fracleft;
|
|
|
|
tcs[UPRGT].u = tcs[LORGT].u = ul + texlength * glseg.fracright;
|
2016-04-07 21:19:37 +00:00
|
|
|
|
2016-04-23 09:38:33 +00:00
|
|
|
float rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid));
|
2016-04-07 21:19:37 +00:00
|
|
|
to = (rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ?
|
2016-04-23 09:38:33 +00:00
|
|
|
0.f : tci.RowOffset(mastersd->GetTextureYOffset(side_t::mid));
|
2016-04-07 21:19:37 +00:00
|
|
|
|
2016-04-24 11:35:43 +00:00
|
|
|
to += rowoffset + rover->top.model->GetPlaneTexZ(rover->top.isceiling);
|
2016-04-07 21:19:37 +00:00
|
|
|
|
2016-05-05 09:48:39 +00:00
|
|
|
tcs[UPLFT].v = tci.FloatToTexV(to - ff_topleft);
|
|
|
|
tcs[UPRGT].v = tci.FloatToTexV(to - ff_topright);
|
|
|
|
tcs[LOLFT].v = tci.FloatToTexV(to - ff_bottomleft);
|
|
|
|
tcs[LORGT].v = tci.FloatToTexV(to - ff_bottomright);
|
2016-04-07 21:19:37 +00:00
|
|
|
type = RENDERWALL_FFBLOCK;
|
2013-06-23 07:49:34 +00:00
|
|
|
CheckTexturePosition();
|
|
|
|
}
|
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
ztop[0] = ff_topleft;
|
|
|
|
ztop[1] = ff_topright;
|
|
|
|
zbottom[0] = ff_bottomleft;//-0.001f;
|
|
|
|
zbottom[1] = ff_bottomright;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
if (rover->flags&(FF_TRANSLUCENT | FF_ADDITIVETRANS | FF_FOG))
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-07 21:19:37 +00:00
|
|
|
alpha = rover->alpha / 255.0f;
|
|
|
|
RenderStyle = (rover->flags&FF_ADDITIVETRANS) ? STYLE_Add : STYLE_Translucent;
|
|
|
|
translucent = true;
|
|
|
|
type = gltexture ? RENDERWALL_M2S : RENDERWALL_COLOR;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-04-07 21:19:37 +00:00
|
|
|
else
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-07 21:19:37 +00:00
|
|
|
alpha = 1.0f;
|
|
|
|
RenderStyle = STYLE_Normal;
|
|
|
|
translucent = false;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
sector_t * sec = sub ? sub->sector : seg->frontsector;
|
|
|
|
|
|
|
|
if (sec->e->XFloor.lightlist.Size() == 0 || gl_fixedcolormap) PutWall(translucent);
|
2016-02-04 14:34:12 +00:00
|
|
|
else SplitWall(sec, translucent);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
alpha = 1.0f;
|
2013-06-23 07:49:34 +00:00
|
|
|
lightlevel = savelight;
|
|
|
|
Colormap = savecolor;
|
2016-04-07 21:19:37 +00:00
|
|
|
flags &= ~GLT_CLAMPY;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
__forceinline void GLWall::GetPlanePos(F3DFloor::planeref *planeref, float &left, float &right)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-07 21:19:37 +00:00
|
|
|
left=planeref->plane->ZatPoint(vertexes[0]);
|
|
|
|
right=planeref->plane->ZatPoint(vertexes[1]);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
void GLWall::InverseFloors(seg_t * seg, sector_t * frontsector,
|
2016-04-07 21:19:37 +00:00
|
|
|
float topleft, float topright,
|
|
|
|
float bottomleft, float bottomright)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-07 21:19:37 +00:00
|
|
|
TArray<F3DFloor *> & frontffloors = frontsector->e->XFloor.ffloors;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
for (unsigned int i = 0; i < frontffloors.Size(); i++)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-07 21:19:37 +00:00
|
|
|
F3DFloor * rover = frontffloors[i];
|
2013-06-23 07:49:34 +00:00
|
|
|
if (!(rover->flags&FF_EXISTS)) continue;
|
|
|
|
if (!(rover->flags&FF_RENDERSIDES)) continue;
|
2016-04-07 21:19:37 +00:00
|
|
|
if (!(rover->flags&(FF_INVERTSIDES | FF_ALLSIDES))) continue;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
float ff_topleft;
|
|
|
|
float ff_topright;
|
|
|
|
float ff_bottomleft;
|
|
|
|
float ff_bottomright;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
GetPlanePos(&rover->top, ff_topleft, ff_topright);
|
|
|
|
GetPlanePos(&rover->bottom, ff_bottomleft, ff_bottomright);
|
|
|
|
|
|
|
|
// above ceiling
|
2016-04-07 21:19:37 +00:00
|
|
|
if (ff_bottomleft > topleft && ff_bottomright > topright) continue;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
if (ff_topleft > topleft && ff_topright > topright)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
// the new section overlaps with the previous one - clip it!
|
2016-04-07 21:19:37 +00:00
|
|
|
ff_topleft = topleft;
|
|
|
|
ff_topright = topright;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-04-07 21:19:37 +00:00
|
|
|
if (ff_bottomleft < bottomleft && ff_bottomright < bottomright)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-07 21:19:37 +00:00
|
|
|
ff_bottomleft = bottomleft;
|
|
|
|
ff_bottomright = bottomright;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-04-07 21:19:37 +00:00
|
|
|
if (ff_topleft < ff_bottomleft || ff_topright < ff_bottomright) continue;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
BuildFFBlock(seg, rover, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright);
|
2016-04-07 21:19:37 +00:00
|
|
|
topleft = ff_bottomleft;
|
|
|
|
topright = ff_bottomright;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
if (topleft <= bottomleft && topright <= bottomright) return;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
void GLWall::ClipFFloors(seg_t * seg, F3DFloor * ffloor, sector_t * frontsector,
|
2016-04-07 21:19:37 +00:00
|
|
|
float topleft, float topright,
|
|
|
|
float bottomleft, float bottomright)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-07 21:19:37 +00:00
|
|
|
TArray<F3DFloor *> & frontffloors = frontsector->e->XFloor.ffloors;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
int flags = ffloor->flags & (FF_SWIMMABLE | FF_TRANSLUCENT);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
for (unsigned int i = 0; i < frontffloors.Size(); i++)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-07 21:19:37 +00:00
|
|
|
F3DFloor * rover = frontffloors[i];
|
2013-06-23 07:49:34 +00:00
|
|
|
if (!(rover->flags&FF_EXISTS)) continue;
|
|
|
|
if (!(rover->flags&FF_RENDERSIDES)) continue;
|
2016-04-07 21:19:37 +00:00
|
|
|
if ((rover->flags&(FF_SWIMMABLE | FF_TRANSLUCENT)) != flags) continue;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
float ff_topleft;
|
|
|
|
float ff_topright;
|
|
|
|
float ff_bottomleft;
|
|
|
|
float ff_bottomright;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
GetPlanePos(&rover->top, ff_topleft, ff_topright);
|
|
|
|
|
|
|
|
// we are completely below the bottom so unless there are some
|
|
|
|
// (unsupported) intersections there won't be any more floors that
|
|
|
|
// could clip this one.
|
2016-04-07 21:19:37 +00:00
|
|
|
if (ff_topleft < bottomleft && ff_topright < bottomright) goto done;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
GetPlanePos(&rover->bottom, ff_bottomleft, ff_bottomright);
|
|
|
|
// above top line?
|
2016-04-07 21:19:37 +00:00
|
|
|
if (ff_bottomleft > topleft && ff_bottomright > topright) continue;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
// overlapping the top line
|
2016-04-07 21:19:37 +00:00
|
|
|
if (ff_topleft >= topleft && ff_topright >= topright)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
// overlapping with the entire range
|
2016-04-07 21:19:37 +00:00
|
|
|
if (ff_bottomleft <= bottomleft && ff_bottomright <= bottomright) return;
|
|
|
|
else if (ff_bottomleft > bottomleft && ff_bottomright > bottomright)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-07 21:19:37 +00:00
|
|
|
topleft = ff_bottomleft;
|
|
|
|
topright = ff_bottomright;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// an intersecting case.
|
|
|
|
// proper handling requires splitting but
|
|
|
|
// I don't need this right now.
|
|
|
|
}
|
|
|
|
}
|
2016-04-07 21:19:37 +00:00
|
|
|
else if (ff_topleft <= topleft && ff_topright <= topright)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
BuildFFBlock(seg, ffloor, topleft, topright, ff_topleft, ff_topright);
|
2016-04-07 21:19:37 +00:00
|
|
|
if (ff_bottomleft <= bottomleft && ff_bottomright <= bottomright) return;
|
|
|
|
topleft = ff_bottomleft;
|
|
|
|
topright = ff_bottomright;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// an intersecting case.
|
|
|
|
// proper handling requires splitting but
|
|
|
|
// I don't need this right now.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
// if the program reaches here there is one block left to draw
|
|
|
|
BuildFFBlock(seg, ffloor, topleft, topright, bottomleft, bottomright);
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2016-04-07 21:19:37 +00:00
|
|
|
void GLWall::DoFFloorBlocks(seg_t * seg, sector_t * frontsector, sector_t * backsector,
|
|
|
|
float fch1, float fch2, float ffh1, float ffh2,
|
|
|
|
float bch1, float bch2, float bfh1, float bfh2)
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
{
|
2016-04-07 21:19:37 +00:00
|
|
|
TArray<F3DFloor *> & backffloors = backsector->e->XFloor.ffloors;
|
|
|
|
float topleft, topright, bottomleft, bottomright;
|
|
|
|
bool renderedsomething = false;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
// if the ceilings intersect use the backsector's height because this sector's ceiling will
|
|
|
|
// obstruct the redundant parts.
|
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
if (fch1 < bch1 && fch2 < bch2)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-07 21:19:37 +00:00
|
|
|
topleft = fch1;
|
|
|
|
topright = fch2;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-07 21:19:37 +00:00
|
|
|
topleft = bch1;
|
|
|
|
topright = bch2;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
if (ffh1 > bfh1 && ffh2 > bfh2)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-07 21:19:37 +00:00
|
|
|
bottomleft = ffh1;
|
|
|
|
bottomright = ffh2;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-07 21:19:37 +00:00
|
|
|
bottomleft = bfh1;
|
|
|
|
bottomright = bfh2;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
for (unsigned int i = 0; i < backffloors.Size(); i++)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-07 21:19:37 +00:00
|
|
|
F3DFloor * rover = backffloors[i];
|
2013-06-23 07:49:34 +00:00
|
|
|
if (!(rover->flags&FF_EXISTS)) continue;
|
|
|
|
if (!(rover->flags&FF_RENDERSIDES) || (rover->flags&FF_INVERTSIDES)) continue;
|
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
float ff_topleft;
|
|
|
|
float ff_topright;
|
|
|
|
float ff_bottomleft;
|
|
|
|
float ff_bottomright;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
GetPlanePos(&rover->top, ff_topleft, ff_topright);
|
|
|
|
GetPlanePos(&rover->bottom, ff_bottomleft, ff_bottomright);
|
|
|
|
|
|
|
|
// completely above ceiling
|
2016-04-07 21:19:37 +00:00
|
|
|
if (ff_bottomleft > topleft && ff_bottomright > topright && !renderedsomething) continue;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
if (ff_topleft > topleft && ff_topright > topright)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
// the new section overlaps with the previous one - clip it!
|
2016-04-07 21:19:37 +00:00
|
|
|
ff_topleft = topleft;
|
|
|
|
ff_topright = topright;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// do all inverse floors above the current one it there is a gap between the
|
|
|
|
// last 3D floor and this one.
|
2016-04-07 21:19:37 +00:00
|
|
|
if (topleft > ff_topleft && topright > ff_topright)
|
2013-06-23 07:49:34 +00:00
|
|
|
InverseFloors(seg, frontsector, topleft, topright, ff_topleft, ff_topright);
|
|
|
|
|
|
|
|
// if translucent or liquid clip away adjoining parts of the same type of FFloors on the other side
|
2016-04-07 21:19:37 +00:00
|
|
|
if (rover->flags&(FF_SWIMMABLE | FF_TRANSLUCENT))
|
2013-06-23 07:49:34 +00:00
|
|
|
ClipFFloors(seg, rover, frontsector, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright);
|
|
|
|
else
|
|
|
|
BuildFFBlock(seg, rover, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright);
|
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
topleft = ff_bottomleft;
|
|
|
|
topright = ff_bottomright;
|
|
|
|
renderedsomething = true;
|
|
|
|
if (topleft <= bottomleft && topright <= bottomright) return;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// draw all inverse floors below the lowest one
|
|
|
|
if (frontsector->e->XFloor.ffloors.Size() > 0)
|
|
|
|
{
|
2016-04-07 21:19:37 +00:00
|
|
|
if (topleft > bottomleft || topright > bottomright)
|
2013-06-23 07:49:34 +00:00
|
|
|
InverseFloors(seg, frontsector, topleft, topright, bottomleft, bottomright);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
|
|
|
|
{
|
2014-08-19 12:18:21 +00:00
|
|
|
vertex_t * v1, *v2;
|
2016-04-07 15:00:13 +00:00
|
|
|
float fch1;
|
|
|
|
float ffh1;
|
|
|
|
float fch2;
|
|
|
|
float ffh2;
|
2016-04-07 22:19:51 +00:00
|
|
|
float frefz, crefz;
|
2013-06-23 07:49:34 +00:00
|
|
|
sector_t * realfront;
|
|
|
|
sector_t * realback;
|
2016-01-05 17:59:32 +00:00
|
|
|
sector_t * segfront;
|
|
|
|
sector_t * segback;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
#ifdef _DEBUG
|
2016-04-14 11:22:15 +00:00
|
|
|
if (seg->linedef - lines < 4)
|
2014-05-08 07:48:39 +00:00
|
|
|
{
|
|
|
|
int a = 0;
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
#endif
|
2014-08-19 12:18:21 +00:00
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
// note: we always have a valid sidedef and linedef reference when getting here.
|
|
|
|
|
|
|
|
this->seg = seg;
|
2016-08-25 20:23:31 +00:00
|
|
|
vertindex = 0;
|
|
|
|
vertcount = 0;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
if ((seg->sidedef->Flags & WALLF_POLYOBJ) && seg->backsector)
|
|
|
|
{
|
|
|
|
// Textures on 2-sided polyobjects are aligned to the actual seg's sectors
|
2016-01-05 17:59:32 +00:00
|
|
|
segfront = realfront = seg->frontsector;
|
|
|
|
segback = realback = seg->backsector;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Need these for aligning the textures
|
|
|
|
realfront = §ors[frontsector->sectornum];
|
2014-08-19 12:18:21 +00:00
|
|
|
realback = backsector ? §ors[backsector->sectornum] : NULL;
|
2016-01-05 17:59:32 +00:00
|
|
|
segfront = frontsector;
|
|
|
|
segback = backsector;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-04-24 11:35:43 +00:00
|
|
|
frefz = realfront->GetPlaneTexZ(sector_t::floor);
|
|
|
|
crefz = realfront->GetPlaneTexZ(sector_t::ceiling);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
if (seg->sidedef == seg->linedef->sidedef[0])
|
|
|
|
{
|
2014-08-19 12:18:21 +00:00
|
|
|
v1 = seg->linedef->v1;
|
|
|
|
v2 = seg->linedef->v2;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-08-19 12:18:21 +00:00
|
|
|
v1 = seg->linedef->v2;
|
|
|
|
v2 = seg->linedef->v1;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(seg->sidedef->Flags & WALLF_POLYOBJ))
|
|
|
|
{
|
2014-08-19 12:18:21 +00:00
|
|
|
glseg.fracleft = 0;
|
|
|
|
glseg.fracright = 1;
|
2013-06-23 07:49:34 +00:00
|
|
|
if (gl_seamless)
|
|
|
|
{
|
|
|
|
if (v1->dirty) gl_RecalcVertexHeights(v1);
|
|
|
|
if (v2->dirty) gl_RecalcVertexHeights(v2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // polyobjects must be rendered per seg.
|
|
|
|
{
|
2016-03-29 09:26:33 +00:00
|
|
|
if (fabs(v1->fX() - v2->fX()) > fabs(v1->fY() - v2->fY()))
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-03-29 09:26:33 +00:00
|
|
|
glseg.fracleft = (seg->v1->fX() - v1->fX()) / (v2->fX() - v1->fX());
|
|
|
|
glseg.fracright = (seg->v2->fX() - v1->fX()) / float(v2->fX() - v1->fX());
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-03-29 09:26:33 +00:00
|
|
|
glseg.fracleft = (seg->v1->fY() - v1->fY()) / (v2->fY() - v1->fY());
|
|
|
|
glseg.fracright = (seg->v2->fY() - v1->fY()) / (v2->fY() - v1->fY());
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2014-08-19 12:18:21 +00:00
|
|
|
v1 = seg->v1;
|
|
|
|
v2 = seg->v2;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-19 12:18:21 +00:00
|
|
|
vertexes[0] = v1;
|
|
|
|
vertexes[1] = v2;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-03-29 09:26:33 +00:00
|
|
|
glseg.x1 = v1->fX();
|
|
|
|
glseg.y1 = v1->fY();
|
|
|
|
glseg.x2 = v2->fX();
|
|
|
|
glseg.y2 = v2->fY();
|
2014-08-19 12:18:21 +00:00
|
|
|
Colormap = frontsector->ColorMap;
|
2014-07-15 18:49:21 +00:00
|
|
|
flags = 0;
|
2016-04-26 11:50:05 +00:00
|
|
|
dynlightindex = -1;
|
2016-02-01 00:03:34 +00:00
|
|
|
lightlist = NULL;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
int rel = 0;
|
|
|
|
int orglightlevel = gl_ClampLight(frontsector->lightlevel);
|
2014-07-15 18:49:21 +00:00
|
|
|
bool foggy = (!gl_isBlack(Colormap.FadeColor) || level.flags&LEVEL_HASFADETABLE); // fog disables fake contrast
|
|
|
|
lightlevel = gl_ClampLight(seg->sidedef->GetLightLevel(foggy, orglightlevel, false, &rel));
|
2013-06-23 07:49:34 +00:00
|
|
|
if (orglightlevel >= 253) // with the software renderer fake contrast won't be visible above this.
|
|
|
|
{
|
2014-08-19 12:18:21 +00:00
|
|
|
rellight = 0;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else if (lightlevel - rel > 256) // the brighter part of fake contrast will be clamped so also clamp the darker part by the same amount for better looks
|
2014-08-19 12:18:21 +00:00
|
|
|
{
|
2013-06-23 07:49:34 +00:00
|
|
|
rellight = 256 - lightlevel + rel;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rellight = rel;
|
|
|
|
}
|
|
|
|
|
2014-08-19 12:18:21 +00:00
|
|
|
alpha = 1.0f;
|
|
|
|
RenderStyle = STYLE_Normal;
|
|
|
|
gltexture = NULL;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-08-19 12:18:21 +00:00
|
|
|
topflat = frontsector->GetTexture(sector_t::ceiling); // for glowing textures. These must be saved because
|
|
|
|
bottomflat = frontsector->GetTexture(sector_t::floor); // the sector passed here might be a temporary copy.
|
2014-05-10 15:09:43 +00:00
|
|
|
topplane = frontsector->ceilingplane;
|
|
|
|
bottomplane = frontsector->floorplane;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-07 15:00:13 +00:00
|
|
|
zfloor[0] = ffh1 = segfront->floorplane.ZatPoint(v1);
|
|
|
|
zfloor[1] = ffh2 = segfront->floorplane.ZatPoint(v2);
|
|
|
|
zceil[0] = fch1 = segfront->ceilingplane.ZatPoint(v1);
|
|
|
|
zceil[1] = fch2 = segfront->ceilingplane.ZatPoint(v2);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-08-19 12:18:21 +00:00
|
|
|
if (seg->linedef->special == Line_Horizon)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-08-19 12:18:21 +00:00
|
|
|
SkyNormal(frontsector, v1, v2);
|
|
|
|
DoHorizon(seg, frontsector, v1, v2);
|
2013-06-23 07:49:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//return;
|
|
|
|
// [GZ] 3D middle textures are necessarily two-sided, even if they lack the explicit two-sided flag
|
2014-08-19 12:18:21 +00:00
|
|
|
if (!backsector || !(seg->linedef->flags&(ML_TWOSIDED | ML_3DMIDTEX))) // one sided
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
// sector's sky
|
2014-08-19 12:18:21 +00:00
|
|
|
SkyNormal(frontsector, v1, v2);
|
|
|
|
|
2016-02-06 18:19:18 +00:00
|
|
|
if (seg->linedef->isVisualPortal())
|
|
|
|
{
|
2016-03-04 13:10:13 +00:00
|
|
|
lineportal = linePortalToGL[seg->linedef->portalindex];
|
2016-02-06 18:19:18 +00:00
|
|
|
ztop[0] = zceil[0];
|
|
|
|
ztop[1] = zceil[1];
|
|
|
|
zbottom[0] = zfloor[0];
|
|
|
|
zbottom[1] = zfloor[1];
|
|
|
|
PutPortal(PORTALTYPE_LINETOLINE);
|
|
|
|
}
|
2016-04-20 18:08:53 +00:00
|
|
|
else if (seg->linedef->portaltransferred > 0)
|
|
|
|
{
|
|
|
|
SkyLine(frontsector, seg->linedef);
|
|
|
|
}
|
|
|
|
else
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-01-11 21:44:53 +00:00
|
|
|
// normal texture
|
|
|
|
gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::mid), false, true);
|
|
|
|
if (gltexture)
|
|
|
|
{
|
|
|
|
DoTexture(RENDERWALL_M1S, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0,
|
2016-04-07 22:19:51 +00:00
|
|
|
crefz, frefz, // must come from the original!
|
2016-01-11 21:44:53 +00:00
|
|
|
fch1, fch2, ffh1, ffh2, 0);
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else // two sided
|
|
|
|
{
|
2016-04-07 15:00:13 +00:00
|
|
|
float bfh1 = segback->floorplane.ZatPoint(v1);
|
|
|
|
float bfh2 = segback->floorplane.ZatPoint(v2);
|
|
|
|
float bch1 = segback->ceilingplane.ZatPoint(v1);
|
|
|
|
float bch2 = segback->ceilingplane.ZatPoint(v2);
|
2016-04-07 21:19:37 +00:00
|
|
|
|
2014-08-19 12:18:21 +00:00
|
|
|
SkyTop(seg, frontsector, backsector, v1, v2);
|
|
|
|
SkyBottom(seg, frontsector, backsector, v1, v2);
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
// upper texture
|
2014-08-19 12:18:21 +00:00
|
|
|
if (frontsector->GetTexture(sector_t::ceiling) != skyflatnum || backsector->GetTexture(sector_t::ceiling) != skyflatnum)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-07 15:00:13 +00:00
|
|
|
float bch1a = bch1, bch2a = bch2;
|
2014-08-19 12:18:21 +00:00
|
|
|
if (frontsector->GetTexture(sector_t::floor) != skyflatnum || backsector->GetTexture(sector_t::floor) != skyflatnum)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
// the back sector's floor obstructs part of this wall
|
2014-08-19 12:18:21 +00:00
|
|
|
if (ffh1 > bch1 && ffh2 > bch2)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-08-19 12:18:21 +00:00
|
|
|
bch2a = ffh2;
|
|
|
|
bch1a = ffh1;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-19 12:18:21 +00:00
|
|
|
if (bch1a < fch1 || bch2a < fch2)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-08-22 21:50:38 +00:00
|
|
|
gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::top), false, true);
|
2014-08-19 12:18:21 +00:00
|
|
|
if (gltexture)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-08-19 12:18:21 +00:00
|
|
|
DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0,
|
2016-04-24 11:35:43 +00:00
|
|
|
crefz, realback->GetPlaneTexZ(sector_t::ceiling),
|
2014-08-19 12:18:21 +00:00
|
|
|
fch1, fch2, bch1a, bch2a, 0);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-01-05 17:59:32 +00:00
|
|
|
else if (!(seg->sidedef->Flags & WALLF_POLYOBJ))
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-03-29 11:45:50 +00:00
|
|
|
if ((frontsector->ceilingplane.isSlope() || backsector->ceilingplane.isSlope()) &&
|
2016-01-05 17:59:32 +00:00
|
|
|
frontsector->GetTexture(sector_t::ceiling) != skyflatnum &&
|
|
|
|
backsector->GetTexture(sector_t::ceiling) != skyflatnum)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-01-05 17:59:32 +00:00
|
|
|
gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::ceiling), false, true);
|
|
|
|
if (gltexture)
|
|
|
|
{
|
|
|
|
DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0,
|
2016-04-24 11:35:43 +00:00
|
|
|
crefz, realback->GetPlaneTexZ(sector_t::ceiling),
|
2016-01-05 17:59:32 +00:00
|
|
|
fch1, fch2, bch1a, bch2a, 0);
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-01-05 17:59:32 +00:00
|
|
|
else
|
2014-08-31 21:01:53 +00:00
|
|
|
{
|
2016-01-05 17:59:32 +00:00
|
|
|
// skip processing if the back is a malformed subsector
|
|
|
|
if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4))
|
|
|
|
{
|
2016-04-07 23:42:43 +00:00
|
|
|
gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, bch1a);
|
2016-01-05 17:59:32 +00:00
|
|
|
}
|
2014-08-31 21:01:53 +00:00
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* mid texture */
|
|
|
|
bool drawfogboundary = gl_CheckFog(frontsector, backsector);
|
|
|
|
FTexture *tex = TexMan(seg->sidedef->GetTexture(side_t::mid));
|
|
|
|
if (tex != NULL)
|
|
|
|
{
|
|
|
|
if (i_compatflags & COMPATF_MASKEDMIDTEX)
|
|
|
|
{
|
|
|
|
tex = tex->GetRawTexture();
|
|
|
|
}
|
2014-08-22 21:50:38 +00:00
|
|
|
gltexture = FMaterial::ValidateTexture(tex, false);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else gltexture = NULL;
|
|
|
|
|
|
|
|
if (gltexture || drawfogboundary)
|
|
|
|
{
|
2014-08-19 12:18:21 +00:00
|
|
|
DoMidTexture(seg, drawfogboundary, frontsector, backsector, realfront, realback,
|
2016-04-07 21:19:37 +00:00
|
|
|
fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
2016-02-06 04:17:47 +00:00
|
|
|
if (seg->linedef->isVisualPortal() && seg->sidedef == seg->linedef->sidedef[0])
|
|
|
|
{
|
2016-03-04 13:10:13 +00:00
|
|
|
lineportal = linePortalToGL[seg->linedef->portalindex];
|
2016-04-07 15:00:13 +00:00
|
|
|
ztop[0] = bch1;
|
|
|
|
ztop[1] = bch2;
|
|
|
|
zbottom[0] = bfh1;
|
|
|
|
zbottom[1] = bfh2;
|
2016-02-06 18:19:18 +00:00
|
|
|
PutPortal(PORTALTYPE_LINETOLINE);
|
2016-02-06 04:17:47 +00:00
|
|
|
}
|
|
|
|
else if (backsector->e->XFloor.ffloors.Size() || frontsector->e->XFloor.ffloors.Size())
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-07 21:19:37 +00:00
|
|
|
DoFFloorBlocks(seg, frontsector, backsector, fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2014-08-19 12:18:21 +00:00
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
/* bottom texture */
|
|
|
|
// the back sector's ceiling obstructs part of this wall (specially important for sky sectors)
|
2016-04-07 15:00:13 +00:00
|
|
|
if (fch1 < bfh1 && fch2 < bfh2)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-08-19 12:18:21 +00:00
|
|
|
bfh1 = fch1;
|
|
|
|
bfh2 = fch2;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
if (bfh1 > ffh1 || bfh2 > ffh2)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-08-22 21:50:38 +00:00
|
|
|
gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), false, true);
|
2014-08-19 12:18:21 +00:00
|
|
|
if (gltexture)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-08-19 12:18:21 +00:00
|
|
|
DoTexture(RENDERWALL_BOTTOM, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0,
|
2016-04-24 11:35:43 +00:00
|
|
|
realback->GetPlaneTexZ(sector_t::floor), frefz,
|
2014-08-19 12:18:21 +00:00
|
|
|
bfh1, bfh2, ffh1, ffh2,
|
|
|
|
frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum ?
|
2016-04-24 11:35:43 +00:00
|
|
|
frefz - realback->GetPlaneTexZ(sector_t::ceiling) :
|
2016-04-07 22:19:51 +00:00
|
|
|
frefz - crefz);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-01-05 17:59:32 +00:00
|
|
|
else if (!(seg->sidedef->Flags & WALLF_POLYOBJ))
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-13 09:41:51 +00:00
|
|
|
if ((frontsector->floorplane.isSlope() || backsector->floorplane.isSlope()) &&
|
2016-01-05 17:59:32 +00:00
|
|
|
frontsector->GetTexture(sector_t::floor) != skyflatnum &&
|
|
|
|
backsector->GetTexture(sector_t::floor) != skyflatnum)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-01-05 17:59:32 +00:00
|
|
|
// render it anyway with the sector's floor texture. With a background sky
|
|
|
|
// there are ugly holes otherwise and slopes are simply not precise enough
|
|
|
|
// to mach in any case.
|
|
|
|
gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), false, true);
|
|
|
|
if (gltexture)
|
|
|
|
{
|
|
|
|
DoTexture(RENDERWALL_BOTTOM, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0,
|
2016-04-24 11:35:43 +00:00
|
|
|
realback->GetPlaneTexZ(sector_t::floor), frefz,
|
2016-04-07 22:19:51 +00:00
|
|
|
bfh1, bfh2, ffh1, ffh2, frefz - crefz);
|
2016-01-05 17:59:32 +00:00
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-01-05 17:59:32 +00:00
|
|
|
else if (backsector->GetTexture(sector_t::floor) != skyflatnum)
|
2014-08-31 21:01:53 +00:00
|
|
|
{
|
2016-01-05 17:59:32 +00:00
|
|
|
// skip processing if the back is a malformed subsector
|
|
|
|
if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4))
|
|
|
|
{
|
2016-04-07 23:42:43 +00:00
|
|
|
gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, bfh1);
|
2016-01-05 17:59:32 +00:00
|
|
|
}
|
2014-08-31 21:01:53 +00:00
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * backsector)
|
|
|
|
{
|
2014-08-19 12:18:21 +00:00
|
|
|
if (frontsector->GetTexture(sector_t::floor) == skyflatnum) return;
|
2016-02-04 14:34:12 +00:00
|
|
|
lightlist = NULL;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-24 11:35:43 +00:00
|
|
|
float ffh = frontsector->GetPlaneTexZ(sector_t::floor);
|
|
|
|
float bfh = backsector->GetPlaneTexZ(sector_t::floor);
|
2016-08-25 20:23:31 +00:00
|
|
|
|
|
|
|
vertindex = 0;
|
|
|
|
vertcount = 0;
|
2014-08-19 12:18:21 +00:00
|
|
|
if (bfh > ffh)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
this->seg = seg;
|
|
|
|
this->sub = NULL;
|
|
|
|
|
2014-08-19 12:18:21 +00:00
|
|
|
vertex_t * v1 = seg->v1;
|
|
|
|
vertex_t * v2 = seg->v2;
|
|
|
|
vertexes[0] = v1;
|
|
|
|
vertexes[1] = v2;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-03-29 09:26:33 +00:00
|
|
|
glseg.x1 = v1->fX();
|
|
|
|
glseg.y1 = v1->fY();
|
|
|
|
glseg.x2 = v2->fX();
|
|
|
|
glseg.y2 = v2->fY();
|
2013-06-23 07:49:34 +00:00
|
|
|
glseg.fracleft = 0;
|
|
|
|
glseg.fracright = 1;
|
|
|
|
|
2014-07-15 18:49:21 +00:00
|
|
|
flags = 0;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
// can't do fake contrast without a sidedef
|
|
|
|
lightlevel = gl_ClampLight(frontsector->lightlevel);
|
|
|
|
rellight = 0;
|
|
|
|
|
|
|
|
alpha = 1.0f;
|
|
|
|
RenderStyle = STYLE_Normal;
|
|
|
|
Colormap = frontsector->ColorMap;
|
|
|
|
|
|
|
|
topflat = frontsector->GetTexture(sector_t::ceiling); // for glowing textures
|
|
|
|
bottomflat = frontsector->GetTexture(sector_t::floor);
|
2014-05-10 15:09:43 +00:00
|
|
|
topplane = frontsector->ceilingplane;
|
|
|
|
bottomplane = frontsector->floorplane;
|
2016-04-26 11:50:05 +00:00
|
|
|
dynlightindex = -1;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-07 21:19:37 +00:00
|
|
|
zfloor[0] = zfloor[1] = ffh;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-08-22 21:50:38 +00:00
|
|
|
gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), false, true);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-08-19 12:18:21 +00:00
|
|
|
if (gltexture)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
FTexCoordInfo tci;
|
2014-08-19 12:18:21 +00:00
|
|
|
type = RENDERWALL_BOTTOM;
|
2016-04-07 23:42:43 +00:00
|
|
|
gltexture->GetTexCoordInfo(&tci, 1.f, 1.f);
|
2016-04-07 21:19:37 +00:00
|
|
|
SetWallCoordinates(seg, &tci, bfh, bfh, bfh, ffh, ffh, 0);
|
2016-02-05 00:48:53 +00:00
|
|
|
PutWall(false);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|