- support for indexed hightiles.

This commit is contained in:
Christoph Oelckers 2021-07-13 09:48:14 +02:00 committed by Mitchell Richters
parent d0e6a7ea29
commit 3e76f71f02
3 changed files with 28 additions and 18 deletions

View file

@ -45,8 +45,8 @@
#include "mapinfo.h"
#include "hw_voxels.h"
int tileSetHightileReplacement(int picnum, int palnum, const char* filename, float alphacut, float xscale, float yscale, float specpower, float specfactor);
int tileSetSkybox(int picnum, int palnum, FString* facenames);
int tileSetHightileReplacement(int picnum, int palnum, const char* filename, float alphacut, float xscale, float yscale, float specpower, float specfactor, bool indexed = false);
int tileSetSkybox(int picnum, int palnum, FString* facenames, bool indexed = false);
void tileRemoveReplacement(int num);
void AddUserMapHack(usermaphack_t&);
@ -136,6 +136,7 @@ static void parseTexturePaletteBlock(FScanner& sc, int tile)
int pal = -1, xsiz = 0, ysiz = 0;
FString fn;
float alphacut = -1.0, xscale = 1.0, yscale = 1.0, specpower = 1.0, specfactor = 1.0;
bool indexed = false;
if (!sc.GetNumber(pal, true)) return;
@ -151,6 +152,7 @@ static void parseTexturePaletteBlock(FScanner& sc, int tile)
else if (sc.Compare({ "specfactor", "specularfactor", "parallaxbias" })) sc.GetFloat(specfactor, true);
else if (sc.Compare("orig_sizex")) sc.GetNumber(xsiz, true);
else if (sc.Compare("orig_sizey")) sc.GetNumber(ysiz, true);
else if (sc.Compare("indexed")) indexed = true;
};
if ((unsigned)tile < MAXUSERTILES)
@ -167,7 +169,7 @@ static void parseTexturePaletteBlock(FScanner& sc, int tile)
xscale = 1.0f / xscale;
yscale = 1.0f / yscale;
tileSetHightileReplacement(tile, pal, fn, alphacut, xscale, yscale, specpower, specfactor);
tileSetHightileReplacement(tile, pal, fn, alphacut, xscale, yscale, specpower, specfactor, indexed);
}
}
}
@ -485,6 +487,7 @@ void parseSkybox(FScanner& sc, FScriptPosition& pos)
FString faces[6];
FScanner::SavedPos blockend;
int tile = -1, pal = 0;
bool indexed = false;
if (sc.StartBraces(&blockend)) return;
while (!sc.FoundEndBrace(blockend))
@ -498,10 +501,11 @@ void parseSkybox(FScanner& sc, FScriptPosition& pos)
else if (sc.Compare({ "lt", "lf", "left" })) sc.GetString(faces[3]);
else if (sc.Compare({ "up", "ceiling", "top", "ceil" })) sc.GetString(faces[4]);
else if (sc.Compare({ "dn", "floor", "bottom", "down" })) sc.GetString(faces[5]);
else if (sc.Compare("indexed")) indexed = true;
// skip over everything else.
}
if (tile < 0) pos.Message(MSG_ERROR, "skybox: missing tile number");
else tileSetSkybox(tile, pal, faces);
else tileSetSkybox(tile, pal, faces, indexed);
}
//===========================================================================

View file

@ -60,7 +60,7 @@ enum
BuildTiles TileFiles;
int tileSetHightileReplacement(int picnum, int palnum, const char* filename, float alphacut, float xscale, float yscale, float specpower, float specfactor);
int tileSetHightileReplacement(int picnum, int palnum, const char* filename, float alphacut, float xscale, float yscale, float specpower, float specfactor, bool indexed = false);
//==========================================================================
//

View file

@ -59,6 +59,7 @@ struct HightileReplacement
float alphacut, specpower, specfactor;
uint16_t palnum;
bool issky;
bool indexed;
};
static TMap<int, TArray<HightileReplacement>> tileReplacements;
@ -242,7 +243,7 @@ void highTileSetup()
//
//==========================================================================
int tileSetHightileReplacement(int picnum, int palnum, const char* filename, float alphacut, float xscale, float yscale, float specpower, float specfactor)
int tileSetHightileReplacement(int picnum, int palnum, const char* filename, float alphacut, float xscale, float yscale, float specpower, float specfactor, bool indexed)
{
if ((uint32_t)picnum >= (uint32_t)MAXTILES) return -1;
if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return -1;
@ -268,6 +269,7 @@ int tileSetHightileReplacement(int picnum, int palnum, const char* filename, flo
replace.specpower = specpower; // currently unused
replace.specfactor = specfactor; // currently unused
replace.issky = 0;
replace.indexed = indexed;
replace.palnum = (uint16_t)palnum;
AddReplacement(picnum, replace);
return 0;
@ -280,7 +282,7 @@ int tileSetHightileReplacement(int picnum, int palnum, const char* filename, flo
//
//==========================================================================
int tileSetSkybox(int picnum, int palnum, FString* facenames)
int tileSetSkybox(int picnum, int palnum, FString* facenames, bool indexed)
{
if ((uint32_t)picnum >= (uint32_t)MAXTILES) return -1;
if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return -1;
@ -311,6 +313,7 @@ int tileSetSkybox(int picnum, int palnum, FString* facenames)
replace.image = MakeGameTexture(sbtex, "", ETextureType::Override);
TexMan.AddGameTexture(replace.image, false);
replace.issky = 1;
replace.indexed = indexed;
replace.palnum = (uint16_t)palnum;
AddReplacement(picnum, replace);
return 0;
@ -349,6 +352,12 @@ bool PickTexture(FGameTexture* tex, int paletteid, TexturePick& pick, bool wanti
int hipalswap = usepalette >= 0 ? useremap : 0;
auto rep = (hw_hightile && !(h.tintFlags & TINTF_ALWAYSUSEART)) ? FindReplacement(tex->GetID(), hipalswap, false) : nullptr;
if (rep || tex->GetTexture()->isHardwareCanvas())
{
if (rep)
{
tex = rep->image;
}
if (!rep || !rep->indexed)
{
if (usepalette > 0)
{
@ -358,14 +367,11 @@ bool PickTexture(FGameTexture* tex, int paletteid, TexturePick& pick, bool wanti
pick.basepalTint = hh.tintColor;
}
if (rep)
{
tex = rep->image;
}
if (!rep || rep->palnum != hipalswap || (h.tintFlags & TINTF_APPLYOVERALTPAL))
applytint = true;
if (!IsLuminosityTranslation(paletteid)) pick.translation = 0;
}
}
else
{
// Only look up the palette if we really want to use it (i.e. when creating a true color texture of an ART tile.)