Wall per-texture scaling and offsetting.

This commit is contained in:
Nev3r 2020-04-22 10:10:39 +02:00
parent 1fa8acd70f
commit 5502761a74

View file

@ -41,6 +41,10 @@ angle_t rw_normalangle;
// angle to line origin
angle_t rw_angle1;
fixed_t rw_distance;
// Horizontal scaling hack shenanigans.
fixed_t rw_distance_scalex_top;
fixed_t rw_distance_scalex_mid;
fixed_t rw_distance_scalex_bot;
//
// regular wall
@ -48,6 +52,7 @@ fixed_t rw_distance;
static INT32 rw_x, rw_stopx;
static angle_t rw_centerangle;
static fixed_t rw_offset;
static fixed_t rw_offset_top, rw_offset_mid, rw_offset_bot; // Independent offsets.
static fixed_t rw_offset2; // for splats
static fixed_t rw_scale, rw_scalestep;
static fixed_t rw_midtexturemid, rw_toptexturemid, rw_bottomtexturemid;
@ -58,6 +63,7 @@ static fixed_t rw_midtextureback, rw_midtexturebackslide; // Values for masked m
static fixed_t pixhigh, pixlow, pixhighstep, pixlowstep;
static fixed_t topfrac, topstep;
static fixed_t bottomfrac, bottomstep;
static fixed_t topxscale, topyscale, midxscale, midyscale, botxscale, botyscale;
static lighttable_t **walllights;
static INT16 *maskedtexturecol;
@ -1258,6 +1264,9 @@ static void R_RenderSegLoop (void)
INT32 mid;
fixed_t texturecolumn = 0;
fixed_t texturecolumn_top = 0;
fixed_t texturecolumn_mid = 0;
fixed_t texturecolumn_bot = 0;
fixed_t oldtexturecolumn = -1;
INT32 top;
INT32 bottom;
@ -1377,6 +1386,9 @@ static void R_RenderSegLoop (void)
// calculate texture offset
angle = (rw_centerangle + xtoviewangle[rw_x])>>ANGLETOFINESHIFT;
texturecolumn = rw_offset-FixedMul(FINETANGENT(angle),rw_distance);
texturecolumn_top = (rw_offset_top - FixedMul(FINETANGENT(angle),rw_distance_scalex_top))>>FRACBITS;
texturecolumn_mid = (rw_offset_mid - FixedMul(FINETANGENT(angle),rw_distance_scalex_mid))>>FRACBITS;
texturecolumn_bot = (rw_offset_bot - FixedMul(FINETANGENT(angle),rw_distance_scalex_bot))>>FRACBITS;
if (oldtexturecolumn != -1) {
rw_bottomtexturemid += FixedMul(rw_bottomtextureslide, oldtexturecolumn-texturecolumn);
@ -1451,8 +1463,9 @@ static void R_RenderSegLoop (void)
{
dc_yl = yl;
dc_yh = yh;
dc_texturemid = rw_midtexturemid;
dc_source = R_GetColumn(midtexture,texturecolumn);
dc_texturemid = FixedMul(rw_midtexturemid, midyscale);
dc_iscale = FixedMul(0xffffffffu / (unsigned)rw_scale, midyscale);
dc_source = R_GetColumn(midtexture, texturecolumn_mid);
dc_texheight = textureheight[midtexture]>>FRACBITS;
//profile stuff ---------------------------------------------------------
@ -1504,8 +1517,9 @@ static void R_RenderSegLoop (void)
{
dc_yl = yl;
dc_yh = mid;
dc_texturemid = rw_toptexturemid;
dc_source = R_GetColumn(toptexture,texturecolumn);
dc_texturemid = FixedMul(rw_toptexturemid, topyscale);
dc_iscale = FixedMul(0xffffffffu / (unsigned)rw_scale, topyscale);
dc_source = R_GetColumn(toptexture, texturecolumn_top);
dc_texheight = textureheight[toptexture]>>FRACBITS;
colfunc();
ceilingclip[rw_x] = (INT16)mid;
@ -1537,9 +1551,9 @@ static void R_RenderSegLoop (void)
{
dc_yl = mid;
dc_yh = yh;
dc_texturemid = rw_bottomtexturemid;
dc_source = R_GetColumn(bottomtexture,
texturecolumn);
dc_texturemid = FixedMul(rw_bottomtexturemid, botyscale);
dc_iscale = FixedMul(0xffffffffu / (unsigned)rw_scale, botyscale);
dc_source = R_GetColumn(bottomtexture, texturecolumn_bot);
dc_texheight = textureheight[bottomtexture]>>FRACBITS;
colfunc();
floorclip[rw_x] = (INT16)mid;
@ -2400,6 +2414,21 @@ void R_StoreWallRange(INT32 start, INT32 stop)
/// don't use texture offset for splats
rw_offset2 = rw_offset + curline->offset;
// Per-texture scaling, offsetting.
topxscale = sidedef->topscale.x;
midxscale = sidedef->midscale.x;
botxscale = sidedef->botscale.x;
topyscale = sidedef->topscale.y;
midyscale = sidedef->midscale.y;
botyscale = sidedef->botscale.y;
rw_offset_top = FixedMul(rw_offset + curline->offset, topxscale) + sidedef->textureoffset + sidedef->topoffset.x;
rw_offset_mid = FixedMul(rw_offset + curline->offset, midxscale) + sidedef->textureoffset + sidedef->midoffset.x;
rw_offset_bot = FixedMul(rw_offset + curline->offset, botxscale) + sidedef->textureoffset + sidedef->botoffset.x;
rw_distance_scalex_top = FixedMul(rw_distance, topxscale);
rw_distance_scalex_mid = FixedMul(rw_distance, midxscale);
rw_distance_scalex_bot = FixedMul(rw_distance, botxscale);
rw_offset += sidedef->textureoffset + curline->offset;
rw_centerangle = ANGLE_90 + viewangle - rw_normalangle;