Convert r_walldraw to a class

This commit is contained in:
Magnus Norddahl 2017-01-24 08:41:35 +01:00
parent b256f6ed89
commit 86d9594d6e
5 changed files with 158 additions and 82 deletions

View File

@ -1042,7 +1042,9 @@ namespace swrenderer
{ {
rw_offset = -rw_offset; rw_offset = -rw_offset;
} }
R_DrawWallSegment(frontsector, curline, WallC, rw_pic, x1, x2, walltop.ScreenY, wallbottom.ScreenY, rw_midtexturemid, walltexcoords.VStep, walltexcoords.UPos, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_frontfz1, rw_frontfz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy, basecolormap);
RenderWallPart renderWallpart;
renderWallpart.Render(frontsector, curline, WallC, rw_pic, x1, x2, walltop.ScreenY, wallbottom.ScreenY, rw_midtexturemid, walltexcoords.VStep, walltexcoords.UPos, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_frontfz1, rw_frontfz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy, basecolormap);
} }
fillshort(ceilingclip + x1, x2 - x1, viewheight); fillshort(ceilingclip + x1, x2 - x1, viewheight);
fillshort(floorclip + x1, x2 - x1, 0xffff); fillshort(floorclip + x1, x2 - x1, 0xffff);
@ -1077,7 +1079,9 @@ namespace swrenderer
{ {
rw_offset = -rw_offset; rw_offset = -rw_offset;
} }
R_DrawWallSegment(frontsector, curline, WallC, rw_pic, x1, x2, walltop.ScreenY, wallupper.ScreenY, rw_toptexturemid, walltexcoords.VStep, walltexcoords.UPos, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_backcz1, rw_backcz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy, basecolormap);
RenderWallPart renderWallpart;
renderWallpart.Render(frontsector, curline, WallC, rw_pic, x1, x2, walltop.ScreenY, wallupper.ScreenY, rw_toptexturemid, walltexcoords.VStep, walltexcoords.UPos, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_backcz1, rw_backcz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy, basecolormap);
} }
memcpy(ceilingclip + x1, wallupper.ScreenY + x1, (x2 - x1) * sizeof(short)); memcpy(ceilingclip + x1, wallupper.ScreenY + x1, (x2 - x1) * sizeof(short));
} }
@ -1115,7 +1119,9 @@ namespace swrenderer
{ {
rw_offset = -rw_offset; rw_offset = -rw_offset;
} }
R_DrawWallSegment(frontsector, curline, WallC, rw_pic, x1, x2, walllower.ScreenY, wallbottom.ScreenY, rw_bottomtexturemid, walltexcoords.VStep, walltexcoords.UPos, yscale, MAX(rw_backfz1, rw_backfz2), MIN(rw_frontfz1, rw_frontfz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy, basecolormap);
RenderWallPart renderWallpart;
renderWallpart.Render(frontsector, curline, WallC, rw_pic, x1, x2, walllower.ScreenY, wallbottom.ScreenY, rw_bottomtexturemid, walltexcoords.VStep, walltexcoords.UPos, yscale, MAX(rw_backfz1, rw_backfz2), MIN(rw_frontfz1, rw_frontfz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy, basecolormap);
} }
memcpy(floorclip + x1, walllower.ScreenY + x1, (x2 - x1) * sizeof(short)); memcpy(floorclip + x1, walllower.ScreenY + x1, (x2 - x1) * sizeof(short));
} }

View File

@ -52,13 +52,6 @@
namespace swrenderer namespace swrenderer
{ {
using namespace drawerargs;
namespace
{
FTexture *rw_pic;
}
WallSampler::WallSampler(int y1, double texturemid, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture) WallSampler::WallSampler(int y1, double texturemid, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture)
{ {
xoffset += FLOAT2FIXED(xmagnitude * 0.5); xoffset += FLOAT2FIXED(xmagnitude * 0.5);
@ -184,8 +177,10 @@ namespace swrenderer
} }
// Draw a column with support for non-power-of-two ranges // Draw a column with support for non-power-of-two ranges
static void Draw1Column(const FWallCoords &WallC, int x, int y1, int y2, WallSampler &sampler, FLightNode *light_list, DrawerFunc draw1column) void RenderWallPart::Draw1Column(int x, int y1, int y2, WallSampler &sampler, DrawerFunc draw1column)
{ {
using namespace drawerargs;
if (r_dynlights && light_list) if (r_dynlights && light_list)
{ {
// Find column position in view space // Find column position in view space
@ -322,12 +317,10 @@ namespace swrenderer
} }
} }
static void ProcessWallWorker( void RenderWallPart::ProcessWallWorker(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal, DrawerFunc drawcolumn)
const FWallCoords &WallC,
int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap,
FLightNode *light_list,
DrawerFunc drawcolumn)
{ {
using namespace drawerargs;
if (rw_pic->UseType == FTexture::TEX_Null) if (rw_pic->UseType == FTexture::TEX_Null)
return; return;
@ -382,47 +375,48 @@ namespace swrenderer
if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x])); if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x]));
WallSampler sampler(y1, texturemid, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic); WallSampler sampler(y1, texturemid, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic);
Draw1Column(WallC, x, y1, y2, sampler, light_list, drawcolumn); Draw1Column(x, y1, y2, sampler, drawcolumn);
} }
NetUpdate(); NetUpdate();
} }
static void ProcessNormalWall(const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap, FLightNode *light_list) void RenderWallPart::ProcessNormalWall(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal)
{ {
ProcessWallWorker(WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list, &SWPixelFormatDrawers::DrawWallColumn); ProcessWallWorker(uwal, dwal, texturemid, swal, lwal, &SWPixelFormatDrawers::DrawWallColumn);
} }
static void ProcessMaskedWall(const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap, FLightNode *light_list) void RenderWallPart::ProcessMaskedWall(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal)
{ {
if (!rw_pic->bMasked) // Textures that aren't masked can use the faster ProcessNormalWall. if (!rw_pic->bMasked) // Textures that aren't masked can use the faster ProcessNormalWall.
{ {
ProcessNormalWall(WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list); ProcessNormalWall(uwal, dwal, texturemid, swal, lwal);
} }
else else
{ {
ProcessWallWorker(WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list, &SWPixelFormatDrawers::DrawWallMaskedColumn); ProcessWallWorker(uwal, dwal, texturemid, swal, lwal, &SWPixelFormatDrawers::DrawWallMaskedColumn);
} }
} }
static void ProcessTranslucentWall(const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap, FLightNode *light_list) void RenderWallPart::ProcessTranslucentWall(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal)
{ {
DrawerFunc drawcol1 = R_GetTransMaskDrawer(); DrawerFunc drawcol1 = R_GetTransMaskDrawer();
if (drawcol1 == nullptr) if (drawcol1 == nullptr)
{ {
// The current translucency is unsupported, so draw with regular ProcessMaskedWall instead. // The current translucency is unsupported, so draw with regular ProcessMaskedWall instead.
ProcessMaskedWall(WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list); ProcessMaskedWall(uwal, dwal, texturemid, swal, lwal);
} }
else else
{ {
ProcessWallWorker(WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list, drawcol1); ProcessWallWorker(uwal, dwal, texturemid, swal, lwal, drawcol1);
} }
} }
static void ProcessStripedWall(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool foggy, FDynamicColormap *basecolormap, FLightNode *light_list) void RenderWallPart::ProcessStripedWall(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal)
{ {
ProjectedWallLine most1, most2, most3; ProjectedWallLine most1, most2, most3;
short *up, *down; const short *up;
short *down;
up = uwal; up = uwal;
down = most1.ScreenY; down = most1.ScreenY;
@ -442,7 +436,7 @@ namespace swrenderer
{ {
down[j] = clamp(most3.ScreenY[j], up[j], dwal[j]); down[j] = clamp(most3.ScreenY[j], up[j], dwal[j]);
} }
ProcessNormalWall(WallC, x1, x2, up, down, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list); ProcessNormalWall(up, down, texturemid, swal, lwal);
up = down; up = down;
down = (down == most1.ScreenY) ? most2.ScreenY : most1.ScreenY; down = (down == most1.ScreenY) ? most2.ScreenY : most1.ScreenY;
} }
@ -452,31 +446,31 @@ namespace swrenderer
wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != NULL) + R_ActualExtraLight(foggy)); wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != NULL) + R_ActualExtraLight(foggy));
} }
ProcessNormalWall(WallC, x1, x2, up, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list); ProcessNormalWall(up, dwal, texturemid, swal, lwal);
} }
static void ProcessWall(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool mask, bool foggy, FDynamicColormap *basecolormap, FLightNode *light_list) void RenderWallPart::ProcessWall(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal)
{ {
if (mask) if (mask)
{ {
if (colfunc == basecolfunc) if (colfunc == basecolfunc)
{ {
ProcessMaskedWall(WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list); ProcessMaskedWall(uwal, dwal, texturemid, swal, lwal);
} }
else else
{ {
ProcessTranslucentWall(WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list); ProcessTranslucentWall(uwal, dwal, texturemid, swal, lwal);
} }
} }
else else
{ {
if (fixedcolormap != NULL || fixedlightlev >= 0 || !(frontsector->e && frontsector->e->XFloor.lightlist.Size())) if (fixedcolormap != NULL || fixedlightlev >= 0 || !(frontsector->e && frontsector->e->XFloor.lightlist.Size()))
{ {
ProcessNormalWall(WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list); ProcessNormalWall(uwal, dwal, texturemid, swal, lwal);
} }
else else
{ {
ProcessStripedWall(frontsector, curline, WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, foggy, basecolormap, light_list); ProcessStripedWall(uwal, dwal, texturemid, swal, lwal);
} }
} }
} }
@ -492,10 +486,9 @@ namespace swrenderer
// //
//============================================================================= //=============================================================================
static void ProcessWallNP2(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, double top, double bot, int wallshade, fixed_t xoffset, float light, float lightstep, bool mask, bool foggy, FDynamicColormap *basecolormap, FLightNode *light_list) void RenderWallPart::ProcessWallNP2(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal, double top, double bot)
{ {
ProjectedWallLine most1, most2, most3; ProjectedWallLine most1, most2, most3;
short *up, *down;
double texheight = rw_pic->GetHeight(); double texheight = rw_pic->GetHeight();
double partition; double partition;
double scaledtexheight = texheight / yrepeat; double scaledtexheight = texheight / yrepeat;
@ -507,8 +500,8 @@ namespace swrenderer
{ {
partition -= scaledtexheight; partition -= scaledtexheight;
} }
up = uwal; const short *up = uwal;
down = most1.ScreenY; short *down = most1.ScreenY;
texturemid = (partition - ViewPos.Z) * yrepeat + texheight; texturemid = (partition - ViewPos.Z) * yrepeat + texheight;
while (partition > bot) while (partition > bot)
{ {
@ -519,20 +512,20 @@ namespace swrenderer
{ {
down[j] = clamp(most3.ScreenY[j], up[j], dwal[j]); down[j] = clamp(most3.ScreenY[j], up[j], dwal[j]);
} }
ProcessWall(frontsector, curline, WallC, x1, x2, up, down, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy, basecolormap, light_list); ProcessWall(up, down, texturemid, swal, lwal);
up = down; up = down;
down = (down == most1.ScreenY) ? most2.ScreenY : most1.ScreenY; down = (down == most1.ScreenY) ? most2.ScreenY : most1.ScreenY;
} }
partition -= scaledtexheight; partition -= scaledtexheight;
texturemid -= texheight; texturemid -= texheight;
} }
ProcessWall(frontsector, curline, WallC, x1, x2, up, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy, basecolormap, light_list); ProcessWall(up, dwal, texturemid, swal, lwal);
} }
else else
{ // upside down: draw strips from bottom to top { // upside down: draw strips from bottom to top
partition = bot - fmod(bot - texturemid / yrepeat - ViewPos.Z, scaledtexheight); partition = bot - fmod(bot - texturemid / yrepeat - ViewPos.Z, scaledtexheight);
up = most1.ScreenY; short *up = most1.ScreenY;
down = dwal; const short *down = dwal;
texturemid = (partition - ViewPos.Z) * yrepeat + texheight; texturemid = (partition - ViewPos.Z) * yrepeat + texheight;
while (partition < top) while (partition < top)
{ {
@ -543,56 +536,42 @@ namespace swrenderer
{ {
up[j] = clamp(most3.ScreenY[j], uwal[j], down[j]); up[j] = clamp(most3.ScreenY[j], uwal[j], down[j]);
} }
ProcessWall(frontsector, curline, WallC, x1, x2, up, down, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy, basecolormap, light_list); ProcessWall(up, down, texturemid, swal, lwal);
down = up; down = up;
up = (up == most1.ScreenY) ? most2.ScreenY : most1.ScreenY; up = (up == most1.ScreenY) ? most2.ScreenY : most1.ScreenY;
} }
partition -= scaledtexheight; partition -= scaledtexheight;
texturemid -= texheight; texturemid -= texheight;
} }
ProcessWall(frontsector, curline, WallC, x1, x2, uwal, down, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy, basecolormap, light_list); ProcessWall(uwal, down, texturemid, swal, lwal);
} }
} }
void R_DrawDrawSeg(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *pic, drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool foggy, FDynamicColormap *basecolormap) void RenderWallPart::Render(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *pic, int x1, int x2, const short *walltop, const short *wallbottom, double texturemid, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask, int wallshade, fixed_t xoffset, float light, float lightstep, FLightNode *light_list, bool foggy, FDynamicColormap *basecolormap)
{ {
rw_pic = pic; this->x1 = x1;
this->x2 = x2;
this->frontsector = frontsector;
this->curline = curline;
this->WallC = WallC;
this->yrepeat = yscale;
this->wallshade = wallshade;
this->xoffset = xoffset;
this->light = light;
this->lightstep = lightstep;
this->foggy = foggy;
this->basecolormap = basecolormap;
this->light_list = light_list;
this->rw_pic = pic;
this->mask = mask;
if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits)
{ {
double frontcz1 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v1); ProcessWallNP2(walltop, wallbottom, texturemid, swall, lwall, top, bottom);
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);
double top = MAX(frontcz1, frontcz2);
double bot = MIN(frontfz1, frontfz2);
Clip3DFloors *clip3d = Clip3DFloors::Instance();
if (clip3d->fake3D & FAKE3D_CLIPTOP)
{
top = MIN(top, clip3d->sclipTop);
}
if (clip3d->fake3D & FAKE3D_CLIPBOTTOM)
{
bot = MAX(bot, clip3d->sclipBottom);
}
ProcessWallNP2(frontsector, curline, WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, top, bot, wallshade, xoffset, light, lightstep, true, foggy, basecolormap, nullptr);
} }
else else
{ {
ProcessWall(frontsector, curline, WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, true, foggy, basecolormap, nullptr); ProcessWall(walltop, wallbottom, texturemid, swall, lwall);
}
}
void R_DrawWallSegment(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *pic, int x1, int x2, short *walltop, short *wallbottom, double texturemid, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask, int wallshade, fixed_t xoffset, float light, float lightstep, FLightNode *light_list, bool foggy, FDynamicColormap *basecolormap)
{
rw_pic = pic;
if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits)
{
ProcessWallNP2(frontsector, curline, WallC, x1, x2, walltop, wallbottom, texturemid, swall, lwall, yscale, top, bottom, wallshade, xoffset, light, lightstep, false, foggy, basecolormap, light_list);
}
else
{
ProcessWall(frontsector, curline, WallC, x1, x2, walltop, wallbottom, texturemid, swall, lwall, yscale, wallshade, xoffset, light, lightstep, false, foggy, basecolormap, light_list);
} }
} }
} }

View File

@ -13,14 +13,77 @@
#pragma once #pragma once
#include "swrenderer/drawers/r_draw.h"
#include "r_line.h"
class FTexture; class FTexture;
struct FLightNode; struct FLightNode;
struct seg_t; struct seg_t;
struct FLightNode;
struct FDynamicColormap;
namespace swrenderer namespace swrenderer
{ {
struct drawseg_t; struct drawseg_t;
struct FWallCoords; struct FWallCoords;
class ProjectedWallLine;
class ProjectedWallTexcoords;
struct WallSampler;
class RenderWallPart
{
public:
void Render(
sector_t *frontsector,
seg_t *curline,
const FWallCoords &WallC,
FTexture *rw_pic,
int x1,
int x2,
const short *walltop,
const short *wallbottom,
double texturemid,
float *swall,
fixed_t *lwall,
double yscale,
double top,
double bottom,
bool mask,
int wallshade,
fixed_t xoffset,
float light,
float lightstep,
FLightNode *light_list,
bool foggy,
FDynamicColormap *basecolormap);
private:
void ProcessWallNP2(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal, double top, double bot);
void ProcessWall(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal);
void ProcessStripedWall(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal);
void ProcessTranslucentWall(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal);
void ProcessMaskedWall(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal);
void ProcessNormalWall(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal);
void ProcessWallWorker(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal, DrawerFunc drawcolumn);
void Draw1Column(int x, int y1, int y2, WallSampler &sampler, DrawerFunc draw1column);
int x1 = 0;
int x2 = 0;
FTexture *rw_pic = nullptr;
sector_t *frontsector = nullptr;
seg_t *curline = nullptr;
FWallCoords WallC;
double yrepeat = 0.0;
int wallshade = 0;
fixed_t xoffset = 0;
float light = 0.0f;
float lightstep = 0.0f;
bool foggy = false;
FDynamicColormap *basecolormap = nullptr;
FLightNode *light_list = nullptr;
bool mask = false;
};
struct WallSampler struct WallSampler
{ {
@ -36,7 +99,4 @@ namespace swrenderer
uint32_t texturefracx; uint32_t texturefracx;
uint32_t height; uint32_t height;
}; };
void R_DrawWallSegment(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *rw_pic, int x1, int x2, short *walltop, short *wallbottom, double texturemid, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask, int wallshade, fixed_t xoffset, float light, float lightstep, FLightNode *light_list, bool foggy, FDynamicColormap *basecolormap);
void R_DrawDrawSeg(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *rw_pic, drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool foggy, FDynamicColormap *basecolormap);
} }

View File

@ -131,6 +131,26 @@ namespace swrenderer
} }
} }
void R_GetMaskedWallTopBottom(drawseg_t *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);
Clip3DFloors *clip3d = Clip3DFloors::Instance();
if (clip3d->fake3D & FAKE3D_CLIPTOP)
{
top = MIN(top, clip3d->sclipTop);
}
if (clip3d->fake3D & FAKE3D_CLIPBOTTOM)
{
bot = MAX(bot, clip3d->sclipBottom);
}
}
void R_RenderMaskedSegRange(drawseg_t *ds, int x1, int x2) void R_RenderMaskedSegRange(drawseg_t *ds, int x1, int x2)
{ {
float *MaskedSWall = nullptr, MaskedScaleY = 0, rw_scalestep = 0; float *MaskedSWall = nullptr, MaskedScaleY = 0, rw_scalestep = 0;
@ -426,7 +446,12 @@ namespace swrenderer
rw_offset = 0; rw_offset = 0;
rw_pic = tex; rw_pic = tex;
R_DrawDrawSeg(frontsector, curline, WallC, rw_pic, ds, x1, x2, mceilingclip, mfloorclip, texturemid, MaskedSWall, maskedtexturecol, ds->yscale, wallshade, rw_offset, rw_light, rw_lightstep, ds->foggy, basecolormap);
double top, bot;
R_GetMaskedWallTopBottom(ds, top, bot);
RenderWallPart renderWallpart;
renderWallpart.Render(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);
} }
clearfog: clearfog:
@ -551,7 +576,12 @@ namespace swrenderer
ProjectedWallTexcoords walltexcoords; ProjectedWallTexcoords walltexcoords;
walltexcoords.ProjectPos(curline->sidedef->TexelLength*xscale, ds->sx1, ds->sx2, WallT); walltexcoords.ProjectPos(curline->sidedef->TexelLength*xscale, ds->sx1, ds->sx2, WallT);
R_DrawDrawSeg(frontsector, curline, WallC, rw_pic, ds, x1, x2, wallupper.ScreenY, walllower.ScreenY, texturemid, MaskedSWall, walltexcoords.UPos, yscale, wallshade, rw_offset, rw_light, rw_lightstep, ds->foggy, basecolormap);
double top, bot;
R_GetMaskedWallTopBottom(ds, top, bot);
RenderWallPart renderWallpart;
renderWallpart.Render(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);
} }
// kg3D - walls of fake floors // kg3D - walls of fake floors

View File

@ -62,4 +62,5 @@ namespace swrenderer
void R_RenderMaskedSegRange(drawseg_t *ds, int x1, int x2); void R_RenderMaskedSegRange(drawseg_t *ds, int x1, int x2);
void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover, int wallshade, FDynamicColormap *basecolormap); void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover, int wallshade, FDynamicColormap *basecolormap);
void R_RenderFakeWallRange(drawseg_t *ds, int x1, int x2, int wallshade); void R_RenderFakeWallRange(drawseg_t *ds, int x1, int x2, int wallshade);
void R_GetMaskedWallTopBottom(drawseg_t *ds, double &top, double &bot);
} }