Use untranslated texture for checking R_TextureCanRemap

- Handles animated textures correctly
This commit is contained in:
James R 2023-12-22 19:01:32 -08:00
parent 9bcdc9094b
commit dae4454055
4 changed files with 78 additions and 68 deletions

View file

@ -443,7 +443,7 @@ static UINT8 *MakeBlock(GLMipmap_t *grMipmap)
// Create a composite texture from patches, adapt the texture size to a power of 2 // Create a composite texture from patches, adapt the texture size to a power of 2
// height and width for the hardware texture cache. // height and width for the hardware texture cache.
// //
static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex) static void HWR_GenerateTexture(INT32 texnum, INT32 basetexnum, GLMapTexture_t *grtex)
{ {
UINT8 *block; UINT8 *block;
texture_t *texture; texture_t *texture;
@ -477,7 +477,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex)
grtex->mipmap.height = (UINT16)texture->height; grtex->mipmap.height = (UINT16)texture->height;
grtex->mipmap.format = textureformat; grtex->mipmap.format = textureformat;
if (encoremap && R_TextureCanRemap(texnum)) if (encoremap && R_TextureCanRemap(basetexnum))
colormap += COLORMAP_REMAPOFFSET; colormap += COLORMAP_REMAPOFFSET;
grtex->mipmap.colormap = Z_Calloc(sizeof(*grtex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL); grtex->mipmap.colormap = Z_Calloc(sizeof(*grtex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL);
@ -783,7 +783,7 @@ void HWR_SetPalette(RGBA_t *palette)
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Make sure texture is downloaded and set it as the source // Make sure texture is downloaded and set it as the source
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
GLMapTexture_t *HWR_GetTexture(INT32 tex) GLMapTexture_t *HWR_GetTexture(INT32 tex, INT32 basetex)
{ {
GLMapTexture_t *grtex; GLMapTexture_t *grtex;
#ifdef PARANOIA #ifdef PARANOIA
@ -797,7 +797,7 @@ GLMapTexture_t *HWR_GetTexture(INT32 tex)
// Generate texture if missing from the cache // Generate texture if missing from the cache
if (!grtex->mipmap.data && !grtex->mipmap.downloaded) if (!grtex->mipmap.data && !grtex->mipmap.downloaded)
HWR_GenerateTexture(tex, grtex); HWR_GenerateTexture(tex, basetex, grtex);
// If hardware does not have the texture, then call pfnSetTexture to upload it // If hardware does not have the texture, then call pfnSetTexture to upload it
if (!grtex->mipmap.downloaded) if (!grtex->mipmap.downloaded)

View file

@ -126,7 +126,7 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap);
void HWR_GetFadeMask(lumpnum_t fademasklumpnum); void HWR_GetFadeMask(lumpnum_t fademasklumpnum);
patch_t *HWR_GetPic(lumpnum_t lumpnum); patch_t *HWR_GetPic(lumpnum_t lumpnum);
GLMapTexture_t *HWR_GetTexture(INT32 tex); GLMapTexture_t *HWR_GetTexture(INT32 tex, INT32 basetex);
void HWR_GetLevelFlat(levelflat_t *levelflat, boolean noencoremap); void HWR_GetLevelFlat(levelflat_t *levelflat, boolean noencoremap);
void HWR_GetRawFlat(lumpnum_t flatlumpnum, boolean noencoremap); void HWR_GetRawFlat(lumpnum_t flatlumpnum, boolean noencoremap);

View file

@ -723,7 +723,7 @@ FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf)
return PF_Translucent; return PF_Translucent;
} }
static void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap); static void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, INT32 basetexnum, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap);
// ========================================================================== // ==========================================================================
// Wall generation from subsector segs // Wall generation from subsector segs
@ -762,7 +762,7 @@ static void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIEL
// //
// HWR_SplitWall // HWR_SplitWall
// //
static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor, FBITFIELD polyflags) static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, INT32 basetexnum, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor, FBITFIELD polyflags)
{ {
/* SoM: split up and light walls according to the /* SoM: split up and light walls according to the
lightlist. This may also include leaving out parts lightlist. This may also include leaving out parts
@ -900,9 +900,9 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
wallVerts[1].y = endbot; wallVerts[1].y = endbot;
if (polyflags & PF_Fog) if (polyflags & PF_Fog)
HWR_AddTransparentWall(wallVerts, Surf, texnum, polyflags, true, HWR_CalcWallLight(lightnum, gl_curline), colormap); HWR_AddTransparentWall(wallVerts, Surf, texnum, basetexnum, polyflags, true, HWR_CalcWallLight(lightnum, gl_curline), colormap);
else if (polyflags & PF_EnvironmentTrans) else if (polyflags & PF_EnvironmentTrans)
HWR_AddTransparentWall(wallVerts, Surf, texnum, polyflags, false, HWR_CalcWallLight(lightnum, gl_curline), colormap); HWR_AddTransparentWall(wallVerts, Surf, texnum, basetexnum, polyflags, false, HWR_CalcWallLight(lightnum, gl_curline), colormap);
else else
HWR_ProjectWall(wallVerts, Surf, polyflags, HWR_CalcWallLight(lightnum, gl_curline), colormap); HWR_ProjectWall(wallVerts, Surf, polyflags, HWR_CalcWallLight(lightnum, gl_curline), colormap);
@ -929,9 +929,9 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
wallVerts[1].y = endbot; wallVerts[1].y = endbot;
if (polyflags & PF_Fog) if (polyflags & PF_Fog)
HWR_AddTransparentWall(wallVerts, Surf, texnum, polyflags, true, HWR_CalcWallLight(lightnum, gl_curline), colormap); HWR_AddTransparentWall(wallVerts, Surf, texnum, basetexnum, polyflags, true, HWR_CalcWallLight(lightnum, gl_curline), colormap);
else if (polyflags & PF_EnvironmentTrans) else if (polyflags & PF_EnvironmentTrans)
HWR_AddTransparentWall(wallVerts, Surf, texnum, polyflags, false, HWR_CalcWallLight(lightnum, gl_curline), colormap); HWR_AddTransparentWall(wallVerts, Surf, texnum, basetexnum, polyflags, false, HWR_CalcWallLight(lightnum, gl_curline), colormap);
else else
HWR_ProjectWall(wallVerts, Surf, polyflags, HWR_CalcWallLight(lightnum, gl_curline), colormap); HWR_ProjectWall(wallVerts, Surf, polyflags, HWR_CalcWallLight(lightnum, gl_curline), colormap);
} }
@ -1037,6 +1037,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if (gl_backsector) if (gl_backsector)
{ {
INT32 gl_toptexture = 0, gl_bottomtexture = 0; INT32 gl_toptexture = 0, gl_bottomtexture = 0;
INT32 gl_basetoptexture = 0, gl_basebottomtexture = 0;
// two sided line // two sided line
boolean bothceilingssky = false; // turned on if both back and front ceilings are sky boolean bothceilingssky = false; // turned on if both back and front ceilings are sky
boolean bothfloorssky = false; // likewise, but for floors boolean bothfloorssky = false; // likewise, but for floors
@ -1060,9 +1061,15 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
} }
if (!bothceilingssky) if (!bothceilingssky)
gl_toptexture = R_GetTextureNum(gl_sidedef->toptexture); {
gl_basetoptexture = gl_sidedef->toptexture;
gl_toptexture = R_GetTextureNum(gl_basetoptexture);
}
if (!bothfloorssky) if (!bothfloorssky)
gl_bottomtexture = R_GetTextureNum(gl_sidedef->bottomtexture); {
gl_basebottomtexture = gl_sidedef->bottomtexture;
gl_bottomtexture = R_GetTextureNum(gl_basebottomtexture);
}
// check TOP TEXTURE // check TOP TEXTURE
if ((worldhighslope < worldtopslope || worldhigh < worldtop) && gl_toptexture) if ((worldhighslope < worldtopslope || worldhigh < worldtop) && gl_toptexture)
@ -1070,7 +1077,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
{ {
fixed_t texturevpegtop; // top fixed_t texturevpegtop; // top
grTex = HWR_GetTexture(gl_toptexture); grTex = HWR_GetTexture(gl_toptexture, gl_basetoptexture);
// PEGGING // PEGGING
if (gl_linedef->flags & ML_DONTPEGTOP) if (gl_linedef->flags & ML_DONTPEGTOP)
@ -1127,9 +1134,9 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
polyflags = PF_Environment; polyflags = PF_Environment;
if (gl_frontsector->numlights) if (gl_frontsector->numlights)
HWR_SplitWall(gl_frontsector, wallVerts, gl_toptexture, &Surf, FOF_CUTLEVEL, NULL, polyflags); HWR_SplitWall(gl_frontsector, wallVerts, gl_toptexture, gl_basetoptexture, &Surf, FOF_CUTLEVEL, NULL, polyflags);
else if (grTex->mipmap.flags & TF_TRANSPARENT) else if (grTex->mipmap.flags & TF_TRANSPARENT)
HWR_AddTransparentWall(wallVerts, &Surf, gl_toptexture, polyflags, false, lightnum, colormap); HWR_AddTransparentWall(wallVerts, &Surf, gl_toptexture, gl_basetoptexture, polyflags, false, lightnum, colormap);
else else
HWR_ProjectWall(wallVerts, &Surf, polyflags, lightnum, colormap); HWR_ProjectWall(wallVerts, &Surf, polyflags, lightnum, colormap);
} }
@ -1143,7 +1150,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
{ {
fixed_t texturevpegbottom = 0; // bottom fixed_t texturevpegbottom = 0; // bottom
grTex = HWR_GetTexture(gl_bottomtexture); grTex = HWR_GetTexture(gl_bottomtexture, gl_basebottomtexture);
// PEGGING // PEGGING
if (!(gl_linedef->flags & ML_DONTPEGBOTTOM)) if (!(gl_linedef->flags & ML_DONTPEGBOTTOM))
@ -1200,9 +1207,9 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
polyflags = PF_Environment; polyflags = PF_Environment;
if (gl_frontsector->numlights) if (gl_frontsector->numlights)
HWR_SplitWall(gl_frontsector, wallVerts, gl_bottomtexture, &Surf, FOF_CUTLEVEL, NULL, polyflags); HWR_SplitWall(gl_frontsector, wallVerts, gl_bottomtexture, gl_basebottomtexture, &Surf, FOF_CUTLEVEL, NULL, polyflags);
else if (grTex->mipmap.flags & TF_TRANSPARENT) else if (grTex->mipmap.flags & TF_TRANSPARENT)
HWR_AddTransparentWall(wallVerts, &Surf, gl_bottomtexture, polyflags, false, lightnum, colormap); HWR_AddTransparentWall(wallVerts, &Surf, gl_bottomtexture, gl_basebottomtexture, polyflags, false, lightnum, colormap);
else else
HWR_ProjectWall(wallVerts, &Surf, polyflags, lightnum, colormap); HWR_ProjectWall(wallVerts, &Surf, polyflags, lightnum, colormap);
} }
@ -1318,7 +1325,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
else else
texturevpeg = polytop - h; texturevpeg = polytop - h;
grTex = HWR_GetTexture(gl_midtexture); grTex = HWR_GetTexture(gl_midtexture, gl_sidedef->midtexture);
wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (h - l + texturevpeg) * grTex->scaleY; wallVerts[0].t = wallVerts[1].t = (h - l + texturevpeg) * grTex->scaleY;
@ -1407,14 +1414,14 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if (tripwire == false && gl_frontsector->numlights) if (tripwire == false && gl_frontsector->numlights)
{ {
if (!(blendmode & PF_Masked)) if (!(blendmode & PF_Masked))
HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FOF_TRANSLUCENT, NULL, blendmode); // vanilla just uses PF_Masked here - if we run into any issues, maybe change to that HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, gl_sidedef->midtexture, &Surf, FOF_TRANSLUCENT, NULL, blendmode); // vanilla just uses PF_Masked here - if we run into any issues, maybe change to that
else else
{ {
HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FOF_CUTLEVEL, NULL, blendmode); // vanilla just uses PF_Masked here - if we run into any issues, maybe change to that HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, gl_sidedef->midtexture, &Surf, FOF_CUTLEVEL, NULL, blendmode); // vanilla just uses PF_Masked here - if we run into any issues, maybe change to that
} }
} }
else if (!(blendmode & PF_Masked)) else if (!(blendmode & PF_Masked))
HWR_AddTransparentWall(wallVerts, &Surf, gl_midtexture, blendmode, false, lightnum, colormap); HWR_AddTransparentWall(wallVerts, &Surf, gl_midtexture, gl_sidedef->midtexture, blendmode, false, lightnum, colormap);
else else
HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap); HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap);
} }
@ -1463,7 +1470,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
// top of texture at top // top of texture at top
texturevpeg = gl_sidedef->rowoffset; texturevpeg = gl_sidedef->rowoffset;
grTex = HWR_GetTexture(gl_midtexture); grTex = HWR_GetTexture(gl_midtexture, gl_sidedef->midtexture);
wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; 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].t = wallVerts[1].t = (texturevpeg + gl_frontsector->ceilingheight - gl_frontsector->floorheight) * grTex->scaleY;
@ -1493,7 +1500,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
// I don't think that solid walls can use translucent linedef types... // I don't think that solid walls can use translucent linedef types...
if (gl_frontsector->numlights) if (gl_frontsector->numlights)
HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FOF_CUTLEVEL, NULL, 0); HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, gl_sidedef->midtexture, &Surf, FOF_CUTLEVEL, NULL, 0);
else else
{ {
FBITFIELD blendmode = PF_Masked; FBITFIELD blendmode = PF_Masked;
@ -1502,11 +1509,11 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
// I don't think that solid walls can use translucent linedef types... // I don't think that solid walls can use translucent linedef types...
if (gl_frontsector->numlights) if (gl_frontsector->numlights)
HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FOF_CUTLEVEL, NULL, blendmode); HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, gl_sidedef->midtexture, &Surf, FOF_CUTLEVEL, NULL, blendmode);
else else
{ {
if (grTex->mipmap.flags & TF_TRANSPARENT) if (grTex->mipmap.flags & TF_TRANSPARENT)
HWR_AddTransparentWall(wallVerts, &Surf, gl_midtexture, blendmode, false, lightnum, colormap); HWR_AddTransparentWall(wallVerts, &Surf, gl_midtexture, gl_sidedef->midtexture, blendmode, false, lightnum, colormap);
else else
HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap); HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap);
} }
@ -1543,7 +1550,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
// Used for height comparisons and etc across FOFs and slopes // Used for height comparisons and etc across FOFs and slopes
fixed_t high1, highslope1, low1, lowslope1; fixed_t high1, highslope1, low1, lowslope1;
INT32 texnum; INT32 texnum, basetexnum;
line_t * newline = NULL; // Multi-Property FOF line_t * newline = NULL; // Multi-Property FOF
lowcut = max(worldbottom, worldlow); lowcut = max(worldbottom, worldlow);
@ -1578,15 +1585,17 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope))
continue; continue;
texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); basetexnum = sides[rover->master->sidenum[0]].midtexture;
if (rover->master->flags & ML_TFERLINE) if (rover->master->flags & ML_TFERLINE)
{ {
size_t linenum = gl_curline->linedef-gl_backsector->lines[0]; size_t linenum = gl_curline->linedef-gl_backsector->lines[0];
newline = rover->master->frontsector->lines[0] + linenum; newline = rover->master->frontsector->lines[0] + linenum;
texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); basetexnum = sides[newline->sidenum[0]].midtexture;
} }
texnum = R_GetTextureNum(basetexnum);
h = P_GetFFloorTopZAt (rover, v1x, v1y); h = P_GetFFloorTopZAt (rover, v1x, v1y);
hS = P_GetFFloorTopZAt (rover, v2x, v2y); hS = P_GetFFloorTopZAt (rover, v2x, v2y);
l = P_GetFFloorBottomZAt(rover, v1x, v1y); l = P_GetFFloorBottomZAt(rover, v1x, v1y);
@ -1639,7 +1648,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
slopeskew = !!(rover->master->flags & ML_SKEWTD); slopeskew = !!(rover->master->flags & ML_SKEWTD);
} }
grTex = HWR_GetTexture(texnum); grTex = HWR_GetTexture(texnum, basetexnum);
if (!slopeskew) // no skewing if (!slopeskew) // no skewing
{ {
@ -1681,9 +1690,9 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap);
if (gl_frontsector->numlights) if (gl_frontsector->numlights)
HWR_SplitWall(gl_frontsector, wallVerts, 0, &Surf, rover->fofflags, rover, blendmode); HWR_SplitWall(gl_frontsector, wallVerts, 0, 0, &Surf, rover->fofflags, rover, blendmode);
else else
HWR_AddTransparentWall(wallVerts, &Surf, 0, blendmode, true, lightnum, colormap); HWR_AddTransparentWall(wallVerts, &Surf, 0, 0, blendmode, true, lightnum, colormap);
} }
else else
{ {
@ -1699,11 +1708,11 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
} }
if (gl_frontsector->numlights) if (gl_frontsector->numlights)
HWR_SplitWall(gl_frontsector, wallVerts, texnum, &Surf, rover->fofflags, rover, blendmode); HWR_SplitWall(gl_frontsector, wallVerts, texnum, basetexnum, &Surf, rover->fofflags, rover, blendmode);
else else
{ {
if (blendmode != PF_Masked) if (blendmode != PF_Masked)
HWR_AddTransparentWall(wallVerts, &Surf, texnum, blendmode, false, lightnum, colormap); HWR_AddTransparentWall(wallVerts, &Surf, texnum, basetexnum, blendmode, false, lightnum, colormap);
else else
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap);
} }
@ -1738,14 +1747,17 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope))
continue; continue;
texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); basetexnum = sides[rover->master->sidenum[0]].midtexture;
if (rover->master->flags & ML_TFERLINE) if (rover->master->flags & ML_TFERLINE)
{ {
size_t linenum = gl_curline->linedef-gl_backsector->lines[0]; size_t linenum = gl_curline->linedef-gl_backsector->lines[0];
newline = rover->master->frontsector->lines[0] + linenum; newline = rover->master->frontsector->lines[0] + linenum;
texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); basetexnum = sides[newline->sidenum[0]].midtexture;
} }
texnum = R_GetTextureNum(basetexnum);
h = P_GetFFloorTopZAt (rover, v1x, v1y); h = P_GetFFloorTopZAt (rover, v1x, v1y);
hS = P_GetFFloorTopZAt (rover, v2x, v2y); hS = P_GetFFloorTopZAt (rover, v2x, v2y);
l = P_GetFFloorBottomZAt(rover, v1x, v1y); l = P_GetFFloorBottomZAt(rover, v1x, v1y);
@ -1778,7 +1790,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
} }
else else
{ {
grTex = HWR_GetTexture(texnum); grTex = HWR_GetTexture(texnum, basetexnum);
if (newline) if (newline)
{ {
@ -1807,9 +1819,9 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap);
if (gl_backsector->numlights) if (gl_backsector->numlights)
HWR_SplitWall(gl_backsector, wallVerts, 0, &Surf, rover->fofflags, rover, blendmode); HWR_SplitWall(gl_backsector, wallVerts, 0, 0, &Surf, rover->fofflags, rover, blendmode);
else else
HWR_AddTransparentWall(wallVerts, &Surf, 0, blendmode, true, lightnum, colormap); HWR_AddTransparentWall(wallVerts, &Surf, 0, 0, blendmode, true, lightnum, colormap);
} }
else else
{ {
@ -1825,11 +1837,11 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
} }
if (gl_backsector->numlights) if (gl_backsector->numlights)
HWR_SplitWall(gl_backsector, wallVerts, texnum, &Surf, rover->fofflags, rover, blendmode); HWR_SplitWall(gl_backsector, wallVerts, texnum, basetexnum, &Surf, rover->fofflags, rover, blendmode);
else else
{ {
if (blendmode != PF_Masked) if (blendmode != PF_Masked)
HWR_AddTransparentWall(wallVerts, &Surf, texnum, blendmode, false, lightnum, colormap); HWR_AddTransparentWall(wallVerts, &Surf, texnum, basetexnum, blendmode, false, lightnum, colormap);
else else
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap);
} }
@ -4094,7 +4106,7 @@ typedef struct
{ {
FOutVector wallVerts[4]; FOutVector wallVerts[4];
FSurfaceInfo Surf; FSurfaceInfo Surf;
INT32 texnum; INT32 texnum, basetexnum;
FBITFIELD blend; FBITFIELD blend;
INT32 drawcount; INT32 drawcount;
boolean fogwall; boolean fogwall;
@ -4368,7 +4380,7 @@ static void HWR_CreateDrawNodes(void)
else if (sortnode[sortindex[i]].wall) else if (sortnode[sortindex[i]].wall)
{ {
if (!(sortnode[sortindex[i]].wall->blend & PF_NoTexture)) if (!(sortnode[sortindex[i]].wall->blend & PF_NoTexture))
HWR_GetTexture(sortnode[sortindex[i]].wall->texnum); HWR_GetTexture(sortnode[sortindex[i]].wall->texnum, sortnode[sortindex[i]].wall->basetexnum);
HWR_RenderWall(sortnode[sortindex[i]].wall->wallVerts, &sortnode[sortindex[i]].wall->Surf, sortnode[sortindex[i]].wall->blend, sortnode[sortindex[i]].wall->fogwall, HWR_RenderWall(sortnode[sortindex[i]].wall->wallVerts, &sortnode[sortindex[i]].wall->Surf, sortnode[sortindex[i]].wall->blend, sortnode[sortindex[i]].wall->fogwall,
sortnode[sortindex[i]].wall->lightlevel, sortnode[sortindex[i]].wall->wallcolormap); sortnode[sortindex[i]].wall->lightlevel, sortnode[sortindex[i]].wall->wallcolormap);
} }
@ -5421,7 +5433,7 @@ static void HWR_DrawSkyBackground(player_t *player)
HWR_RollTransform(&dometransform, viewroll); HWR_RollTransform(&dometransform, viewroll);
dometransform.splitscreen = r_splitscreen; dometransform.splitscreen = r_splitscreen;
HWR_GetTexture(texturetranslation[skytexture]); HWR_GetTexture(texturetranslation[skytexture], skytexture);
if (gl_sky.texture != texturetranslation[skytexture]) if (gl_sky.texture != texturetranslation[skytexture])
{ {
@ -5441,7 +5453,7 @@ static void HWR_DrawSkyBackground(player_t *player)
float aspectratio; float aspectratio;
float angleturn; float angleturn;
HWR_GetTexture(texturetranslation[skytexture]); HWR_GetTexture(texturetranslation[skytexture], skytexture);
aspectratio = (float)vid.width/(float)vid.height; aspectratio = (float)vid.width/(float)vid.height;
//Hurdler: the sky is the only texture who need 4.0f instead of 1.0 //Hurdler: the sky is the only texture who need 4.0f instead of 1.0
@ -6026,7 +6038,7 @@ void transform(float *cx, float *cy, float *cz)
*cx *= gl_fovlud; *cx *= gl_fovlud;
} }
void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap) void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, INT32 basetexnum, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap)
{ {
static size_t allocedwalls = 0; static size_t allocedwalls = 0;
@ -6043,6 +6055,7 @@ void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 te
M_Memcpy(wallinfo[numwalls].wallVerts, wallVerts, sizeof (wallinfo[numwalls].wallVerts)); M_Memcpy(wallinfo[numwalls].wallVerts, wallVerts, sizeof (wallinfo[numwalls].wallVerts));
M_Memcpy(&wallinfo[numwalls].Surf, pSurf, sizeof (FSurfaceInfo)); M_Memcpy(&wallinfo[numwalls].Surf, pSurf, sizeof (FSurfaceInfo));
wallinfo[numwalls].texnum = texnum; wallinfo[numwalls].texnum = texnum;
wallinfo[numwalls].basetexnum = basetexnum;
wallinfo[numwalls].blend = blend; wallinfo[numwalls].blend = blend;
wallinfo[numwalls].drawcount = drawcount++; wallinfo[numwalls].drawcount = drawcount++;
wallinfo[numwalls].fogwall = fogwall; wallinfo[numwalls].fogwall = fogwall;

View file

@ -175,7 +175,7 @@ static inline boolean R_OverflowTest(drawcolumndata_t* dc)
return false; return false;
} }
static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT32 x1, INT32 x2, INT32 texnum, void (*colfunc_2s)(drawcolumndata_t*, column_t *, column_t *, INT32)) static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT32 x1, INT32 x2, INT32 texnum, INT32 basetexnum, void (*colfunc_2s)(drawcolumndata_t*, column_t *, column_t *, INT32))
{ {
size_t pindex; size_t pindex;
column_t *col, *bmCol = NULL; column_t *col, *bmCol = NULL;
@ -189,7 +189,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
INT32 times, repeats; INT32 times, repeats;
boolean tripwire; boolean tripwire;
boolean brightmapped = R_TextureHasBrightmap(texnum); boolean brightmapped = R_TextureHasBrightmap(texnum);
boolean remap = encoremap && R_TextureCanRemap(texnum); boolean remap = encoremap && R_TextureCanRemap(basetexnum);
ldef = curline->linedef; ldef = curline->linedef;
tripwire = P_IsLineTripWire(ldef); tripwire = P_IsLineTripWire(ldef);
@ -572,18 +572,12 @@ static void R_RenderMaskedSegLoopDebug(drawcolumndata_t* dc, drawseg_t *ds, INT3
static INT32 R_GetTwoSidedMidTexture(seg_t *line) static INT32 R_GetTwoSidedMidTexture(seg_t *line)
{ {
INT32 texture;
if (R_IsDebugLine(line)) if (R_IsDebugLine(line))
{ {
texture = g_texturenum_dbgline; return g_texturenum_dbgline;
}
else
{
texture = line->sidedef->midtexture;
} }
return R_GetTextureNum(texture); return line->sidedef->midtexture;
} }
static boolean R_CheckBlendMode(drawcolumndata_t* dc, const line_t *ldef, boolean brightmapped) static boolean R_CheckBlendMode(drawcolumndata_t* dc, const line_t *ldef, boolean brightmapped)
@ -635,7 +629,7 @@ static boolean R_CheckBlendMode(drawcolumndata_t* dc, const line_t *ldef, boolea
void R_RenderMaskedSegRange(drawseg_t *drawseg, INT32 x1, INT32 x2) void R_RenderMaskedSegRange(drawseg_t *drawseg, INT32 x1, INT32 x2)
{ {
INT32 texnum; INT32 texnum, basetexnum;
void (*colfunc_2s)(drawcolumndata_t*, column_t *, column_t *, INT32); void (*colfunc_2s)(drawcolumndata_t*, column_t *, column_t *, INT32);
line_t *ldef; line_t *ldef;
const boolean debug = R_IsDebugLine(drawseg->curline); const boolean debug = R_IsDebugLine(drawseg->curline);
@ -649,7 +643,8 @@ void R_RenderMaskedSegRange(drawseg_t *drawseg, INT32 x1, INT32 x2)
frontsector = curline->frontsector; frontsector = curline->frontsector;
backsector = curline->backsector; backsector = curline->backsector;
texnum = R_GetTwoSidedMidTexture(curline); basetexnum = R_GetTwoSidedMidTexture(curline);
texnum = R_GetTextureNum(basetexnum);
windowbottom = windowtop = sprbotscreen = INT32_MAX; windowbottom = windowtop = sprbotscreen = INT32_MAX;
ldef = curline->linedef; ldef = curline->linedef;
@ -699,7 +694,7 @@ void R_RenderMaskedSegRange(drawseg_t *drawseg, INT32 x1, INT32 x2)
} }
else else
{ {
R_RenderMaskedSegLoop(dc, drawseg, x1, x2, texnum, colfunc_2s); R_RenderMaskedSegLoop(dc, drawseg, x1, x2, texnum, basetexnum, colfunc_2s);
} }
R_SetColumnFunc(BASEDRAWFUNC, false); R_SetColumnFunc(BASEDRAWFUNC, false);
@ -747,7 +742,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
size_t pindex = 0; size_t pindex = 0;
column_t * col, *bmCol = NULL; column_t * col, *bmCol = NULL;
INT32 lightnum; INT32 lightnum;
INT32 texnum; INT32 texnum, basetexnum;
sector_t tempsec; sector_t tempsec;
INT32 templight; INT32 templight;
INT32 i, p; INT32 i, p;
@ -779,7 +774,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
curline = ds->curline; curline = ds->curline;
backsector = pfloor->target; backsector = pfloor->target;
frontsector = curline->frontsector == pfloor->target ? curline->backsector : curline->frontsector; frontsector = curline->frontsector == pfloor->target ? curline->backsector : curline->frontsector;
texnum = R_GetTextureNum(sides[pfloor->master->sidenum[0]].midtexture); basetexnum = sides[pfloor->master->sidenum[0]].midtexture;
R_CheckDebugHighlight(SW_HI_FOFSIDES); R_CheckDebugHighlight(SW_HI_FOFSIDES);
@ -787,11 +782,13 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
{ {
size_t linenum = curline->linedef-backsector->lines[0]; size_t linenum = curline->linedef-backsector->lines[0];
newline = pfloor->master->frontsector->lines[0] + linenum; newline = pfloor->master->frontsector->lines[0] + linenum;
texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); basetexnum = sides[newline->sidenum[0]].midtexture;
} }
texnum = R_GetTextureNum(basetexnum);
boolean brightmapped = R_TextureHasBrightmap(texnum); boolean brightmapped = R_TextureHasBrightmap(texnum);
boolean remap = encoremap && R_TextureCanRemap(texnum); boolean remap = encoremap && R_TextureCanRemap(basetexnum);
R_SetColumnFunc(BASEDRAWFUNC, brightmapped); R_SetColumnFunc(BASEDRAWFUNC, brightmapped);
@ -1764,7 +1761,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
vertex_t segleft, segright; vertex_t segleft, segright;
fixed_t ceilingfrontslide, floorfrontslide, ceilingbackslide, floorbackslide; fixed_t ceilingfrontslide, floorfrontslide, ceilingbackslide, floorbackslide;
static size_t maxdrawsegs = 0; static size_t maxdrawsegs = 0;
const INT32 twosidedmidtexture = R_GetTwoSidedMidTexture(curline); const INT32 twosidedmidtexture = R_GetTextureNum(R_GetTwoSidedMidTexture(curline));
const bool wantremap = encoremap && !(curline->linedef->flags & ML_TFERLINE); const bool wantremap = encoremap && !(curline->linedef->flags & ML_TFERLINE);
drawcolumndata_t dc {0}; drawcolumndata_t dc {0};
@ -2009,7 +2006,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
// single sided line // single sided line
midtexture = R_GetTextureNum(sidedef->midtexture); midtexture = R_GetTextureNum(sidedef->midtexture);
midbrightmapped = R_TextureHasBrightmap(midtexture); midbrightmapped = R_TextureHasBrightmap(midtexture);
midremap = wantremap && R_TextureCanRemap(midtexture); midremap = wantremap && R_TextureCanRemap(sidedef->midtexture);
texheight = textureheight[midtexture]; texheight = textureheight[midtexture];
// a single sided line is terminal, so it must mark ends // a single sided line is terminal, so it must mark ends
markfloor = markceiling = true; markfloor = markceiling = true;
@ -2202,7 +2199,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
// top texture // top texture
toptexture = R_GetTextureNum(sidedef->toptexture); toptexture = R_GetTextureNum(sidedef->toptexture);
topbrightmapped = R_TextureHasBrightmap(toptexture); topbrightmapped = R_TextureHasBrightmap(toptexture);
topremap = wantremap && R_TextureCanRemap(toptexture); topremap = wantremap && R_TextureCanRemap(sidedef->toptexture);
texheight = textureheight[toptexture]; texheight = textureheight[toptexture];
if (!(linedef->flags & ML_SKEWTD)) if (!(linedef->flags & ML_SKEWTD))
@ -2232,7 +2229,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
// bottom texture // bottom texture
bottomtexture = R_GetTextureNum(sidedef->bottomtexture); bottomtexture = R_GetTextureNum(sidedef->bottomtexture);
bottombrightmapped = R_TextureHasBrightmap(bottomtexture); bottombrightmapped = R_TextureHasBrightmap(bottomtexture);
bottomremap = wantremap && R_TextureCanRemap(bottomtexture); bottomremap = wantremap && R_TextureCanRemap(sidedef->bottomtexture);
if (!(linedef->flags & ML_SKEWTD)) if (!(linedef->flags & ML_SKEWTD))
{ {