Merge branch 'no-remap-terrain' into 'master'

TERRAIN 'remap' property, for ENCOREMAP/TWEAKMAP

Closes #756

See merge request KartKrew/Kart!1698
This commit is contained in:
James R. 2023-12-23 06:10:26 +00:00
commit c8827c18a2
9 changed files with 127 additions and 86 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
// 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;
texture_t *texture;
@ -477,7 +477,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex)
grtex->mipmap.height = (UINT16)texture->height;
grtex->mipmap.format = textureformat;
if (encoremap)
if (encoremap && R_TextureCanRemap(basetexnum))
colormap += COLORMAP_REMAPOFFSET;
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
// --------------------------------------------------------------------------
GLMapTexture_t *HWR_GetTexture(INT32 tex)
GLMapTexture_t *HWR_GetTexture(INT32 tex, INT32 basetex)
{
GLMapTexture_t *grtex;
#ifdef PARANOIA
@ -797,7 +797,7 @@ GLMapTexture_t *HWR_GetTexture(INT32 tex)
// Generate texture if missing from the cache
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 (!grtex->mipmap.downloaded)

View file

@ -126,7 +126,7 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap);
void HWR_GetFadeMask(lumpnum_t fademasklumpnum);
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_GetRawFlat(lumpnum_t flatlumpnum, boolean noencoremap);

View file

@ -723,7 +723,7 @@ FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf)
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
@ -762,7 +762,7 @@ static void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIEL
//
// 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
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;
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)
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
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;
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)
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
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)
{
INT32 gl_toptexture = 0, gl_bottomtexture = 0;
INT32 gl_basetoptexture = 0, gl_basebottomtexture = 0;
// two sided line
boolean bothceilingssky = false; // turned on if both back and front ceilings are sky
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)
gl_toptexture = R_GetTextureNum(gl_sidedef->toptexture);
{
gl_basetoptexture = gl_sidedef->toptexture;
gl_toptexture = R_GetTextureNum(gl_basetoptexture);
}
if (!bothfloorssky)
gl_bottomtexture = R_GetTextureNum(gl_sidedef->bottomtexture);
{
gl_basebottomtexture = gl_sidedef->bottomtexture;
gl_bottomtexture = R_GetTextureNum(gl_basebottomtexture);
}
// check TOP TEXTURE
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
grTex = HWR_GetTexture(gl_toptexture);
grTex = HWR_GetTexture(gl_toptexture, gl_basetoptexture);
// PEGGING
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;
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)
HWR_AddTransparentWall(wallVerts, &Surf, gl_toptexture, polyflags, false, lightnum, colormap);
HWR_AddTransparentWall(wallVerts, &Surf, gl_toptexture, gl_basetoptexture, polyflags, false, lightnum, colormap);
else
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
grTex = HWR_GetTexture(gl_bottomtexture);
grTex = HWR_GetTexture(gl_bottomtexture, gl_basebottomtexture);
// PEGGING
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;
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)
HWR_AddTransparentWall(wallVerts, &Surf, gl_bottomtexture, polyflags, false, lightnum, colormap);
HWR_AddTransparentWall(wallVerts, &Surf, gl_bottomtexture, gl_basebottomtexture, polyflags, false, lightnum, colormap);
else
HWR_ProjectWall(wallVerts, &Surf, polyflags, lightnum, colormap);
}
@ -1318,7 +1325,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
else
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[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 (!(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
{
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))
HWR_AddTransparentWall(wallVerts, &Surf, gl_midtexture, blendmode, false, lightnum, colormap);
HWR_AddTransparentWall(wallVerts, &Surf, gl_midtexture, gl_sidedef->midtexture, blendmode, false, lightnum, colormap);
else
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
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[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...
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
{
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...
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
{
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
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
fixed_t high1, highslope1, low1, lowslope1;
INT32 texnum;
INT32 texnum, basetexnum;
line_t * newline = NULL; // Multi-Property FOF
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))
continue;
texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture);
basetexnum = sides[rover->master->sidenum[0]].midtexture;
if (rover->master->flags & ML_TFERLINE)
{
size_t linenum = gl_curline->linedef-gl_backsector->lines[0];
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);
hS = P_GetFFloorTopZAt (rover, v2x, v2y);
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);
}
grTex = HWR_GetTexture(texnum);
grTex = HWR_GetTexture(texnum, basetexnum);
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);
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
HWR_AddTransparentWall(wallVerts, &Surf, 0, blendmode, true, lightnum, colormap);
HWR_AddTransparentWall(wallVerts, &Surf, 0, 0, blendmode, true, lightnum, colormap);
}
else
{
@ -1699,11 +1708,11 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
}
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
{
if (blendmode != PF_Masked)
HWR_AddTransparentWall(wallVerts, &Surf, texnum, blendmode, false, lightnum, colormap);
HWR_AddTransparentWall(wallVerts, &Surf, texnum, basetexnum, blendmode, false, lightnum, colormap);
else
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))
continue;
texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture);
basetexnum = sides[rover->master->sidenum[0]].midtexture;
if (rover->master->flags & ML_TFERLINE)
{
size_t linenum = gl_curline->linedef-gl_backsector->lines[0];
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);
hS = P_GetFFloorTopZAt (rover, v2x, v2y);
l = P_GetFFloorBottomZAt(rover, v1x, v1y);
@ -1778,7 +1790,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
}
else
{
grTex = HWR_GetTexture(texnum);
grTex = HWR_GetTexture(texnum, basetexnum);
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);
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
HWR_AddTransparentWall(wallVerts, &Surf, 0, blendmode, true, lightnum, colormap);
HWR_AddTransparentWall(wallVerts, &Surf, 0, 0, blendmode, true, lightnum, colormap);
}
else
{
@ -1825,11 +1837,11 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
}
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
{
if (blendmode != PF_Masked)
HWR_AddTransparentWall(wallVerts, &Surf, texnum, blendmode, false, lightnum, colormap);
HWR_AddTransparentWall(wallVerts, &Surf, texnum, basetexnum, blendmode, false, lightnum, colormap);
else
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap);
}
@ -4094,7 +4106,7 @@ typedef struct
{
FOutVector wallVerts[4];
FSurfaceInfo Surf;
INT32 texnum;
INT32 texnum, basetexnum;
FBITFIELD blend;
INT32 drawcount;
boolean fogwall;
@ -4368,7 +4380,7 @@ static void HWR_CreateDrawNodes(void)
else if (sortnode[sortindex[i]].wall)
{
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,
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);
dometransform.splitscreen = r_splitscreen;
HWR_GetTexture(texturetranslation[skytexture]);
HWR_GetTexture(texturetranslation[skytexture], skytexture);
if (gl_sky.texture != texturetranslation[skytexture])
{
@ -5441,7 +5453,7 @@ static void HWR_DrawSkyBackground(player_t *player)
float aspectratio;
float angleturn;
HWR_GetTexture(texturetranslation[skytexture]);
HWR_GetTexture(texturetranslation[skytexture], skytexture);
aspectratio = (float)vid.width/(float)vid.height;
//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;
}
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;
@ -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].Surf, pSurf, sizeof (FSurfaceInfo));
wallinfo[numwalls].texnum = texnum;
wallinfo[numwalls].basetexnum = basetexnum;
wallinfo[numwalls].blend = blend;
wallinfo[numwalls].drawcount = drawcount++;
wallinfo[numwalls].fogwall = fogwall;

View file

@ -348,7 +348,7 @@ terrain_t *K_GetTerrainForTextureName(const char *checkName)
{
t_floor_t *f = &terrainFloorDefs[i];
if (checkHash == f->textureHash && !strncmp(checkName, f->textureName, 8))
if (checkHash == f->textureHash && !strncasecmp(checkName, f->textureName, 8))
{
return K_GetTerrainByIndex(f->terrainID);
}
@ -370,7 +370,7 @@ terrain_t *K_GetTerrainForTextureNum(INT32 textureNum)
if (textureNum >= 0 && textureNum < numtextures)
{
texture_t *tex = textures[textureNum];
return K_GetTerrainForTextureName(tex->name);
return tex->terrain;
}
// This texture doesn't have a terrain directly applied to it,
@ -1568,7 +1568,7 @@ static void K_TerrainDefaults(terrain_t *terrain)
terrain->speedPadAngle = 0;
terrain->springStrength = 0;
terrain->springStarColor = SKINCOLOR_NONE;
terrain->flags = 0;
terrain->flags = TRF_REMAP;
}
/*--------------------------------------------------
@ -1715,6 +1715,10 @@ static void K_ParseTerrainParameter(size_t i, char *param, char *val)
{
K_FlagBoolean(&terrain->flags, TRF_TRIPWIRE, val);
}
else if (stricmp(param, "remap") == 0)
{
K_FlagBoolean(&terrain->flags, TRF_REMAP, val);
}
}
/*--------------------------------------------------
@ -2036,6 +2040,12 @@ static boolean K_TERRAINLumpParser(char *data, size_t size)
{
f->terrainID = K_GetTerrainHeapIndex(t);
CONS_Printf("Texture '%s' set to Terrain '%s'\n", f->textureName, tkn);
INT32 tex = R_CheckTextureNumForName(f->textureName);
if (tex != -1)
{
textures[tex]->terrain = t;
}
}
}
else
@ -2211,4 +2221,6 @@ void K_InitTerrain(UINT16 wadNum)
free(name);
}
}
R_ClearTextureNumCache(false);
}

View file

@ -99,7 +99,8 @@ typedef enum
TRF_LIQUID = 1, // Texture has water properties (wavy, slippery, etc)
TRF_SNEAKERPANEL = 1<<1, // Texture is a booster
TRF_STAIRJANK = 1<<2, // Texture is bumpy road
TRF_TRIPWIRE = 1<<3 // Texture is a tripwire when used as a midtexture
TRF_TRIPWIRE = 1<<3, // Texture is a tripwire when used as a midtexture
TRF_REMAP = 1<<4, // Texture colors may be remapped with ENCOREMAP or TWEAKMAP
} terrain_flags_t;
struct terrain_t

View file

@ -58,10 +58,7 @@ boolean R_NoEncore(sector_t *sector, levelflat_t *flat, boolean ceiling)
const boolean invertEncore = (sector->flags & MSF_INVERTENCORE);
const terrain_t *terrain = (flat != NULL ? flat->terrain : NULL);
if ((terrain == NULL)
|| (terrain->trickPanel <= 0
&& terrain->speedPad <= 0
&& !(terrain->flags & TRF_SNEAKERPANEL)))
if ((terrain == NULL) || (terrain->flags & TRF_REMAP))
{
return invertEncore;
}

View file

@ -32,6 +32,7 @@
#include "r_draw.h"
#include "core/memory.h"
#include "core/thread_pool.h"
#include "k_terrain.h"
extern "C" consvar_t cv_debugfinishline;
@ -48,6 +49,7 @@ static boolean markceiling;
static boolean maskedtexture;
static INT32 toptexture, bottomtexture, midtexture;
static bool topbrightmapped, bottombrightmapped, midbrightmapped;
static bool topremap, bottomremap, midremap;
static INT32 numthicksides, numbackffloors;
angle_t rw_normalangle;
@ -173,7 +175,7 @@ static inline boolean R_OverflowTest(drawcolumndata_t* dc)
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;
column_t *col, *bmCol = NULL;
@ -187,6 +189,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
INT32 times, repeats;
boolean tripwire;
boolean brightmapped = R_TextureHasBrightmap(texnum);
boolean remap = encoremap && R_TextureCanRemap(basetexnum);
ldef = curline->linedef;
tripwire = P_IsLineTripWire(ldef);
@ -408,7 +411,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
dc->colormap = rlight->rcolormap;
dc->lightmap = xwalllights[pindex];
dc->fullbright = colormaps;
if (encoremap && !(ldef->flags & ML_TFERLINE))
if (remap && !(ldef->flags & ML_TFERLINE))
{
dc->colormap += COLORMAP_REMAPOFFSET;
dc->fullbright += COLORMAP_REMAPOFFSET;
@ -434,7 +437,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
dc->colormap = rlight->rcolormap;
dc->lightmap = xwalllights[pindex];
dc->fullbright = colormaps;
if (encoremap && !(ldef->flags & ML_TFERLINE))
if (remap && !(ldef->flags & ML_TFERLINE))
{
dc->colormap += COLORMAP_REMAPOFFSET;
dc->fullbright += COLORMAP_REMAPOFFSET;
@ -457,7 +460,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
dc->colormap = walllights[pindex];
dc->lightmap = walllights[pindex];
dc->fullbright = colormaps;
if (encoremap && !(ldef->flags & ML_TFERLINE))
if (remap && !(ldef->flags & ML_TFERLINE))
{
dc->colormap += COLORMAP_REMAPOFFSET;
dc->fullbright += COLORMAP_REMAPOFFSET;
@ -569,18 +572,12 @@ static void R_RenderMaskedSegLoopDebug(drawcolumndata_t* dc, drawseg_t *ds, INT3
static INT32 R_GetTwoSidedMidTexture(seg_t *line)
{
INT32 texture;
if (R_IsDebugLine(line))
{
texture = g_texturenum_dbgline;
}
else
{
texture = line->sidedef->midtexture;
return g_texturenum_dbgline;
}
return R_GetTextureNum(texture);
return line->sidedef->midtexture;
}
static boolean R_CheckBlendMode(drawcolumndata_t* dc, const line_t *ldef, boolean brightmapped)
@ -632,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)
{
INT32 texnum;
INT32 texnum, basetexnum;
void (*colfunc_2s)(drawcolumndata_t*, column_t *, column_t *, INT32);
line_t *ldef;
const boolean debug = R_IsDebugLine(drawseg->curline);
@ -646,7 +643,8 @@ void R_RenderMaskedSegRange(drawseg_t *drawseg, INT32 x1, INT32 x2)
frontsector = curline->frontsector;
backsector = curline->backsector;
texnum = R_GetTwoSidedMidTexture(curline);
basetexnum = R_GetTwoSidedMidTexture(curline);
texnum = R_GetTextureNum(basetexnum);
windowbottom = windowtop = sprbotscreen = INT32_MAX;
ldef = curline->linedef;
@ -696,7 +694,7 @@ void R_RenderMaskedSegRange(drawseg_t *drawseg, INT32 x1, INT32 x2)
}
else
{
R_RenderMaskedSegLoop(dc, drawseg, x1, x2, texnum, colfunc_2s);
R_RenderMaskedSegLoop(dc, drawseg, x1, x2, texnum, basetexnum, colfunc_2s);
}
R_SetColumnFunc(BASEDRAWFUNC, false);
@ -744,7 +742,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
size_t pindex = 0;
column_t * col, *bmCol = NULL;
INT32 lightnum;
INT32 texnum;
INT32 texnum, basetexnum;
sector_t tempsec;
INT32 templight;
INT32 i, p;
@ -776,7 +774,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
curline = ds->curline;
backsector = pfloor->target;
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);
@ -784,10 +782,13 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
{
size_t linenum = curline->linedef-backsector->lines[0];
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 remap = encoremap && R_TextureCanRemap(basetexnum);
R_SetColumnFunc(BASEDRAWFUNC, brightmapped);
@ -1182,7 +1183,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
dc->colormap = rlight->rcolormap;
dc->lightmap = xwalllights[pindex];
dc->fullbright = colormaps;
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
if (remap && !(curline->linedef->flags & ML_TFERLINE))
{
dc->colormap += COLORMAP_REMAPOFFSET;
dc->fullbright += COLORMAP_REMAPOFFSET;
@ -1219,7 +1220,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
dc->colormap = rlight->rcolormap;
dc->lightmap = xwalllights[pindex];
dc->fullbright = colormaps;
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
if (remap && !(curline->linedef->flags & ML_TFERLINE))
{
dc->colormap += COLORMAP_REMAPOFFSET;
dc->fullbright += COLORMAP_REMAPOFFSET;
@ -1245,7 +1246,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
dc->lightmap = walllights[pindex];
dc->fullbright = colormaps;
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
if (remap && !(curline->linedef->flags & ML_TFERLINE))
{
dc->colormap += COLORMAP_REMAPOFFSET;
dc->fullbright += COLORMAP_REMAPOFFSET;
@ -1309,7 +1310,7 @@ UINT32 nombre = 100000;
#endif
//profile stuff ---------------------------------------------------------
static void R_DrawWallColumn(drawcolumndata_t* dc, INT32 yl, INT32 yh, fixed_t mid, fixed_t texturecolumn, INT32 texture, boolean brightmapped)
static void R_DrawWallColumn(drawcolumndata_t* dc, INT32 yl, INT32 yh, fixed_t mid, fixed_t texturecolumn, INT32 texture, boolean brightmapped, boolean remap)
{
dc->yl = yl;
dc->yh = yh;
@ -1320,6 +1321,11 @@ static void R_DrawWallColumn(drawcolumndata_t* dc, INT32 yl, INT32 yh, fixed_t m
R_SetColumnFunc(colfunctype, dc->brightmap != NULL);
coldrawfunc_t* colfunccopy = colfunc;
drawcolumndata_t dc_copy = *dc;
if (remap)
{
dc_copy.colormap += COLORMAP_REMAPOFFSET;
dc_copy.fullbright += COLORMAP_REMAPOFFSET;
}
colfunccopy(const_cast<drawcolumndata_t*>(&dc_copy));
}
@ -1524,11 +1530,6 @@ static void R_RenderSegLoop (drawcolumndata_t* dc)
dc->colormap = walllights[pindex];
dc->lightmap = walllights[pindex];
dc->fullbright = colormaps;
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
{
dc->colormap += COLORMAP_REMAPOFFSET;
dc->fullbright += COLORMAP_REMAPOFFSET;
}
dc->x = rw_x;
dc->iscale = 0xffffffffu / (unsigned)rw_scale;
@ -1595,7 +1596,7 @@ static void R_RenderSegLoop (drawcolumndata_t* dc)
// single sided line
if (yl <= yh && yh >= 0 && yl < viewheight)
{
R_DrawWallColumn(dc, yl, yh, rw_midtexturemid, texturecolumn, midtexture, midbrightmapped);
R_DrawWallColumn(dc, yl, yh, rw_midtexturemid, texturecolumn, midtexture, midbrightmapped, midremap);
// dont draw anything more for this column, since
// a midtexture blocks the view
@ -1634,7 +1635,7 @@ static void R_RenderSegLoop (drawcolumndata_t* dc)
}
else if (mid >= 0) // safe to draw top texture
{
R_DrawWallColumn(dc, yl, mid, rw_toptexturemid, texturecolumn, toptexture, topbrightmapped);
R_DrawWallColumn(dc, yl, mid, rw_toptexturemid, texturecolumn, toptexture, topbrightmapped, topremap);
ceilingclip[rw_x] = (INT16)mid;
}
else if (!rw_ceilingmarked) // entirely off top of screen
@ -1665,7 +1666,7 @@ static void R_RenderSegLoop (drawcolumndata_t* dc)
}
else if (mid < viewheight) // safe to draw bottom texture
{
R_DrawWallColumn(dc, mid, yh, rw_bottomtexturemid, texturecolumn, bottomtexture, bottombrightmapped);
R_DrawWallColumn(dc, mid, yh, rw_bottomtexturemid, texturecolumn, bottomtexture, bottombrightmapped, bottomremap);
floorclip[rw_x] = (INT16)mid;
}
else if (!rw_floormarked) // entirely off bottom of screen
@ -1760,7 +1761,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
vertex_t segleft, segright;
fixed_t ceilingfrontslide, floorfrontslide, ceilingbackslide, floorbackslide;
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);
drawcolumndata_t dc {0};
ZoneScoped;
@ -1955,6 +1957,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
midtexture = toptexture = bottomtexture = maskedtexture = 0;
midbrightmapped = topbrightmapped = bottombrightmapped = false;
midremap = topremap = bottomremap = false;
ds_p->maskedtexturecol = NULL;
ds_p->numthicksides = numthicksides = 0;
ds_p->thicksidecol = NULL;
@ -2003,6 +2006,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
// single sided line
midtexture = R_GetTextureNum(sidedef->midtexture);
midbrightmapped = R_TextureHasBrightmap(midtexture);
midremap = wantremap && R_TextureCanRemap(sidedef->midtexture);
texheight = textureheight[midtexture];
// a single sided line is terminal, so it must mark ends
markfloor = markceiling = true;
@ -2195,6 +2199,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
// top texture
toptexture = R_GetTextureNum(sidedef->toptexture);
topbrightmapped = R_TextureHasBrightmap(toptexture);
topremap = wantremap && R_TextureCanRemap(sidedef->toptexture);
texheight = textureheight[toptexture];
if (!(linedef->flags & ML_SKEWTD))
@ -2224,6 +2229,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
// bottom texture
bottomtexture = R_GetTextureNum(sidedef->bottomtexture);
bottombrightmapped = R_TextureHasBrightmap(bottomtexture);
bottomremap = wantremap && R_TextureCanRemap(sidedef->bottomtexture);
if (!(linedef->flags & ML_SKEWTD))
{

View file

@ -27,6 +27,7 @@
#include "p_setup.h" // levelflats
#include "byteptr.h"
#include "dehacked.h"
#include "k_terrain.h"
#ifdef HWRENDER
#include "hardware/hw_glob.h" // HWR_LoadMapTextures
@ -840,6 +841,12 @@ boolean R_TextureHasBrightmap(INT32 texnum)
return R_GetTextureBrightmap(texnum) != 0;
}
boolean R_TextureCanRemap(INT32 texnum)
{
const terrain_t *t = K_GetTerrainForTextureNum(texnum);
return !t || t->flags & TRF_REMAP;
}
//
// R_CheckTextureCache
//
@ -1191,6 +1198,7 @@ Rloadflats (INT32 i, INT32 w)
texture->patchcount = 1;
texture->holes = false;
texture->flip = 0;
texture->terrain = K_GetTerrainForTextureName(texture->name);
// Allocate information for the texture's patches.
patch = &texture->patches[0];
@ -1293,6 +1301,7 @@ Rloadtextures (INT32 i, INT32 w)
texture->patchcount = 1;
texture->holes = false;
texture->flip = 0;
texture->terrain = K_GetTerrainForTextureName(texture->name);
// Allocate information for the texture's patches.
patch = &texture->patches[0];
@ -1830,6 +1839,7 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
resultTexture->width = newTextureWidth;
resultTexture->height = newTextureHeight;
resultTexture->type = TEXTURETYPE_COMPOSITE;
resultTexture->terrain = K_GetTerrainForTextureName(newTextureName);
}
Z_Free(texturesToken);
texturesToken = M_GetToken(NULL);

View file

@ -66,6 +66,7 @@ struct texture_t
boolean holes;
UINT8 flip; // 1 = flipx, 2 = flipy, 3 = both
void *flat; // The texture, as a flat.
terrain_t *terrain;
// All the patches[patchcount] are drawn back to front into the cached texture.
INT16 patchcount;
@ -94,6 +95,7 @@ UINT8 *R_GenerateTextureBrightmap(size_t texnum);
INT32 R_GetTextureNum(INT32 texnum);
INT32 R_GetTextureBrightmap(INT32 texnum);
boolean R_TextureHasBrightmap(INT32 texnum);
boolean R_TextureCanRemap(INT32 texnum);
void R_CheckTextureCache(INT32 tex);
void R_ClearTextureNumCache(boolean btell);