Reapply 'Implement per-texture offsets in UDMF'

This reverts commit c713de1225.
This commit is contained in:
NepDisk 2025-02-11 16:10:22 -05:00
parent 7af12aefd7
commit 8f040ed151
7 changed files with 132 additions and 46 deletions

View file

@ -110,7 +110,7 @@ mapformat_udmf
// When this is set to true, sectors with the same tag will light up when a line is highlighted
linetagindicatesectors = false;
localsidedeftextureoffsets = false;
localsidedeftextureoffsets = true;
// Enables support for plane equation slopes
planeequationsupport = true;

View file

@ -1291,7 +1291,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
else
texturevpeg = gl_backsector->ceilingheight + textureheight[gl_toptexture] - gl_frontsector->ceilingheight;
texturevpeg += gl_sidedef->rowoffset;
texturevpeg += gl_sidedef->rowoffset + gl_sidedef->offsety_top;
// This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway
texturevpeg %= textureheight[gl_toptexture];
@ -1300,8 +1300,8 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (texturevpeg + gl_frontsector->ceilingheight - gl_backsector->ceilingheight) * grTex->scaleY;
wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX;
wallVerts[0].s = wallVerts[3].s = (cliplow + gl_sidedef->offsetx_top) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = (cliphigh + gl_sidedef->offsetx_top) * grTex->scaleX;
// Adjust t value for sloped walls
if (!(gl_linedef->flags & ML_SKEWTD))
@ -1356,7 +1356,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
else
texturevpeg = gl_frontsector->floorheight - gl_backsector->floorheight;
texturevpeg += gl_sidedef->rowoffset;
texturevpeg += gl_sidedef->rowoffset + gl_sidedef->offsety_bot;
// This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway
texturevpeg %= textureheight[gl_bottomtexture];
@ -1365,8 +1365,8 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (texturevpeg + gl_backsector->floorheight - gl_frontsector->floorheight) * grTex->scaleY;
wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX;
wallVerts[0].s = wallVerts[3].s = (cliplow + gl_sidedef->offsetx_bot) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = (cliphigh + gl_sidedef->offsetx_bot) * grTex->scaleX;
// Adjust t value for sloped walls
if (!(gl_linedef->flags & ML_SKEWTD))
@ -1480,12 +1480,12 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
{
if (gl_linedef->flags & ML_MIDPEG) // Peg it to the floor
{
polybottom = max(front->floorheight, back->floorheight) + gl_sidedef->rowoffset;
polybottom = max(front->floorheight, back->floorheight) + gl_sidedef->rowoffset + gl_sidedef->offsety_mid;
polytop = polybottom + midtexheight;
}
else // Peg it to the ceiling
{
polytop = min(front->ceilingheight, back->ceilingheight) + gl_sidedef->rowoffset;
polytop = min(front->ceilingheight, back->ceilingheight) + gl_sidedef->rowoffset + gl_sidedef->offsety_mid;
polybottom = polytop - midtexheight;
}
@ -1495,9 +1495,9 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
}
else if (gl_linedef->flags & ML_MIDPEG) // Skew the texture, but peg it to the floor
{
polybottom = popenbottom + gl_sidedef->rowoffset;
polybottom = popenbottom + gl_sidedef->rowoffset + gl_sidedef->offsety_mid;
polytop = polybottom + midtexheight;
polybottomslope = popenbottomslope + gl_sidedef->rowoffset;
polybottomslope = popenbottomslope + gl_sidedef->rowoffset + gl_sidedef->offsety_mid;
polytopslope = polybottomslope + midtexheight;
}
else // Skew it according to the ceiling's slope
@ -1551,12 +1551,12 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
// Left side
wallVerts[3].t = texturevpeg * grTex->scaleY;
wallVerts[0].t = (h - l + texturevpeg) * grTex->scaleY;
wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX;
wallVerts[0].s = wallVerts[3].s = (cliplow + gl_sidedef->offsetx_mid) * grTex->scaleX;
// Right side
wallVerts[2].t = texturevpegslope * grTex->scaleY;
wallVerts[1].t = (hS - lS + texturevpegslope) * grTex->scaleY;
wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = (cliphigh + gl_sidedef->offsetx_mid) * grTex->scaleX;
// set top/bottom coords
// Take the texture peg into account, rather than changing the offsets past
@ -1694,19 +1694,19 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
// PEGGING
if ((gl_linedef->flags & (ML_DONTPEGBOTTOM|ML_NOSKEW)) == (ML_DONTPEGBOTTOM|ML_NOSKEW))
texturevpeg = gl_frontsector->floorheight + textureheight[gl_sidedef->midtexture] - gl_frontsector->ceilingheight + gl_sidedef->rowoffset;
texturevpeg = gl_frontsector->floorheight + textureheight[gl_sidedef->midtexture] - gl_frontsector->ceilingheight + gl_sidedef->rowoffset + gl_sidedef->offsety_mid;
else if (gl_linedef->flags & ML_DONTPEGBOTTOM)
texturevpeg = worldbottom + textureheight[gl_sidedef->midtexture] - worldtop + gl_sidedef->rowoffset;
texturevpeg = worldbottom + textureheight[gl_sidedef->midtexture] - worldtop + gl_sidedef->rowoffset + gl_sidedef->offsety_mid;
else
// top of texture at top
texturevpeg = gl_sidedef->rowoffset;
texturevpeg = gl_sidedef->rowoffset + gl_sidedef->offsety_mid;
grTex = HWR_GetTexture(gl_midtexture);
wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (texturevpeg + gl_frontsector->ceilingheight - gl_frontsector->floorheight) * grTex->scaleY;
wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX;
wallVerts[0].s = wallVerts[3].s = (cliplow + gl_sidedef->offsetx_mid) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = (cliphigh + gl_sidedef->offsetx_mid) * grTex->scaleX;
// Texture correction for slopes
if (gl_linedef->flags & ML_NOSKEW) {
@ -1876,13 +1876,13 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
// -- Monster Iestyn 26/06/18
if (newline)
{
texturevpeg = sides[newline->sidenum[0]].rowoffset;
texturevpeg = sides[newline->sidenum[0]].rowoffset + sides[newline->sidenum[0]].offsety_mid;
attachtobottom = !!(newline->flags & ML_DONTPEGBOTTOM);
slopeskew = !!(newline->flags & ML_SKEWTD);
}
else
{
texturevpeg = sides[rover->master->sidenum[0]].rowoffset;
texturevpeg = sides[rover->master->sidenum[0]].rowoffset + sides[rover->master->sidenum[0]].offsety_mid;
attachtobottom = !!(gl_linedef->flags & ML_DONTPEGBOTTOM);
slopeskew = !!(rover->master->flags & ML_SKEWTD);
}
@ -1914,8 +1914,8 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
}
}
wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX;
wallVerts[0].s = wallVerts[3].s = (cliplow + gl_sidedef->offsetx_mid) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = (cliphigh + gl_sidedef->offsetx_mid) * grTex->scaleX;
}
if (rover->fofflags & FOF_FOG)
{
@ -2030,17 +2030,17 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if (newline)
{
wallVerts[3].t = wallVerts[2].t = (*rover->topheight - h + sides[newline->sidenum[0]].rowoffset) * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (h - l + (*rover->topheight - h + sides[newline->sidenum[0]].rowoffset)) * grTex->scaleY;
wallVerts[3].t = wallVerts[2].t = (*rover->topheight - h + sides[newline->sidenum[0]].rowoffset + sides[newline->sidenum[0]].offsety_mid) * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (h - l + (*rover->topheight - h + sides[newline->sidenum[0]].rowoffset) + sides[newline->sidenum[0]].offsety_mid) * grTex->scaleY;
}
else
{
wallVerts[3].t = wallVerts[2].t = (*rover->topheight - h + sides[rover->master->sidenum[0]].rowoffset) * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (h - l + (*rover->topheight - h + sides[rover->master->sidenum[0]].rowoffset)) * grTex->scaleY;
wallVerts[3].t = wallVerts[2].t = (*rover->topheight - h + sides[rover->master->sidenum[0]].rowoffset + sides[rover->master->sidenum[0]].offsety_mid) * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (h - l + (*rover->topheight - h + sides[rover->master->sidenum[0]].rowoffset + sides[rover->master->sidenum[0]].offsety_mid)) * grTex->scaleY;
}
wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX;
wallVerts[0].s = wallVerts[3].s = (cliplow + gl_sidedef->offsetx_mid) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = (cliphigh + gl_sidedef->offsetx_mid) * grTex->scaleX;
}
if (rover->fofflags & FOF_FOG)

View file

@ -170,6 +170,12 @@ enum side_e {
side_valid = 0,
side_textureoffset,
side_rowoffset,
side_offsetx_top,
side_offsety_top,
side_offsetx_mid,
side_offsety_mid,
side_offsetx_bot,
side_offsety_bot,
side_toptexture,
side_bottomtexture,
side_midtexture,
@ -184,6 +190,12 @@ static const char *const side_opt[] = {
"valid",
"textureoffset",
"rowoffset",
"offsetx_top",
"offsety_top",
"offsetx_mid",
"offsety_mid",
"offsetx_bot",
"offsety_bot",
"toptexture",
"bottomtexture",
"midtexture",
@ -1166,6 +1178,24 @@ static int side_get(lua_State *L)
case side_rowoffset:
lua_pushfixed(L, side->rowoffset);
return 1;
case side_offsetx_top:
lua_pushfixed(L, side->offsetx_top);
return 1;
case side_offsety_top:
lua_pushfixed(L, side->offsety_top);
return 1;
case side_offsetx_mid:
lua_pushfixed(L, side->offsetx_mid);
return 1;
case side_offsety_mid:
lua_pushfixed(L, side->offsety_mid);
return 1;
case side_offsetx_bot:
lua_pushfixed(L, side->offsetx_bot);
return 1;
case side_offsety_bot:
lua_pushfixed(L, side->offsety_bot);
return 1;
case side_toptexture:
lua_pushinteger(L, side->toptexture);
return 1;
@ -1224,6 +1254,24 @@ static int side_set(lua_State *L)
case side_rowoffset:
side->rowoffset = luaL_checkfixed(L, 3);
break;
case side_offsetx_top:
side->offsetx_top = luaL_checkfixed(L, 3);
break;
case side_offsety_top:
side->offsety_top = luaL_checkfixed(L, 3);
break;
case side_offsetx_mid:
side->offsetx_mid = luaL_checkfixed(L, 3);
break;
case side_offsety_mid:
side->offsety_mid = luaL_checkfixed(L, 3);
break;
case side_offsetx_bot:
side->offsetx_bot = luaL_checkfixed(L, 3);
break;
case side_offsety_bot:
side->offsety_bot = luaL_checkfixed(L, 3);
break;
case side_toptexture:
side->toptexture = luaL_checkinteger(L, 3);
break;

View file

@ -447,17 +447,17 @@ P_GetMidtextureTopBottom
{
if ((linedef->flags & ML_WRAPMIDTEX) && !side->repeatcnt) // "infinite" repeat
{
texbottom = back->floorheight + side->rowoffset;
textop = back->ceilingheight + side->rowoffset;
texbottom = back->floorheight + side->rowoffset + side->offsety_mid;
textop = back->ceilingheight + side->rowoffset + side->offsety_mid;
}
else if (linedef->flags & ML_MIDPEG)
{
texbottom = back->floorheight + side->rowoffset;
texbottom = back->floorheight + side->rowoffset + side->offsety_mid;
textop = texbottom + texheight*(side->repeatcnt+1);
}
else
{
textop = back->ceilingheight + side->rowoffset;
textop = back->ceilingheight + side->rowoffset + side->offsety_mid;
texbottom = textop - texheight*(side->repeatcnt+1);
}
}
@ -466,17 +466,17 @@ P_GetMidtextureTopBottom
{
if ((linedef->flags & ML_WRAPMIDTEX) && !side->repeatcnt) // "infinite" repeat
{
texbottom = open->floor + side->rowoffset;
textop = open->ceiling + side->rowoffset;
texbottom = open->floor + side->rowoffset + side->offsety_mid;
textop = open->ceiling + side->rowoffset + side->offsety_mid;
}
else if (linedef->flags & ML_MIDPEG)
{
texbottom = open->floor + side->rowoffset;
texbottom = open->floor + side->rowoffset + side->offsety_mid;
textop = texbottom + texheight*(side->repeatcnt+1);
}
else
{
textop = open->ceiling + side->rowoffset;
textop = open->ceiling + side->rowoffset + side->offsety_mid;
texbottom = textop - texheight*(side->repeatcnt+1);
}
}

View file

@ -1349,6 +1349,9 @@ static void P_LoadSidedefs(UINT8 *data)
}
sd->rowoffset = SHORT(msd->rowoffset)<<FRACBITS;
sd->offsetx_top = sd->offsetx_mid = sd->offsetx_bot = 0;
sd->offsety_top = sd->offsety_mid = sd->offsety_bot = 0;
P_SetSidedefSector(i, SHORT(msd->sector));
// Special info stored in texture fields!
@ -2032,6 +2035,18 @@ static void ParseTextmapSidedefParameter(UINT32 i, const char *param, const char
sides[i].textureoffset = atol(val)<<FRACBITS;
else if (fastcmp(param, "offsety"))
sides[i].rowoffset = atol(val)<<FRACBITS;
else if (fastcmp(param, "offsetx_top"))
sides[i].offsetx_top = atol(val) << FRACBITS;
else if (fastcmp(param, "offsetx_mid"))
sides[i].offsetx_mid = atol(val) << FRACBITS;
else if (fastcmp(param, "offsetx_bottom"))
sides[i].offsetx_bot = atol(val) << FRACBITS;
else if (fastcmp(param, "offsety_top"))
sides[i].offsety_top = atol(val) << FRACBITS;
else if (fastcmp(param, "offsety_mid"))
sides[i].offsety_mid = atol(val) << FRACBITS;
else if (fastcmp(param, "offsety_bottom"))
sides[i].offsety_bot = atol(val) << FRACBITS;
else if (fastcmp(param, "texturetop"))
sides[i].toptexture = R_TextureNumForName(val);
else if (fastcmp(param, "texturebottom"))
@ -2944,6 +2959,18 @@ static void P_WriteTextmap(void)
fprintf(f, "offsetx = %d;\n", wsides[i].textureoffset >> FRACBITS);
if (wsides[i].rowoffset != 0)
fprintf(f, "offsety = %d;\n", wsides[i].rowoffset >> FRACBITS);
if (wsides[i].offsetx_top != 0)
fprintf(f, "offsetx_top = %d;\n", wsides[i].offsetx_top >> FRACBITS);
if (wsides[i].offsety_top != 0)
fprintf(f, "offsety_top = %d;\n", wsides[i].offsety_top >> FRACBITS);
if (wsides[i].offsetx_mid != 0)
fprintf(f, "offsetx_mid = %d;\n", wsides[i].offsetx_mid >> FRACBITS);
if (wsides[i].offsety_mid != 0)
fprintf(f, "offsety_mid = %d;\n", wsides[i].offsety_mid >> FRACBITS);
if (wsides[i].offsetx_bot != 0)
fprintf(f, "offsetx_bottom = %d;\n", wsides[i].offsetx_bot >> FRACBITS);
if (wsides[i].offsety_bot != 0)
fprintf(f, "offsety_bottom = %d;\n", wsides[i].offsety_bot >> FRACBITS);
if (wsides[i].toptexture > 0 && wsides[i].toptexture < numtextures)
fprintf(f, "texturetop = \"%.*s\";\n", 8, textures[wsides[i].toptexture]->name);
if (wsides[i].bottomtexture > 0 && wsides[i].bottomtexture < numtextures)
@ -3433,6 +3460,8 @@ static void P_LoadTextmap(void)
// Defaults.
sd->textureoffset = 0;
sd->rowoffset = 0;
sd->offsetx_top = sd->offsetx_mid = sd->offsetx_bot = 0;
sd->offsety_top = sd->offsety_mid = sd->offsety_bot = 0;
sd->toptexture = R_TextureNumForName("-");
sd->midtexture = R_TextureNumForName("-");
sd->bottomtexture = R_TextureNumForName("-");

View file

@ -645,6 +645,10 @@ struct side_t
// add this to the calculated texture top
fixed_t rowoffset;
// per-texture offsets for UDMF
fixed_t offsetx_top, offsetx_mid, offsetx_bot;
fixed_t offsety_top, offsety_mid, offsety_bot;
// Texture indices.
// We do not maintain names here.
INT32 toptexture, bottomtexture, midtexture;

View file

@ -67,6 +67,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;
static fixed_t rw_offset2; // for splats
static fixed_t rw_scale, rw_scalestep;
static fixed_t rw_midtexturemid, rw_toptexturemid, rw_bottomtexturemid;
@ -988,7 +989,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
if (newline)
{
offsetvalue = sides[newline->sidenum[0]].rowoffset;
offsetvalue = sides[newline->sidenum[0]].rowoffset + sides[newline->sidenum[0]].offsety_mid;
if (newline->flags & ML_DONTPEGBOTTOM)
{
skewslope = *pfloor->b_slope; // skew using bottom slope
@ -1000,7 +1001,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
}
else
{
offsetvalue = sides[pfloor->master->sidenum[0]].rowoffset;
offsetvalue = sides[pfloor->master->sidenum[0]].rowoffset + sides[pfloor->master->sidenum[0]].offsety_mid;
if (curline->linedef->flags & ML_DONTPEGBOTTOM)
{
skewslope = *pfloor->b_slope; // skew using bottom slope
@ -1326,11 +1327,12 @@ UINT32 nombre = 100000;
static void R_DrawWallColumn(drawcolumndata_t* dc, INT32 yl, INT32 yh, fixed_t mid, fixed_t texturecolumn, INT32 texture, boolean brightmapped, boolean remap)
{
INT32 itexturecolumn = texturecolumn >> FRACBITS;
dc->yl = yl;
dc->yh = yh;
dc->texturemid = mid;
dc->source = R_GetColumn(texture, texturecolumn);
dc->brightmap = (brightmapped ? R_GetBrightmapColumn(texture, texturecolumn) : NULL);
dc->source = R_GetColumn(texture, itexturecolumn + (rw_offset_mid>>FRACBITS));
dc->brightmap = (brightmapped ? R_GetBrightmapColumn(texture, itexturecolumn + (rw_offset_mid>>FRACBITS)) : NULL);
dc->texheight = textureheight[texture] >> FRACBITS;
dc->sourcelength = dc->texheight;
R_SetColumnFunc(colfunctype, dc->brightmap != NULL);
@ -1696,7 +1698,7 @@ static void R_RenderSegLoop (drawcolumndata_t* dc)
{
// save texturecol
// for backdrawing of masked mid texture
maskedtexturecol[rw_x] = (INT16)texturecolumn;
maskedtexturecol[rw_x] = texturecolumn + rw_offset_mid;
if (maskedtextureheight != NULL) {
maskedtextureheight[rw_x] = (curline->linedef->flags & ML_MIDPEG) ?
@ -2081,7 +2083,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
rw_midtexturemid = worldtop;
rw_midtextureslide = ceilingfrontslide;
}
rw_midtexturemid += sidedef->rowoffset;
rw_midtexturemid += sidedef->rowoffset + sidedef->offsety_mid;
ds_p->silhouette = SIL_BOTH;
ds_p->sprtopclip = screenheightarray;
@ -2358,8 +2360,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
}
}
rw_toptexturemid += sidedef->rowoffset;
rw_bottomtexturemid += sidedef->rowoffset;
rw_toptexturemid += sidedef->rowoffset + sidedef->offsety_top;
rw_bottomtexturemid += sidedef->rowoffset + sidedef->offsety_bot;
R_AllocTextureColumnTables(rw_stopx - start);
@ -2604,8 +2606,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
rw_midtexturebackslide = ceilingbackslide;
}
}
rw_midtexturemid += sidedef->rowoffset;
rw_midtextureback += sidedef->rowoffset;
rw_midtexturemid += sidedef->rowoffset + sidedef->offsety_mid;
rw_midtextureback += sidedef->rowoffset + sidedef->offsety_mid;
if (R_IsDebugLine(curline))
{
@ -2654,6 +2656,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
/// don't use texture offset for splats
rw_offset2 = rw_offset + curline->offset;
rw_offset += sidedef->textureoffset + curline->offset;
rw_offset_top = sidedef->offsetx_top;
rw_offset_mid = sidedef->offsetx_mid;
rw_offset_bot = sidedef->offsetx_bot;
rw_centerangle = ANGLE_90 + viewangle - rw_normalangle;
// calculate light table