2017-04-17 10:27:19 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
2017-01-26 07:13:39 +00:00
|
|
|
//
|
2017-04-17 10:27:19 +00:00
|
|
|
// Copyright 1993-1996 id Software
|
|
|
|
// Copyright 1999-2016 Randy Heit
|
|
|
|
// Copyright 2016 Magnus Norddahl
|
2017-01-26 07:13:39 +00:00
|
|
|
//
|
2017-04-17 10:27:19 +00:00
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2017-01-26 07:13:39 +00:00
|
|
|
//
|
2017-04-17 10:27:19 +00:00
|
|
|
// This program is distributed in the hope that it will be useful,
|
2017-01-26 07:13:39 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2017-04-17 10:27:19 +00:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see http://www.gnu.org/licenses/
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
2017-01-26 07:13:39 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "templates.h"
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "m_bbox.h"
|
|
|
|
#include "i_system.h"
|
|
|
|
#include "p_lnspec.h"
|
|
|
|
#include "p_setup.h"
|
|
|
|
#include "a_sharedglobal.h"
|
|
|
|
#include "g_level.h"
|
2017-03-06 21:58:48 +00:00
|
|
|
#include "g_levellocals.h"
|
2017-01-26 07:13:39 +00:00
|
|
|
#include "p_effect.h"
|
|
|
|
#include "doomstat.h"
|
|
|
|
#include "r_state.h"
|
|
|
|
#include "v_palette.h"
|
|
|
|
#include "r_sky.h"
|
|
|
|
#include "po_man.h"
|
|
|
|
#include "r_data/colormaps.h"
|
|
|
|
#include "d_net.h"
|
|
|
|
#include "swrenderer/r_memory.h"
|
2017-02-03 23:25:37 +00:00
|
|
|
#include "swrenderer/r_renderthread.h"
|
2017-01-26 07:13:39 +00:00
|
|
|
#include "swrenderer/drawers/r_draw.h"
|
|
|
|
#include "swrenderer/scene/r_3dfloors.h"
|
|
|
|
#include "swrenderer/scene/r_opaque_pass.h"
|
|
|
|
#include "swrenderer/scene/r_portal.h"
|
|
|
|
#include "swrenderer/line/r_wallsetup.h"
|
|
|
|
#include "swrenderer/line/r_walldraw.h"
|
|
|
|
#include "swrenderer/line/r_fogboundary.h"
|
|
|
|
#include "swrenderer/line/r_renderdrawsegment.h"
|
|
|
|
#include "swrenderer/segments/r_drawsegment.h"
|
|
|
|
#include "swrenderer/things/r_visiblesprite.h"
|
|
|
|
#include "swrenderer/scene/r_light.h"
|
2017-02-02 14:10:06 +00:00
|
|
|
#include "swrenderer/viewport/r_viewport.h"
|
|
|
|
#include "swrenderer/viewport/r_spritedrawer.h"
|
2017-01-28 22:37:57 +00:00
|
|
|
|
|
|
|
EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
|
2017-01-26 07:13:39 +00:00
|
|
|
|
|
|
|
namespace swrenderer
|
|
|
|
{
|
2017-02-03 23:25:37 +00:00
|
|
|
RenderDrawSegment::RenderDrawSegment(RenderThread *thread)
|
|
|
|
{
|
|
|
|
Thread = thread;
|
|
|
|
}
|
|
|
|
|
2018-03-08 03:05:35 +00:00
|
|
|
void RenderDrawSegment::Render(DrawSegment *ds, int x1, int x2, Fake3DTranslucent clip3DFloor)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
2017-03-12 17:54:39 +00:00
|
|
|
auto viewport = Thread->Viewport.get();
|
2017-01-26 07:13:39 +00:00
|
|
|
|
|
|
|
curline = ds->curline;
|
2018-03-08 03:05:35 +00:00
|
|
|
m3DFloor = clip3DFloor;
|
2017-01-26 07:13:39 +00:00
|
|
|
|
2017-01-30 10:25:25 +00:00
|
|
|
float alpha = (float)MIN(curline->linedef->alpha, 1.);
|
|
|
|
bool additive = (curline->linedef->flags & ML_ADDTRANS) != 0;
|
2017-01-29 09:05:37 +00:00
|
|
|
|
|
|
|
WallDrawerArgs walldrawerargs;
|
2017-01-30 10:25:25 +00:00
|
|
|
walldrawerargs.SetStyle(true, additive, FLOAT2FIXED(alpha));
|
2017-01-29 09:05:37 +00:00
|
|
|
|
2017-01-30 10:27:58 +00:00
|
|
|
SpriteDrawerArgs columndrawerargs;
|
2017-01-30 10:25:25 +00:00
|
|
|
FDynamicColormap *patchstylecolormap = nullptr;
|
2017-03-12 17:54:39 +00:00
|
|
|
bool visible = columndrawerargs.SetStyle(viewport, LegacyRenderStyles[additive ? STYLE_Add : STYLE_Translucent], alpha, 0, 0, patchstylecolormap);
|
2017-01-26 07:13:39 +00:00
|
|
|
|
2017-07-02 13:35:29 +00:00
|
|
|
if (!visible && !ds->bFogBoundary && !ds->Has3DFloorWalls())
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-04 18:13:56 +00:00
|
|
|
if (Thread->MainThread)
|
|
|
|
NetUpdate();
|
2017-01-26 07:13:39 +00:00
|
|
|
|
|
|
|
frontsector = curline->frontsector;
|
|
|
|
backsector = curline->backsector;
|
|
|
|
|
|
|
|
// killough 4/13/98: get correct lightlevel for 2s normal textures
|
2017-06-18 22:55:32 +00:00
|
|
|
sector_t tempsec;
|
|
|
|
const sector_t *sec = Thread->OpaquePass->FakeFlat(frontsector, &tempsec, nullptr, nullptr, nullptr, 0, 0, 0, 0);
|
2017-01-26 07:13:39 +00:00
|
|
|
|
2017-03-15 22:24:53 +00:00
|
|
|
FDynamicColormap *basecolormap = GetColorTable(sec->Colormap, sec->SpecialColors[sector_t::walltop]); // [RH] Set basecolormap
|
2017-01-26 07:13:39 +00:00
|
|
|
|
|
|
|
int wallshade = ds->shade;
|
|
|
|
rw_lightstep = ds->lightstep;
|
|
|
|
rw_light = ds->light + (x1 - ds->x1) * rw_lightstep;
|
|
|
|
|
2017-02-06 15:04:27 +00:00
|
|
|
Clip3DFloors *clip3d = Thread->Clip3D.get();
|
2017-01-26 07:13:39 +00:00
|
|
|
|
2017-01-26 09:22:54 +00:00
|
|
|
CameraLight *cameraLight = CameraLight::Instance();
|
2017-02-03 08:00:46 +00:00
|
|
|
if (cameraLight->FixedLightLevel() < 0)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
2018-03-09 00:30:47 +00:00
|
|
|
double clipTop = m3DFloor.clipTop ? m3DFloor.sclipTop : sec->ceilingplane.ZatPoint(Thread->Viewport->viewpoint.Pos);
|
2017-06-18 22:55:32 +00:00
|
|
|
for (int i = frontsector->e->XFloor.lightlist.Size() - 1; i >= 0; i--)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
2018-03-09 00:30:47 +00:00
|
|
|
if (clipTop <= frontsector->e->XFloor.lightlist[i].plane.Zat0())
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
|
|
|
lightlist_t *lit = &frontsector->e->XFloor.lightlist[i];
|
2017-03-15 22:24:53 +00:00
|
|
|
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
2017-03-06 21:58:48 +00:00
|
|
|
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
|
2017-03-12 17:54:39 +00:00
|
|
|
wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + LightVisibility::ActualExtraLight(ds->foggy, viewport), foggy);
|
2017-01-26 07:13:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// [RH] Draw fog partition
|
2017-06-19 18:36:28 +00:00
|
|
|
bool renderwall = true;
|
2017-06-18 22:55:32 +00:00
|
|
|
bool notrelevant = false;
|
2017-01-26 07:13:39 +00:00
|
|
|
if (ds->bFogBoundary)
|
|
|
|
{
|
2018-03-07 23:55:37 +00:00
|
|
|
const short *mfloorclip = ds->sprbottomclip - ds->x1;
|
|
|
|
const short *mceilingclip = ds->sprtopclip - ds->x1;
|
2017-06-18 22:55:32 +00:00
|
|
|
|
|
|
|
RenderFogBoundary renderfog;
|
2017-02-04 11:38:05 +00:00
|
|
|
renderfog.Render(Thread, x1, x2, mceilingclip, mfloorclip, wallshade, rw_light, rw_lightstep, basecolormap);
|
2017-06-18 22:55:32 +00:00
|
|
|
|
2017-06-19 18:36:28 +00:00
|
|
|
if (ds->maskedtexturecol == nullptr)
|
|
|
|
renderwall = false;
|
2017-06-18 22:55:32 +00:00
|
|
|
}
|
2017-07-02 13:35:29 +00:00
|
|
|
else if ((ds->Has3DFloorWalls() && !ds->Has3DFloorMidTexture()) || !visible)
|
2017-06-18 22:55:32 +00:00
|
|
|
{
|
2017-06-19 18:36:28 +00:00
|
|
|
renderwall = false;
|
2017-06-18 22:55:32 +00:00
|
|
|
}
|
|
|
|
|
2017-06-19 18:36:28 +00:00
|
|
|
if (renderwall)
|
2018-03-08 00:28:23 +00:00
|
|
|
notrelevant = RenderWall(ds, x1, x2, walldrawerargs, columndrawerargs, visible, basecolormap, wallshade);
|
2017-06-19 18:36:28 +00:00
|
|
|
|
2017-07-02 13:35:29 +00:00
|
|
|
if (ds->Has3DFloorFrontSectorWalls() || ds->Has3DFloorBackSectorWalls())
|
2017-06-18 22:55:32 +00:00
|
|
|
{
|
|
|
|
RenderFakeWallRange(ds, x1, x2, wallshade);
|
|
|
|
}
|
|
|
|
if (!notrelevant)
|
|
|
|
{
|
2018-03-08 00:28:23 +00:00
|
|
|
ds->sprclipped = true;
|
|
|
|
fillshort(ds->sprtopclip - ds->x1 + x1, x2 - x1, viewheight);
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
2017-06-18 22:55:32 +00:00
|
|
|
}
|
|
|
|
|
2018-03-08 00:28:23 +00:00
|
|
|
bool RenderDrawSegment::RenderWall(DrawSegment *ds, int x1, int x2, WallDrawerArgs &walldrawerargs, SpriteDrawerArgs &columndrawerargs, bool visible, FDynamicColormap *basecolormap, int wallshade)
|
2017-06-18 22:55:32 +00:00
|
|
|
{
|
2018-03-18 20:33:44 +00:00
|
|
|
auto renderstyle = DefaultRenderStyle();
|
2017-06-18 22:55:32 +00:00
|
|
|
auto viewport = Thread->Viewport.get();
|
|
|
|
Clip3DFloors *clip3d = Thread->Clip3D.get();
|
|
|
|
|
|
|
|
FTexture *tex = TexMan(curline->sidedef->GetTexture(side_t::mid), true);
|
|
|
|
if (i_compatflags & COMPATF_MASKEDMIDTEX)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
2017-06-18 22:55:32 +00:00
|
|
|
tex = tex->GetRawTexture();
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
|
|
|
|
2018-03-07 23:55:37 +00:00
|
|
|
const short *mfloorclip = ds->sprbottomclip - ds->x1;
|
|
|
|
const short *mceilingclip = ds->sprtopclip - ds->x1;
|
2017-06-18 22:55:32 +00:00
|
|
|
|
|
|
|
float *MaskedSWall = ds->swall - ds->x1;
|
|
|
|
float MaskedScaleY = ds->yscale;
|
|
|
|
fixed_t *maskedtexturecol = ds->maskedtexturecol - ds->x1;
|
|
|
|
double spryscale = ds->iscale + ds->iscalestep * (x1 - ds->x1);
|
|
|
|
float rw_scalestep = ds->iscalestep;
|
2017-01-26 07:13:39 +00:00
|
|
|
|
2017-06-18 22:55:32 +00:00
|
|
|
CameraLight *cameraLight = CameraLight::Instance();
|
2017-02-03 08:00:46 +00:00
|
|
|
if (cameraLight->FixedLightLevel() >= 0)
|
2017-01-29 09:05:37 +00:00
|
|
|
{
|
2017-03-06 22:27:02 +00:00
|
|
|
walldrawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, cameraLight->FixedLightLevelShade());
|
|
|
|
columndrawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, cameraLight->FixedLightLevelShade());
|
2017-01-29 09:05:37 +00:00
|
|
|
}
|
2017-02-03 08:00:46 +00:00
|
|
|
else if (cameraLight->FixedColormap() != nullptr)
|
2017-01-29 09:05:37 +00:00
|
|
|
{
|
2017-02-03 08:00:46 +00:00
|
|
|
walldrawerargs.SetLight(cameraLight->FixedColormap(), 0, 0);
|
|
|
|
columndrawerargs.SetLight(cameraLight->FixedColormap(), 0, 0);
|
2017-01-29 09:05:37 +00:00
|
|
|
}
|
2017-01-26 07:13:39 +00:00
|
|
|
|
|
|
|
// find positioning
|
2017-06-18 22:55:32 +00:00
|
|
|
double texheight = tex->GetScaledHeightDouble();
|
|
|
|
double texheightscale = fabs(curline->sidedef->GetTextureYScale(side_t::mid));
|
2017-01-26 07:13:39 +00:00
|
|
|
if (texheightscale != 1)
|
|
|
|
{
|
|
|
|
texheight = texheight / texheightscale;
|
|
|
|
}
|
|
|
|
|
|
|
|
double texturemid;
|
|
|
|
if (curline->linedef->flags & ML_DONTPEGBOTTOM)
|
|
|
|
{
|
|
|
|
texturemid = MAX(frontsector->GetPlaneTexZ(sector_t::floor), backsector->GetPlaneTexZ(sector_t::floor)) + texheight;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
texturemid = MIN(frontsector->GetPlaneTexZ(sector_t::ceiling), backsector->GetPlaneTexZ(sector_t::ceiling));
|
|
|
|
}
|
|
|
|
|
2017-06-18 22:55:32 +00:00
|
|
|
double rowoffset = curline->sidedef->GetTextureYOffset(side_t::mid);
|
2017-01-26 07:13:39 +00:00
|
|
|
|
2018-03-08 00:28:23 +00:00
|
|
|
bool wrap = (curline->linedef->flags & ML_WRAP_MIDTEX) || (curline->sidedef->Flags & WALLF_WRAP_MIDTEX);
|
2017-01-26 07:13:39 +00:00
|
|
|
if (!wrap)
|
|
|
|
{ // Texture does not wrap vertically.
|
|
|
|
double textop;
|
|
|
|
|
2017-06-18 22:55:32 +00:00
|
|
|
bool sprflipvert = false;
|
|
|
|
|
2017-01-26 07:13:39 +00:00
|
|
|
if (MaskedScaleY < 0)
|
|
|
|
{
|
|
|
|
MaskedScaleY = -MaskedScaleY;
|
|
|
|
sprflipvert = true;
|
|
|
|
}
|
|
|
|
if (tex->bWorldPanning)
|
|
|
|
{
|
|
|
|
// rowoffset is added before the multiply so that the masked texture will
|
|
|
|
// still be positioned in world units rather than texels.
|
2017-03-12 17:54:39 +00:00
|
|
|
texturemid += rowoffset - Thread->Viewport->viewpoint.Pos.Z;
|
2017-01-26 07:13:39 +00:00
|
|
|
textop = texturemid;
|
|
|
|
texturemid *= MaskedScaleY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// rowoffset is added outside the multiply so that it positions the texture
|
|
|
|
// by texels instead of world units.
|
2017-03-12 17:54:39 +00:00
|
|
|
textop = texturemid + rowoffset / MaskedScaleY - Thread->Viewport->viewpoint.Pos.Z;
|
|
|
|
texturemid = (texturemid - Thread->Viewport->viewpoint.Pos.Z) * MaskedScaleY + rowoffset;
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
|
|
|
if (sprflipvert)
|
|
|
|
{
|
|
|
|
MaskedScaleY = -MaskedScaleY;
|
|
|
|
texturemid -= tex->GetHeight() << FRACBITS;
|
|
|
|
}
|
|
|
|
|
|
|
|
// [RH] Don't bother drawing segs that are completely offscreen
|
2017-02-01 15:02:21 +00:00
|
|
|
if (viewport->globaldclip * ds->sz1 < -textop && viewport->globaldclip * ds->sz2 < -textop)
|
2017-01-26 07:13:39 +00:00
|
|
|
{ // Texture top is below the bottom of the screen
|
2017-06-18 22:55:32 +00:00
|
|
|
return false;
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
|
|
|
|
2017-02-01 15:02:21 +00:00
|
|
|
if (viewport->globaluclip * ds->sz1 > texheight - textop && viewport->globaluclip * ds->sz2 > texheight - textop)
|
2017-01-26 07:13:39 +00:00
|
|
|
{ // Texture bottom is above the top of the screen
|
2017-06-18 22:55:32 +00:00
|
|
|
return false;
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
|
|
|
|
2018-03-08 03:05:35 +00:00
|
|
|
if (m3DFloor.clipBottom && textop < m3DFloor.sclipBottom - Thread->Viewport->viewpoint.Pos.Z)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
2017-06-18 22:55:32 +00:00
|
|
|
return true;
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
2018-03-08 03:05:35 +00:00
|
|
|
if (m3DFloor.clipTop && textop - texheight > m3DFloor.sclipTop - Thread->Viewport->viewpoint.Pos.Z)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
2017-06-18 22:55:32 +00:00
|
|
|
return true;
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WallC.sz1 = ds->sz1;
|
|
|
|
WallC.sz2 = ds->sz2;
|
|
|
|
WallC.sx1 = ds->sx1;
|
|
|
|
WallC.sx2 = ds->sx2;
|
|
|
|
|
2018-04-04 23:40:58 +00:00
|
|
|
// Unclipped vanilla Doom range for the wall. Relies on ceiling/floor clip to clamp the wall in range.
|
|
|
|
double ceilZ = textop;
|
|
|
|
double floorZ = textop - texheight;
|
2018-03-09 00:30:47 +00:00
|
|
|
|
2018-04-04 23:40:58 +00:00
|
|
|
// The 3D Floors implementation destroys the ceiling clip when doing its height passes..
|
|
|
|
if (m3DFloor.clipTop || m3DFloor.clipBottom)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
2018-04-04 23:40:58 +00:00
|
|
|
// Use the actual correct wall range for the midtexture.
|
|
|
|
// This doesn't work for self-referenced sectors, which is why we only do it if we have 3D floors.
|
|
|
|
|
|
|
|
double top, bot;
|
|
|
|
GetMaskedWallTopBottom(ds, top, bot);
|
|
|
|
top -= Thread->Viewport->viewpoint.Pos.Z;
|
|
|
|
bot -= Thread->Viewport->viewpoint.Pos.Z;
|
|
|
|
|
|
|
|
ceilZ = MIN(ceilZ, top);
|
|
|
|
floorZ = MAX(floorZ, bot);
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
2018-04-04 23:40:58 +00:00
|
|
|
|
|
|
|
// Clip wall by the current 3D floor render range.
|
|
|
|
if (m3DFloor.clipTop)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
2018-04-04 23:40:58 +00:00
|
|
|
double clipZ = m3DFloor.sclipTop - Thread->Viewport->viewpoint.Pos.Z;
|
|
|
|
ceilZ = MIN(ceilZ, clipZ);
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
2018-03-08 03:05:35 +00:00
|
|
|
if (m3DFloor.clipBottom)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
2018-04-04 23:40:58 +00:00
|
|
|
double clipZ = m3DFloor.sclipBottom - Thread->Viewport->viewpoint.Pos.Z;
|
|
|
|
floorZ = MAX(floorZ, clipZ);
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 23:40:58 +00:00
|
|
|
wallupper.Project(Thread->Viewport.get(), ceilZ, &WallC);
|
|
|
|
walllower.Project(Thread->Viewport.get(), floorZ, &WallC);
|
|
|
|
|
2017-06-18 22:55:32 +00:00
|
|
|
for (int i = x1; i < x2; i++)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
|
|
|
if (wallupper.ScreenY[i] < mceilingclip[i])
|
|
|
|
wallupper.ScreenY[i] = mceilingclip[i];
|
|
|
|
}
|
2017-06-18 22:55:32 +00:00
|
|
|
for (int i = x1; i < x2; i++)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
|
|
|
if (walllower.ScreenY[i] > mfloorclip[i])
|
|
|
|
walllower.ScreenY[i] = mfloorclip[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (clip3d->CurrentSkybox)
|
|
|
|
{ // Midtex clipping doesn't work properly with skyboxes, since you're normally below the floor
|
|
|
|
// or above the ceiling, so the appropriate end won't be clipped automatically when adding
|
|
|
|
// this drawseg.
|
|
|
|
if ((curline->linedef->flags & ML_CLIP_MIDTEX) ||
|
2017-02-23 11:32:53 +00:00
|
|
|
(curline->sidedef->Flags & WALLF_CLIP_MIDTEX) ||
|
|
|
|
(ib_compatflags & BCOMPATF_CLIPMIDTEX))
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
|
|
|
ClipMidtex(x1, x2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mfloorclip = walllower.ScreenY;
|
|
|
|
mceilingclip = wallupper.ScreenY;
|
|
|
|
|
|
|
|
// draw the columns one at a time
|
|
|
|
if (visible)
|
|
|
|
{
|
2018-03-18 20:33:44 +00:00
|
|
|
Thread->PrepareTexture(tex, renderstyle);
|
2017-01-26 07:13:39 +00:00
|
|
|
for (int x = x1; x < x2; ++x)
|
|
|
|
{
|
2017-02-03 08:00:46 +00:00
|
|
|
if (cameraLight->FixedColormap() == nullptr && cameraLight->FixedLightLevel() < 0)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
2017-02-02 10:16:18 +00:00
|
|
|
columndrawerargs.SetLight(basecolormap, rw_light, wallshade);
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fixed_t iscale = xs_Fix<16>::ToFix(MaskedSWall[x] * MaskedScaleY);
|
|
|
|
double sprtopscreen;
|
|
|
|
if (sprflipvert)
|
2017-02-01 15:02:21 +00:00
|
|
|
sprtopscreen = viewport->CenterY + texturemid * spryscale;
|
2017-01-26 07:13:39 +00:00
|
|
|
else
|
2017-02-01 15:02:21 +00:00
|
|
|
sprtopscreen = viewport->CenterY - texturemid * spryscale;
|
2017-01-26 07:13:39 +00:00
|
|
|
|
2018-03-18 20:33:44 +00:00
|
|
|
columndrawerargs.DrawMaskedColumn(Thread, x, iscale, tex, maskedtexturecol[x], spryscale, sprtopscreen, sprflipvert, mfloorclip, mceilingclip, renderstyle);
|
2017-01-26 07:13:39 +00:00
|
|
|
|
|
|
|
rw_light += rw_lightstep;
|
|
|
|
spryscale += rw_scalestep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // Texture does wrap vertically.
|
|
|
|
if (tex->bWorldPanning)
|
|
|
|
{
|
|
|
|
// rowoffset is added before the multiply so that the masked texture will
|
|
|
|
// still be positioned in world units rather than texels.
|
2017-03-12 17:54:39 +00:00
|
|
|
texturemid = (texturemid - Thread->Viewport->viewpoint.Pos.Z + rowoffset) * MaskedScaleY;
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// rowoffset is added outside the multiply so that it positions the texture
|
|
|
|
// by texels instead of world units.
|
2017-03-12 17:54:39 +00:00
|
|
|
texturemid = (texturemid - Thread->Viewport->viewpoint.Pos.Z) * MaskedScaleY + rowoffset;
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WallC.sz1 = ds->sz1;
|
|
|
|
WallC.sz2 = ds->sz2;
|
|
|
|
WallC.sx1 = ds->sx1;
|
|
|
|
WallC.sx2 = ds->sx2;
|
|
|
|
|
|
|
|
if (clip3d->CurrentSkybox)
|
|
|
|
{ // Midtex clipping doesn't work properly with skyboxes, since you're normally below the floor
|
|
|
|
// or above the ceiling, so the appropriate end won't be clipped automatically when adding
|
|
|
|
// this drawseg.
|
|
|
|
if ((curline->linedef->flags & ML_CLIP_MIDTEX) ||
|
2017-02-23 11:32:53 +00:00
|
|
|
(curline->sidedef->Flags & WALLF_CLIP_MIDTEX) ||
|
|
|
|
(ib_compatflags & BCOMPATF_CLIPMIDTEX))
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
|
|
|
ClipMidtex(x1, x2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-08 03:05:35 +00:00
|
|
|
if (m3DFloor.clipTop)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
2018-03-08 03:05:35 +00:00
|
|
|
wallupper.Project(Thread->Viewport.get(), m3DFloor.sclipTop - Thread->Viewport->viewpoint.Pos.Z, &WallC);
|
2017-06-18 22:55:32 +00:00
|
|
|
for (int i = x1; i < x2; i++)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
|
|
|
if (wallupper.ScreenY[i] < mceilingclip[i])
|
|
|
|
wallupper.ScreenY[i] = mceilingclip[i];
|
|
|
|
}
|
|
|
|
mceilingclip = wallupper.ScreenY;
|
|
|
|
}
|
2018-03-08 03:05:35 +00:00
|
|
|
if (m3DFloor.clipBottom)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
2018-03-08 03:05:35 +00:00
|
|
|
walllower.Project(Thread->Viewport.get(), m3DFloor.sclipBottom - Thread->Viewport->viewpoint.Pos.Z, &WallC);
|
2017-06-18 22:55:32 +00:00
|
|
|
for (int i = x1; i < x2; i++)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
|
|
|
if (walllower.ScreenY[i] > mfloorclip[i])
|
|
|
|
walllower.ScreenY[i] = mfloorclip[i];
|
|
|
|
}
|
|
|
|
mfloorclip = walllower.ScreenY;
|
|
|
|
}
|
|
|
|
|
|
|
|
rw_offset = 0;
|
|
|
|
rw_pic = tex;
|
|
|
|
|
|
|
|
double top, bot;
|
|
|
|
GetMaskedWallTopBottom(ds, top, bot);
|
|
|
|
|
2017-02-03 23:25:37 +00:00
|
|
|
RenderWallPart renderWallpart(Thread);
|
2017-01-29 09:05:37 +00:00
|
|
|
renderWallpart.Render(walldrawerargs, frontsector, curline, WallC, rw_pic, x1, x2, mceilingclip, mfloorclip, texturemid, MaskedSWall, maskedtexturecol, ds->yscale, top, bot, true, wallshade, rw_offset, rw_light, rw_lightstep, nullptr, ds->foggy, basecolormap);
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
|
|
|
|
2017-06-18 22:55:32 +00:00
|
|
|
return false;
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// kg3D - render one fake wall
|
2018-03-09 00:30:47 +00:00
|
|
|
void RenderDrawSegment::RenderFakeWall(DrawSegment *ds, int x1, int x2, F3DFloor *rover, int wallshade, FDynamicColormap *basecolormap, double clipTop, double clipBottom)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
double xscale;
|
|
|
|
double yscale;
|
|
|
|
|
|
|
|
fixed_t Alpha = Scale(rover->alpha, OPAQUE, 255);
|
2017-01-30 10:25:25 +00:00
|
|
|
if (Alpha <= 0)
|
2017-01-26 07:13:39 +00:00
|
|
|
return;
|
|
|
|
|
2017-01-30 10:25:25 +00:00
|
|
|
WallDrawerArgs drawerargs;
|
|
|
|
drawerargs.SetStyle(true, (rover->flags & FF_ADDITIVETRANS) != 0, Alpha);
|
|
|
|
|
2017-01-26 07:13:39 +00:00
|
|
|
rw_lightstep = ds->lightstep;
|
|
|
|
rw_light = ds->light + (x1 - ds->x1) * rw_lightstep;
|
|
|
|
|
2018-03-07 23:55:37 +00:00
|
|
|
const short *mfloorclip = ds->sprbottomclip - ds->x1;
|
|
|
|
const short *mceilingclip = ds->sprtopclip - ds->x1;
|
2017-01-26 07:13:39 +00:00
|
|
|
|
|
|
|
//double spryscale = ds->iscale + ds->iscalestep * (x1 - ds->x1);
|
|
|
|
float *MaskedSWall = ds->swall - ds->x1;
|
|
|
|
|
|
|
|
// find positioning
|
|
|
|
side_t *scaledside;
|
|
|
|
side_t::ETexpart scaledpart;
|
|
|
|
if (rover->flags & FF_UPPERTEXTURE)
|
|
|
|
{
|
|
|
|
scaledside = curline->sidedef;
|
|
|
|
scaledpart = side_t::top;
|
|
|
|
}
|
|
|
|
else if (rover->flags & FF_LOWERTEXTURE)
|
|
|
|
{
|
|
|
|
scaledside = curline->sidedef;
|
|
|
|
scaledpart = side_t::bottom;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scaledside = rover->master->sidedef[0];
|
|
|
|
scaledpart = side_t::mid;
|
|
|
|
}
|
|
|
|
xscale = rw_pic->Scale.X * scaledside->GetTextureXScale(scaledpart);
|
|
|
|
yscale = rw_pic->Scale.Y * scaledside->GetTextureYScale(scaledpart);
|
|
|
|
|
|
|
|
double rowoffset = curline->sidedef->GetTextureYOffset(side_t::mid) + rover->master->sidedef[0]->GetTextureYOffset(side_t::mid);
|
|
|
|
double planez = rover->model->GetPlaneTexZ(sector_t::ceiling);
|
|
|
|
rw_offset = FLOAT2FIXED(curline->sidedef->GetTextureXOffset(side_t::mid) + rover->master->sidedef[0]->GetTextureXOffset(side_t::mid));
|
|
|
|
if (rowoffset < 0)
|
|
|
|
{
|
|
|
|
rowoffset += rw_pic->GetHeight();
|
|
|
|
}
|
2017-03-12 17:54:39 +00:00
|
|
|
double texturemid = (planez - Thread->Viewport->viewpoint.Pos.Z) * yscale;
|
2017-01-26 07:13:39 +00:00
|
|
|
if (rw_pic->bWorldPanning)
|
|
|
|
{
|
|
|
|
// rowoffset is added before the multiply so that the masked texture will
|
|
|
|
// still be positioned in world units rather than texels.
|
|
|
|
|
|
|
|
texturemid = texturemid + rowoffset * yscale;
|
|
|
|
rw_offset = xs_RoundToInt(rw_offset * xscale);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// rowoffset is added outside the multiply so that it positions the texture
|
|
|
|
// by texels instead of world units.
|
|
|
|
texturemid += rowoffset;
|
|
|
|
}
|
|
|
|
|
2017-01-26 09:22:54 +00:00
|
|
|
CameraLight *cameraLight = CameraLight::Instance();
|
2017-02-03 08:00:46 +00:00
|
|
|
if (cameraLight->FixedLightLevel() >= 0)
|
2017-03-06 22:27:02 +00:00
|
|
|
drawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, cameraLight->FixedLightLevelShade());
|
2017-02-03 08:00:46 +00:00
|
|
|
else if (cameraLight->FixedColormap() != nullptr)
|
|
|
|
drawerargs.SetLight(cameraLight->FixedColormap(), 0, 0);
|
2017-01-26 07:13:39 +00:00
|
|
|
|
|
|
|
WallC.sz1 = ds->sz1;
|
|
|
|
WallC.sz2 = ds->sz2;
|
|
|
|
WallC.sx1 = ds->sx1;
|
|
|
|
WallC.sx2 = ds->sx2;
|
|
|
|
WallC.tleft.X = ds->cx;
|
|
|
|
WallC.tleft.Y = ds->cy;
|
|
|
|
WallC.tright.X = ds->cx + ds->cdx;
|
|
|
|
WallC.tright.Y = ds->cy + ds->cdy;
|
|
|
|
WallT = ds->tmapvals;
|
|
|
|
|
2017-02-06 15:04:27 +00:00
|
|
|
Clip3DFloors *clip3d = Thread->Clip3D.get();
|
2018-03-09 00:30:47 +00:00
|
|
|
wallupper.Project(Thread->Viewport.get(), clipTop - Thread->Viewport->viewpoint.Pos.Z, &WallC);
|
|
|
|
walllower.Project(Thread->Viewport.get(), clipBottom - Thread->Viewport->viewpoint.Pos.Z, &WallC);
|
2017-01-26 07:13:39 +00:00
|
|
|
|
|
|
|
for (i = x1; i < x2; i++)
|
|
|
|
{
|
|
|
|
if (wallupper.ScreenY[i] < mceilingclip[i])
|
|
|
|
wallupper.ScreenY[i] = mceilingclip[i];
|
|
|
|
}
|
|
|
|
for (i = x1; i < x2; i++)
|
|
|
|
{
|
|
|
|
if (walllower.ScreenY[i] > mfloorclip[i])
|
|
|
|
walllower.ScreenY[i] = mfloorclip[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
ProjectedWallTexcoords walltexcoords;
|
2017-03-12 17:54:39 +00:00
|
|
|
walltexcoords.ProjectPos(Thread->Viewport.get(), curline->sidedef->TexelLength*xscale, ds->sx1, ds->sx2, WallT);
|
2017-01-26 07:13:39 +00:00
|
|
|
|
|
|
|
double top, bot;
|
|
|
|
GetMaskedWallTopBottom(ds, top, bot);
|
|
|
|
|
2017-02-03 23:25:37 +00:00
|
|
|
RenderWallPart renderWallpart(Thread);
|
2017-01-29 06:49:04 +00:00
|
|
|
renderWallpart.Render(drawerargs, frontsector, curline, WallC, rw_pic, x1, x2, wallupper.ScreenY, walllower.ScreenY, texturemid, MaskedSWall, walltexcoords.UPos, yscale, top, bot, true, wallshade, rw_offset, rw_light, rw_lightstep, nullptr, ds->foggy, basecolormap);
|
2017-05-02 20:26:13 +00:00
|
|
|
|
|
|
|
RenderDecal::RenderDecals(Thread, curline->sidedef, ds, wallshade, rw_light, rw_lightstep, curline, WallC, ds->foggy, basecolormap, wallupper.ScreenY, walllower.ScreenY, true);
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// kg3D - walls of fake floors
|
|
|
|
void RenderDrawSegment::RenderFakeWallRange(DrawSegment *ds, int x1, int x2, int wallshade)
|
|
|
|
{
|
|
|
|
FTexture *const DONT_DRAW = ((FTexture*)(intptr_t)-1);
|
|
|
|
int i, j;
|
|
|
|
F3DFloor *rover, *fover = nullptr;
|
|
|
|
int passed, last;
|
|
|
|
double floorHeight;
|
|
|
|
double ceilingHeight;
|
|
|
|
|
|
|
|
curline = ds->curline;
|
|
|
|
|
|
|
|
frontsector = curline->frontsector;
|
|
|
|
backsector = curline->backsector;
|
|
|
|
|
|
|
|
if (backsector == nullptr)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2017-07-02 13:35:29 +00:00
|
|
|
if (ds->Has3DFloorFrontSectorWalls() && !ds->Has3DFloorBackSectorWalls())
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
|
|
|
sector_t *sec = backsector;
|
|
|
|
backsector = frontsector;
|
|
|
|
frontsector = sec;
|
|
|
|
}
|
|
|
|
|
|
|
|
floorHeight = backsector->CenterFloor();
|
|
|
|
ceilingHeight = backsector->CenterCeiling();
|
|
|
|
|
2017-02-06 15:04:27 +00:00
|
|
|
Clip3DFloors *clip3d = Thread->Clip3D.get();
|
2017-01-26 07:13:39 +00:00
|
|
|
|
2018-03-09 00:30:47 +00:00
|
|
|
double clipTop = m3DFloor.clipTop ? m3DFloor.sclipTop : ceilingHeight;
|
|
|
|
double clipBottom = m3DFloor.clipBottom ? m3DFloor.sclipBottom : floorHeight;
|
2017-01-26 07:13:39 +00:00
|
|
|
|
|
|
|
// maybe not visible
|
2018-03-09 00:30:47 +00:00
|
|
|
if (clipBottom >= frontsector->CenterCeiling()) return;
|
|
|
|
if (clipTop <= frontsector->CenterFloor()) return;
|
2017-01-26 07:13:39 +00:00
|
|
|
|
2018-03-08 03:05:35 +00:00
|
|
|
if (m3DFloor.down2Up)
|
2017-01-26 07:13:39 +00:00
|
|
|
{ // bottom to viewz
|
|
|
|
last = 0;
|
|
|
|
for (i = backsector->e->XFloor.ffloors.Size() - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
rover = backsector->e->XFloor.ffloors[i];
|
|
|
|
if (!(rover->flags & FF_EXISTS)) continue;
|
|
|
|
|
|
|
|
// visible?
|
|
|
|
passed = 0;
|
|
|
|
if (!(rover->flags & FF_RENDERSIDES) || rover->top.plane->isSlope() || rover->bottom.plane->isSlope() ||
|
2018-03-09 00:30:47 +00:00
|
|
|
rover->top.plane->Zat0() <= clipBottom ||
|
2017-01-26 07:13:39 +00:00
|
|
|
rover->bottom.plane->Zat0() >= ceilingHeight ||
|
|
|
|
rover->top.plane->Zat0() <= floorHeight)
|
|
|
|
{
|
|
|
|
if (!i)
|
|
|
|
{
|
|
|
|
passed = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rw_pic = nullptr;
|
2018-03-09 00:30:47 +00:00
|
|
|
if (rover->bottom.plane->Zat0() >= clipTop || passed)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
|
|
|
if (last)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// maybe wall from inside rendering?
|
|
|
|
fover = nullptr;
|
|
|
|
for (j = frontsector->e->XFloor.ffloors.Size() - 1; j >= 0; j--)
|
|
|
|
{
|
|
|
|
fover = frontsector->e->XFloor.ffloors[j];
|
|
|
|
if (fover->model == rover->model)
|
|
|
|
{ // never
|
|
|
|
fover = nullptr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!(fover->flags & FF_EXISTS)) continue;
|
|
|
|
if (!(fover->flags & FF_RENDERSIDES)) continue;
|
|
|
|
// no sloped walls, it's bugged
|
|
|
|
if (fover->top.plane->isSlope() || fover->bottom.plane->isSlope()) continue;
|
|
|
|
|
|
|
|
// visible?
|
2018-03-09 00:30:47 +00:00
|
|
|
if (fover->top.plane->Zat0() <= clipBottom) continue; // no
|
|
|
|
if (fover->bottom.plane->Zat0() >= clipTop)
|
2017-01-26 07:13:39 +00:00
|
|
|
{ // no, last possible
|
|
|
|
fover = nullptr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// it is, render inside?
|
|
|
|
if (!(fover->flags & (FF_BOTHPLANES | FF_INVERTPLANES)))
|
|
|
|
{ // no
|
|
|
|
fover = nullptr;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// nothing
|
|
|
|
if (!fover || j == -1)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// correct texture
|
|
|
|
if (fover->flags & rover->flags & FF_SWIMMABLE)
|
|
|
|
{ // don't ever draw (but treat as something has been found)
|
|
|
|
rw_pic = DONT_DRAW;
|
|
|
|
}
|
|
|
|
else if (fover->flags & FF_UPPERTEXTURE)
|
|
|
|
{
|
|
|
|
rw_pic = TexMan(curline->sidedef->GetTexture(side_t::top), true);
|
|
|
|
}
|
|
|
|
else if (fover->flags & FF_LOWERTEXTURE)
|
|
|
|
{
|
|
|
|
rw_pic = TexMan(curline->sidedef->GetTexture(side_t::bottom), true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rw_pic = TexMan(fover->master->sidedef[0]->GetTexture(side_t::mid), true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (frontsector->e->XFloor.ffloors.Size())
|
|
|
|
{
|
|
|
|
// maybe not visible?
|
|
|
|
fover = nullptr;
|
|
|
|
for (j = frontsector->e->XFloor.ffloors.Size() - 1; j >= 0; j--)
|
|
|
|
{
|
|
|
|
fover = frontsector->e->XFloor.ffloors[j];
|
|
|
|
if (fover->model == rover->model) // never
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!(fover->flags & FF_EXISTS)) continue;
|
|
|
|
if (!(fover->flags & FF_RENDERSIDES)) continue;
|
|
|
|
// no sloped walls, it's bugged
|
|
|
|
if (fover->top.plane->isSlope() || fover->bottom.plane->isSlope()) continue;
|
|
|
|
|
|
|
|
// visible?
|
2018-03-09 00:30:47 +00:00
|
|
|
if (fover->top.plane->Zat0() <= clipBottom) continue; // no
|
|
|
|
if (fover->bottom.plane->Zat0() >= clipTop)
|
2017-01-26 07:13:39 +00:00
|
|
|
{ // visible, last possible
|
|
|
|
fover = nullptr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((fover->flags & FF_SOLID) == (rover->flags & FF_SOLID) &&
|
|
|
|
!(!(fover->flags & FF_SOLID) && (fover->alpha == 255 || rover->alpha == 255))
|
|
|
|
)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (fover->flags & rover->flags & FF_SWIMMABLE)
|
|
|
|
{ // don't ever draw (but treat as something has been found)
|
|
|
|
rw_pic = DONT_DRAW;
|
|
|
|
}
|
|
|
|
fover = nullptr; // visible
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (fover && j != -1)
|
|
|
|
{
|
|
|
|
fover = nullptr;
|
|
|
|
last = 1;
|
|
|
|
continue; // not visible
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!rw_pic)
|
|
|
|
{
|
|
|
|
fover = nullptr;
|
|
|
|
if (rover->flags & FF_UPPERTEXTURE)
|
|
|
|
{
|
|
|
|
rw_pic = TexMan(curline->sidedef->GetTexture(side_t::top), true);
|
|
|
|
}
|
|
|
|
else if (rover->flags & FF_LOWERTEXTURE)
|
|
|
|
{
|
|
|
|
rw_pic = TexMan(curline->sidedef->GetTexture(side_t::bottom), true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rw_pic = TexMan(rover->master->sidedef[0]->GetTexture(side_t::mid), true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// correct colors now
|
2017-03-15 21:04:23 +00:00
|
|
|
FDynamicColormap *basecolormap = nullptr;
|
2017-01-26 07:13:39 +00:00
|
|
|
wallshade = ds->shade;
|
2017-01-26 09:22:54 +00:00
|
|
|
CameraLight *cameraLight = CameraLight::Instance();
|
2017-02-03 08:00:46 +00:00
|
|
|
if (cameraLight->FixedLightLevel() < 0)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
2017-07-02 13:35:29 +00:00
|
|
|
if (ds->Has3DFloorFrontSectorWalls() && !ds->Has3DFloorBackSectorWalls())
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
|
|
|
for (j = backsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
|
|
|
|
{
|
2018-03-09 00:30:47 +00:00
|
|
|
if (clipTop <= backsector->e->XFloor.lightlist[j].plane.Zat0())
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
|
|
|
lightlist_t *lit = &backsector->e->XFloor.lightlist[j];
|
2017-03-15 22:24:53 +00:00
|
|
|
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
2017-03-06 21:58:48 +00:00
|
|
|
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
|
2017-03-12 17:54:39 +00:00
|
|
|
wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + LightVisibility::ActualExtraLight(ds->foggy, Thread->Viewport.get()), foggy);
|
2017-01-26 07:13:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (j = frontsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
|
|
|
|
{
|
2018-03-09 00:30:47 +00:00
|
|
|
if (clipTop <= frontsector->e->XFloor.lightlist[j].plane.Zat0())
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
|
|
|
lightlist_t *lit = &frontsector->e->XFloor.lightlist[j];
|
2017-03-15 22:24:53 +00:00
|
|
|
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
2017-03-06 21:58:48 +00:00
|
|
|
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
|
2017-03-12 17:54:39 +00:00
|
|
|
wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + LightVisibility::ActualExtraLight(ds->foggy, Thread->Viewport.get()), foggy);
|
2017-01-26 07:13:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-15 22:24:53 +00:00
|
|
|
if (basecolormap == nullptr) basecolormap = GetColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::walltop]);
|
2017-03-15 21:04:23 +00:00
|
|
|
|
2017-01-26 07:13:39 +00:00
|
|
|
if (rw_pic != DONT_DRAW)
|
|
|
|
{
|
2018-03-09 00:30:47 +00:00
|
|
|
RenderFakeWall(ds, x1, x2, fover ? fover : rover, wallshade, basecolormap, clipTop, clipBottom);
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
|
|
|
else rw_pic = nullptr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // top to viewz
|
|
|
|
for (i = 0; i < (int)backsector->e->XFloor.ffloors.Size(); i++)
|
|
|
|
{
|
|
|
|
rover = backsector->e->XFloor.ffloors[i];
|
|
|
|
if (!(rover->flags & FF_EXISTS)) continue;
|
|
|
|
|
|
|
|
// visible?
|
|
|
|
passed = 0;
|
|
|
|
if (!(rover->flags & FF_RENDERSIDES) ||
|
|
|
|
rover->top.plane->isSlope() || rover->bottom.plane->isSlope() ||
|
2018-03-09 00:30:47 +00:00
|
|
|
rover->bottom.plane->Zat0() >= clipTop ||
|
2017-01-26 07:13:39 +00:00
|
|
|
rover->top.plane->Zat0() <= floorHeight ||
|
|
|
|
rover->bottom.plane->Zat0() >= ceilingHeight)
|
|
|
|
{
|
|
|
|
if ((unsigned)i == backsector->e->XFloor.ffloors.Size() - 1)
|
|
|
|
{
|
|
|
|
passed = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rw_pic = nullptr;
|
2018-03-09 00:30:47 +00:00
|
|
|
if (rover->top.plane->Zat0() <= clipBottom || passed)
|
2017-01-26 07:13:39 +00:00
|
|
|
{ // maybe wall from inside rendering?
|
|
|
|
fover = nullptr;
|
|
|
|
for (j = 0; j < (int)frontsector->e->XFloor.ffloors.Size(); j++)
|
|
|
|
{
|
|
|
|
fover = frontsector->e->XFloor.ffloors[j];
|
|
|
|
if (fover->model == rover->model)
|
|
|
|
{ // never
|
|
|
|
fover = nullptr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!(fover->flags & FF_EXISTS)) continue;
|
|
|
|
if (!(fover->flags & FF_RENDERSIDES)) continue;
|
|
|
|
// no sloped walls, it's bugged
|
|
|
|
if (fover->top.plane->isSlope() || fover->bottom.plane->isSlope()) continue;
|
|
|
|
|
|
|
|
// visible?
|
2018-03-09 00:30:47 +00:00
|
|
|
if (fover->bottom.plane->Zat0() >= clipTop) continue; // no
|
|
|
|
if (fover->top.plane->Zat0() <= clipBottom)
|
2017-01-26 07:13:39 +00:00
|
|
|
{ // no, last possible
|
|
|
|
fover = nullptr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// it is, render inside?
|
|
|
|
if (!(fover->flags & (FF_BOTHPLANES | FF_INVERTPLANES)))
|
|
|
|
{ // no
|
|
|
|
fover = nullptr;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// nothing
|
|
|
|
if (!fover || (unsigned)j == frontsector->e->XFloor.ffloors.Size())
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// correct texture
|
|
|
|
if (fover->flags & rover->flags & FF_SWIMMABLE)
|
|
|
|
{
|
|
|
|
rw_pic = DONT_DRAW; // don't ever draw (but treat as something has been found)
|
|
|
|
}
|
|
|
|
else if (fover->flags & FF_UPPERTEXTURE)
|
|
|
|
{
|
|
|
|
rw_pic = TexMan(curline->sidedef->GetTexture(side_t::top), true);
|
|
|
|
}
|
|
|
|
else if (fover->flags & FF_LOWERTEXTURE)
|
|
|
|
{
|
|
|
|
rw_pic = TexMan(curline->sidedef->GetTexture(side_t::bottom), true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rw_pic = TexMan(fover->master->sidedef[0]->GetTexture(side_t::mid), true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (frontsector->e->XFloor.ffloors.Size())
|
|
|
|
{ // maybe not visible?
|
|
|
|
fover = nullptr;
|
|
|
|
for (j = 0; j < (int)frontsector->e->XFloor.ffloors.Size(); j++)
|
|
|
|
{
|
|
|
|
fover = frontsector->e->XFloor.ffloors[j];
|
|
|
|
if (fover->model == rover->model)
|
|
|
|
{ // never
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!(fover->flags & FF_EXISTS)) continue;
|
|
|
|
if (!(fover->flags & FF_RENDERSIDES)) continue;
|
|
|
|
// no sloped walls, its bugged
|
|
|
|
if (fover->top.plane->isSlope() || fover->bottom.plane->isSlope()) continue;
|
|
|
|
|
|
|
|
// visible?
|
2018-03-09 00:30:47 +00:00
|
|
|
if (fover->bottom.plane->Zat0() >= clipTop) continue; // no
|
|
|
|
if (fover->top.plane->Zat0() <= clipBottom)
|
2017-01-26 07:13:39 +00:00
|
|
|
{ // visible, last possible
|
|
|
|
fover = nullptr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((fover->flags & FF_SOLID) == (rover->flags & FF_SOLID) &&
|
|
|
|
!(!(rover->flags & FF_SOLID) && (fover->alpha == 255 || rover->alpha == 255))
|
|
|
|
)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (fover->flags & rover->flags & FF_SWIMMABLE)
|
|
|
|
{ // don't ever draw (but treat as something has been found)
|
|
|
|
rw_pic = DONT_DRAW;
|
|
|
|
}
|
|
|
|
fover = nullptr; // visible
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (fover && (unsigned)j != frontsector->e->XFloor.ffloors.Size())
|
|
|
|
{ // not visible
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (rw_pic == nullptr)
|
|
|
|
{
|
|
|
|
fover = nullptr;
|
|
|
|
if (rover->flags & FF_UPPERTEXTURE)
|
|
|
|
{
|
|
|
|
rw_pic = TexMan(curline->sidedef->GetTexture(side_t::top), true);
|
|
|
|
}
|
|
|
|
else if (rover->flags & FF_LOWERTEXTURE)
|
|
|
|
{
|
|
|
|
rw_pic = TexMan(curline->sidedef->GetTexture(side_t::bottom), true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rw_pic = TexMan(rover->master->sidedef[0]->GetTexture(side_t::mid), true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// correct colors now
|
2017-03-15 21:04:23 +00:00
|
|
|
FDynamicColormap *basecolormap = nullptr;
|
2017-01-26 07:13:39 +00:00
|
|
|
wallshade = ds->shade;
|
2017-01-26 09:22:54 +00:00
|
|
|
CameraLight *cameraLight = CameraLight::Instance();
|
2017-02-03 08:00:46 +00:00
|
|
|
if (cameraLight->FixedLightLevel() < 0)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
2017-07-02 13:35:29 +00:00
|
|
|
if (ds->Has3DFloorFrontSectorWalls() && !ds->Has3DFloorBackSectorWalls())
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
|
|
|
for (j = backsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
|
|
|
|
{
|
2018-03-09 00:30:47 +00:00
|
|
|
if (clipTop <= backsector->e->XFloor.lightlist[j].plane.Zat0())
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
|
|
|
lightlist_t *lit = &backsector->e->XFloor.lightlist[j];
|
2017-03-15 22:24:53 +00:00
|
|
|
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
2017-03-06 21:58:48 +00:00
|
|
|
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
|
2017-03-12 17:54:39 +00:00
|
|
|
wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + LightVisibility::ActualExtraLight(ds->foggy, Thread->Viewport.get()), foggy);
|
2017-01-26 07:13:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (j = frontsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
|
|
|
|
{
|
2018-03-09 00:30:47 +00:00
|
|
|
if (clipTop <= frontsector->e->XFloor.lightlist[j].plane.Zat0())
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
|
|
|
lightlist_t *lit = &frontsector->e->XFloor.lightlist[j];
|
2017-03-15 22:24:53 +00:00
|
|
|
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
2017-03-06 21:58:48 +00:00
|
|
|
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
|
2017-03-12 17:54:39 +00:00
|
|
|
wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + LightVisibility::ActualExtraLight(ds->foggy, Thread->Viewport.get()), foggy);
|
2017-01-26 07:13:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-15 22:24:53 +00:00
|
|
|
if (basecolormap == nullptr) basecolormap = GetColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::walltop]);
|
2017-01-26 07:13:39 +00:00
|
|
|
|
|
|
|
if (rw_pic != DONT_DRAW)
|
|
|
|
{
|
2018-03-09 00:30:47 +00:00
|
|
|
RenderFakeWall(ds, x1, x2, fover ? fover : rover, wallshade, basecolormap, clipTop, clipBottom);
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rw_pic = nullptr;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clip a midtexture to the floor and ceiling of the sector in front of it.
|
|
|
|
void RenderDrawSegment::ClipMidtex(int x1, int x2)
|
|
|
|
{
|
|
|
|
ProjectedWallLine most;
|
|
|
|
|
2017-02-03 23:25:37 +00:00
|
|
|
RenderPortal *renderportal = Thread->Portal.get();
|
2017-01-26 07:13:39 +00:00
|
|
|
|
2017-03-12 17:54:39 +00:00
|
|
|
most.Project(Thread->Viewport.get(), curline->frontsector->ceilingplane, &WallC, curline, renderportal->MirrorFlags & RF_XFLIP);
|
2017-01-26 07:13:39 +00:00
|
|
|
for (int i = x1; i < x2; ++i)
|
|
|
|
{
|
|
|
|
if (wallupper.ScreenY[i] < most.ScreenY[i])
|
|
|
|
wallupper.ScreenY[i] = most.ScreenY[i];
|
|
|
|
}
|
2017-03-12 17:54:39 +00:00
|
|
|
most.Project(Thread->Viewport.get(), curline->frontsector->floorplane, &WallC, curline, renderportal->MirrorFlags & RF_XFLIP);
|
2017-01-26 07:13:39 +00:00
|
|
|
for (int i = x1; i < x2; ++i)
|
|
|
|
{
|
|
|
|
if (walllower.ScreenY[i] > most.ScreenY[i])
|
|
|
|
walllower.ScreenY[i] = most.ScreenY[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RenderDrawSegment::GetMaskedWallTopBottom(DrawSegment *ds, double &top, double &bot)
|
|
|
|
{
|
|
|
|
double frontcz1 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v1);
|
|
|
|
double frontfz1 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v1);
|
|
|
|
double frontcz2 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v2);
|
|
|
|
double frontfz2 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v2);
|
|
|
|
top = MAX(frontcz1, frontcz2);
|
|
|
|
bot = MIN(frontfz1, frontfz2);
|
|
|
|
|
2018-03-08 03:05:35 +00:00
|
|
|
if (m3DFloor.clipTop)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
2018-03-08 03:05:35 +00:00
|
|
|
top = MIN(top, m3DFloor.sclipTop);
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
2018-03-08 03:05:35 +00:00
|
|
|
if (m3DFloor.clipBottom)
|
2017-01-26 07:13:39 +00:00
|
|
|
{
|
2018-03-08 03:05:35 +00:00
|
|
|
bot = MAX(bot, m3DFloor.sclipBottom);
|
2017-01-26 07:13:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|