Merge branch 'fix-3dfloor-scaling' into 'next'

Fix 3D floor side texture scale when there are multiple on the same line

See merge request STJr/SRB2!2262
This commit is contained in:
sphere 2024-01-10 14:41:34 +00:00
commit c938d7757b
2 changed files with 30 additions and 10 deletions

View file

@ -1625,12 +1625,17 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
side_t *side = &sides[rover->master->sidenum[0]];
INT16 lineflags;
if (rover->master->flags & ML_TFERLINE)
{
size_t linenum = gl_curline->linedef-gl_backsector->lines[0];
newline = rover->master->frontsector->lines[0] + linenum;
side = &sides[newline->sidenum[0]];
lineflags = newline->flags;
}
else
lineflags = gl_curline->linedef->flags;
texnum = R_GetTextureNum(side->midtexture);
@ -1669,13 +1674,13 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
// ...Oh well, anyway, Lower Unpegged now changes pegging of FOFs like in software
// -- Monster Iestyn 26/06/18
fixed_t texturevpeg = side->rowoffset + side->offsety_mid;
boolean attachtobottom = !!(rover->master->flags & ML_DONTPEGBOTTOM);
boolean attachtobottom = !!(lineflags & ML_DONTPEGBOTTOM);
grTex = HWR_GetTexture(texnum);
xscale = FixedToFloat(side->scalex_mid);
yscale = FixedToFloat(side->scaley_mid);
if (!(rover->master->flags & ML_SKEWTD)) // no skewing
if (!(lineflags & ML_SKEWTD)) // no skewing
{
if (attachtobottom)
texturevpeg -= (*rover->topheight - *rover->bottomheight) * yscale;

View file

@ -525,6 +525,9 @@ static boolean R_IsFFloorTranslucent(visffloor_t *pfloor)
//
// R_RenderThickSideRange
// Renders all the thick sides in the given range.
static fixed_t ffloortexturecolumn[MAXVIDWIDTH];
void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
{
size_t pindex;
@ -550,7 +553,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
fixed_t left_top, left_bottom; // needed here for slope skewing
pslope_t *skewslope = NULL;
boolean do_texture_skew;
UINT32 lineflags;
INT16 lineflags;
fixed_t wall_scalex, wall_scaley;
void (*colfunc_2s) (column_t *);
@ -575,7 +578,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
lineflags = newline->flags;
}
else
lineflags = pfloor->master->flags;
lineflags = curline->linedef->flags;
texnum = R_GetTextureNum(sidedef->midtexture);
@ -732,10 +735,18 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
wall_scalex = FixedDiv(FRACUNIT, sidedef->scalex_mid);
wall_scaley = sidedef->scaley_mid;
thicksidecol = ds->thicksidecol;
thicksidecol = ffloortexturecolumn;
for (INT32 x = x1; x <= x2; x++)
thicksidecol[x] = FixedDiv(thicksidecol[x], wall_scalex) + ds->offsetx;
if (wall_scalex == FRACUNIT)
{
for (INT32 x = x1; x <= x2; x++)
thicksidecol[x] = ds->thicksidecol[x] + ds->offsetx;
}
else
{
for (INT32 x = x1; x <= x2; x++)
thicksidecol[x] = FixedDiv(ds->thicksidecol[x], wall_scalex) + ds->offsetx;
}
mfloorclip = ds->sprbottomclip;
mceilingclip = ds->sprtopclip;
@ -746,10 +757,12 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
left_bottom = P_GetFFloorBottomZAt(pfloor, ds->leftpos.x, ds->leftpos.y) - viewz;
do_texture_skew = lineflags & ML_SKEWTD;
skewslope = *pfloor->t_slope; // skew using top slope by default
if (do_texture_skew)
{
skewslope = *pfloor->t_slope; // skew using top slope by default
dc_texturemid = FixedMul(left_top, wall_scaley);
}
else
dc_texturemid = FixedMul(*pfloor->topheight - viewz, wall_scaley);
@ -757,14 +770,16 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
if (lineflags & ML_DONTPEGBOTTOM)
{
skewslope = *pfloor->b_slope; // skew using bottom slope
if (do_texture_skew)
{
skewslope = *pfloor->b_slope; // skew using bottom slope
dc_texturemid = FixedMul(left_bottom, wall_scaley);
}
else
offsetvalue -= FixedMul(*pfloor->topheight - *pfloor->bottomheight, wall_scaley);
}
if (do_texture_skew && skewslope)
if (skewslope)
{
angle_t lineangle = R_PointToAngle2(curline->v1->x, curline->v1->y, curline->v2->x, curline->v2->y);
ffloortextureslide = FixedMul(skewslope->zdelta, FINECOSINE((lineangle-skewslope->xydirection)>>ANGLETOFINESHIFT));