- remove pointless duplication of FWallCoords member variables

This commit is contained in:
Magnus Norddahl 2018-12-28 01:13:58 +01:00
parent 4d3d4ea746
commit 45d3df9df1
7 changed files with 29 additions and 48 deletions

View file

@ -328,17 +328,8 @@ namespace swrenderer
Thread->DrawSegments->Push(draw_segment);
draw_segment->CurrentPortalUniq = renderportal->CurrentPortalUniq;
draw_segment->sx1 = WallC.sx1;
draw_segment->sx2 = WallC.sx2;
draw_segment->sz1 = WallC.sz1;
draw_segment->sz2 = WallC.sz2;
draw_segment->cx = WallC.tleft.X;
draw_segment->cy = WallC.tleft.Y;
draw_segment->cdx = WallC.tright.X - WallC.tleft.X;
draw_segment->cdy = WallC.tright.Y - WallC.tleft.Y;
draw_segment->WallC = WallC;
draw_segment->tmapvals = WallT;
draw_segment->siz1 = 1 / WallC.sz1;
draw_segment->siz2 = 1 / WallC.sz2;
draw_segment->x1 = start;
draw_segment->x2 = stop;
draw_segment->curline = mLineSegment;

View file

@ -219,12 +219,12 @@ namespace swrenderer
}
// [RH] Don't bother drawing segs that are completely offscreen
if (viewport->globaldclip * ds->sz1 < -textop && viewport->globaldclip * ds->sz2 < -textop)
if (viewport->globaldclip * ds->WallC.sz1 < -textop && viewport->globaldclip * ds->WallC.sz2 < -textop)
{ // Texture top is below the bottom of the screen
return false;
}
if (viewport->globaluclip * ds->sz1 > texheight - textop && viewport->globaluclip * ds->sz2 > texheight - textop)
if (viewport->globaluclip * ds->WallC.sz1 > texheight - textop && viewport->globaluclip * ds->WallC.sz2 > texheight - textop)
{ // Texture bottom is above the top of the screen
return false;
}
@ -238,10 +238,10 @@ namespace swrenderer
return true;
}
WallC.sz1 = ds->sz1;
WallC.sz2 = ds->sz2;
WallC.sx1 = ds->sx1;
WallC.sx2 = ds->sx2;
WallC.sz1 = ds->WallC.sz1;
WallC.sz2 = ds->WallC.sz2;
WallC.sx1 = ds->WallC.sx1;
WallC.sx2 = ds->WallC.sx2;
// Unclipped vanilla Doom range for the wall. Relies on ceiling/floor clip to clamp the wall in range.
double ceilZ = textop;
@ -345,10 +345,10 @@ namespace swrenderer
texturemid = (texturemid - Thread->Viewport->viewpoint.Pos.Z) * MaskedScaleY + rowoffset;
}
WallC.sz1 = ds->sz1;
WallC.sz2 = ds->sz2;
WallC.sx1 = ds->sx1;
WallC.sx2 = ds->sx2;
WallC.sz1 = ds->WallC.sz1;
WallC.sz2 = ds->WallC.sz2;
WallC.sx1 = ds->WallC.sx1;
WallC.sx2 = ds->WallC.sx2;
if (clip3d->CurrentSkybox)
{ // Midtex clipping doesn't work properly with skyboxes, since you're normally below the floor
@ -462,14 +462,7 @@ namespace swrenderer
texturemid += rowoffset;
}
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;
WallC = ds->WallC;
WallT = ds->tmapvals;
Clip3DFloors *clip3d = Thread->Clip3D.get();
@ -488,7 +481,7 @@ namespace swrenderer
}
ProjectedWallTexcoords walltexcoords;
walltexcoords.ProjectPos(Thread->Viewport.get(), curline->sidedef->TexelLength*xscale, ds->sx1, ds->sx2, WallT);
walltexcoords.ProjectPos(Thread->Viewport.get(), curline->sidedef->TexelLength*xscale, ds->WallC.sx1, ds->WallC.sx2, WallT);
double top, bot;
GetMaskedWallTopBottom(ds, top, bot);

View file

@ -206,10 +206,8 @@ namespace swrenderer
// Create a drawseg to clip sprites to the sky plane
DrawSegment *draw_segment = Thread->FrameMemory->NewObject<DrawSegment>();
draw_segment->CurrentPortalUniq = CurrentPortalUniq;
draw_segment->siz1 = INT_MAX;
draw_segment->siz2 = INT_MAX;
draw_segment->sz1 = 0;
draw_segment->sz2 = 0;
draw_segment->WallC.sz1 = 0;
draw_segment->WallC.sz2 = 0;
draw_segment->x1 = pl->left;
draw_segment->x2 = pl->right;
draw_segment->silhouette = SIL_BOTH;

View file

@ -107,18 +107,18 @@ namespace swrenderer
group.EndIndex = MIN(index + groupSize, SegmentsCount());
group.x1 = ds->x1;
group.x2 = ds->x2;
group.neardepth = MIN(ds->sz1, ds->sz2);
group.fardepth = MAX(ds->sz1, ds->sz2);
group.neardepth = MIN(ds->WallC.sz1, ds->WallC.sz2);
group.fardepth = MAX(ds->WallC.sz1, ds->WallC.sz2);
for (unsigned int groupIndex = group.BeginIndex + 1; groupIndex < group.EndIndex; groupIndex++)
{
ds = Segment(groupIndex);
group.x1 = MIN(group.x1, ds->x1);
group.x2 = MAX(group.x2, ds->x2);
group.neardepth = MIN(group.neardepth, ds->sz1);
group.neardepth = MIN(group.neardepth, ds->sz2);
group.fardepth = MAX(ds->sz1, group.fardepth);
group.fardepth = MAX(ds->sz2, group.fardepth);
group.neardepth = MIN(group.neardepth, ds->WallC.sz1);
group.neardepth = MIN(group.neardepth, ds->WallC.sz2);
group.fardepth = MAX(ds->WallC.sz1, group.fardepth);
group.fardepth = MAX(ds->WallC.sz2, group.fardepth);
}
for (int x = group.x1; x < group.x2; x++)

View file

@ -31,10 +31,7 @@ namespace swrenderer
float light, lightstep;
float iscale, iscalestep;
short x1, x2; // Same as sx1 and sx2, but clipped to the drawseg
short sx1, sx2; // left, right of parent seg on screen
float sz1, sz2; // z for left, right of parent seg on screen
float siz1, siz2; // 1/z for left, right of parent seg on screen
float cx, cy, cdx, cdy;
FWallCoords WallC;
float yscale;
uint8_t silhouette = 0; // 0=none, 1=bottom, 2=top, 3=both
bool bFogBoundary = false;

View file

@ -291,7 +291,9 @@ namespace swrenderer
{
continue;
}
if ((ds->siz2 - ds->siz1) * ((x2 + x1) / 2 - ds->sx1) / (ds->sx2 - ds->sx1) + ds->siz1 < idepth)
float siz1 = 1 / ds->WallC.sz1;
float siz2 = 1 / ds->WallC.sz2;
if ((siz2 - siz1) * ((x2 + x1) / 2 - ds->WallC.sx1) / (ds->WallC.sx2 - ds->WallC.sx1) + siz1 < idepth)
{
// [ZZ] only draw stuff that's inside the same portal as the particle, other portals will care for themselves
if (ds->CurrentPortalUniq == CurrentPortalUniq)

View file

@ -340,8 +340,8 @@ namespace swrenderer
continue;
}
float neardepth = MIN(ds->sz1, ds->sz2);
float fardepth = MAX(ds->sz1, ds->sz2);
float neardepth = MIN(ds->WallC.sz1, ds->WallC.sz2);
float fardepth = MAX(ds->WallC.sz1, ds->WallC.sz2);
// Check if sprite is in front of draw seg:
if ((!spr->IsWallSprite() && neardepth > spr->depth) || ((spr->IsWallSprite() || fardepth > spr->depth) &&
@ -414,8 +414,8 @@ namespace swrenderer
int r1 = MAX<int>(ds->x1, x1);
int r2 = MIN<int>(ds->x2, x2);
float neardepth = MIN(ds->sz1, ds->sz2);
float fardepth = MAX(ds->sz1, ds->sz2);
float neardepth = MIN(ds->WallC.sz1, ds->WallC.sz2);
float fardepth = MAX(ds->WallC.sz1, ds->WallC.sz2);
// Check if sprite is in front of draw seg:
if ((!spr->IsWallSprite() && neardepth > spr->depth) || ((spr->IsWallSprite() || fardepth > spr->depth) &&