Revert Merge branch sprite-brightmaps into master

This reverts commit ce47997a10.
This commit is contained in:
NepDisk 2024-08-24 15:25:46 -04:00
parent 84ede3188e
commit f1d7d5f763
6 changed files with 33 additions and 123 deletions

View file

@ -268,20 +268,6 @@ static UINT8 GetPivotFrame(lua_State *L, int idx)
return frame;
}
static int PushCast(lua_State *L, const char *meta)
{
// bypass LUA_PushUserdata
void **userdata = lua_newuserdata(L, sizeof(void *));
*userdata = lua_touserdata(L, 1);
luaL_getmetatable(L, meta);
lua_setmetatable(L, -2);
// stack is left with the userdata on top, as if getting it had originally succeeded.
return 1;
}
// spriteinfo[]
static int lib_getSpriteInfo(lua_State *L)
{
@ -470,15 +456,23 @@ static int lib_spriteinfolen(lua_State *L)
// spriteinfo_t
static int spriteinfo_get(lua_State *L)
{
spriteinfo_t *sprinfo = *((spriteinfo_t **)luaL_checkudata(L, 1, META_SPRITEINFO));
const char *field = luaL_checkstring(L, 2);
luaL_checkudata(L, 1, META_SPRITEINFO);
I_Assert(sprinfo != NULL);
// push spriteframepivot_t userdata
if (fastcmp(field, "pivot"))
return PushCast(L, META_PIVOTLIST);
else if (fastcmp(field, "brightmap"))
return PushCast(L, META_SPRITEBRIGHTLIST);
{
// bypass LUA_PushUserdata
void **userdata = lua_newuserdata(L, sizeof(void *));
*userdata = sprinfo;
luaL_getmetatable(L, META_PIVOTLIST);
lua_setmetatable(L, -2);
// stack is left with the userdata on top, as if getting it had originally succeeded.
return 1;
}
else
return luaL_error(L, LUA_QL("spriteinfo_t") " has no field named " LUA_QS, field);
@ -648,29 +642,6 @@ static int framepivot_num(lua_State *L)
return 1;
}
static int brightlist_get(lua_State *L)
{
const spriteinfo_t *sprinfo = *((spriteinfo_t **)luaL_checkudata(L, 1, META_SPRITEBRIGHTLIST));
const UINT8 frame = GetPivotFrame(L, 2);
lua_pushstring(L, sprinfo->bright[frame]);
return 1;
}
static int brightlist_set(lua_State *L)
{
spriteinfo_t *sprinfo = *((spriteinfo_t **)luaL_checkudata(L, 1, META_SPRITEBRIGHTLIST));
const UINT8 frame = GetPivotFrame(L, 2);
const char *val = luaL_checkstring(L, 3);
Z_Free(sprinfo->bright[frame]);
sprinfo->bright[frame] = Z_StrDup(val);
return 0;
}
////////////////
// STATE INFO //
////////////////
@ -2125,17 +2096,6 @@ int LUA_InfoLib(lua_State *L)
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_SPRITEBRIGHTLIST);
lua_pushcfunction(L, brightlist_get);
lua_setfield(L, -2, "__index");
lua_pushcfunction(L, brightlist_set);
lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, pivotlist_num);
lua_setfield(L, -2, "__len");
lua_pop(L, 1);
luaL_newmetatable(L, META_PRECIPPROPS);
lua_pushcfunction(L, precipprops_get);
lua_setfield(L, -2, "__index");

View file

@ -28,7 +28,6 @@ extern lua_State *gL;
#define META_SPRITEINFO "SPRITEINFO_T*"
#define META_PIVOTLIST "SPRITEFRAMEPIVOT_T[]"
#define META_FRAMEPIVOT "SPRITEFRAMEPIVOT_T*"
#define META_SPRITEBRIGHTLIST "SPRITEBRIGHTMAP_T[]"
#define META_PRECIPPROPS "PRECIPPROPS_T*"
#define META_TAGLIST "TAGLIST"

View file

@ -1474,10 +1474,9 @@ static void R_ParseSpriteInfoFrame(struct ParseSpriteInfoState *parser, boolean
size_t sprinfoTokenLength;
char *frameChar = NULL;
UINT8 frameFrame = 0xFF;
INT16 frameXPivot = INT16_MIN;
INT16 frameYPivot = INT16_MIN;
INT16 frameXPivot = 0;
INT16 frameYPivot = 0;
rotaxis_t frameRotAxis = 0;
char *bright = NULL;
if (all)
{
@ -1542,11 +1541,6 @@ static void R_ParseSpriteInfoFrame(struct ParseSpriteInfoState *parser, boolean
else if ((stricmp(sprinfoToken, "Z")==0) || (stricmp(sprinfoToken, "ZAXIS")==0) || (stricmp(sprinfoToken, "YAW")==0))
frameRotAxis = ROTAXIS_Z;
}
else if (stricmp(sprinfoToken, "BRIGHTMAP")==0)
{
Z_Free(bright);
bright = M_GetToken(NULL);
}
Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL);
@ -1563,13 +1557,8 @@ static void R_ParseSpriteInfoFrame(struct ParseSpriteInfoState *parser, boolean
parser->info->pivot[frameFrame].x = frameXPivot;
parser->info->pivot[frameFrame].y = frameYPivot;
parser->info->pivot[frameFrame].rotaxis = frameRotAxis;
Z_Free(parser->info->bright[frameFrame]);
parser->info->bright[frameFrame] = bright;
if (frameXPivot != INT16_MIN || frameYPivot != INT16_MIN)
{
set_bit_array(parser->info->available, frameFrame);
}
set_bit_array(parser->info->available, frameFrame);
if (parser->spr2)
{

View file

@ -103,8 +103,6 @@ typedef struct
spriteframepivot_t pivot[64 + 1];
#define SPRINFO_DEFAULT_PIVOT (64)
UINT8 available[BIT_ARRAY_SIZE(64 + 1)]; // 1 extra for default_pivot
char *bright[64 + 1]; // brightmap lump name
} spriteinfo_t;
// Portable Network Graphics

View file

@ -849,13 +849,12 @@ UINT8 *R_GetSpriteTranslation(vissprite_t *vis)
//
static void R_DrawVisSprite(vissprite_t *vis)
{
column_t *column, *bmcol = NULL;
column_t *column;
void (*localcolfunc)(column_t *, column_t *, INT32);
INT32 texturecolumn;
INT32 pwidth;
fixed_t frac;
patch_t *patch = vis->patch;
patch_t *bmpatch = vis->bright;
fixed_t this_scale = vis->thingscale;
INT32 x1, x2;
INT64 overflow_test;
@ -876,13 +875,6 @@ static void R_DrawVisSprite(vissprite_t *vis)
if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) return; // ditto
}
// Prevent an out of bounds error
if (bmpatch && (bmpatch->width != patch->width ||
bmpatch->height != patch->height))
{
return;
}
R_SetColumnFunc(BASEDRAWFUNC, false); // hack: this isn't resetting properly somewhere.
dc_colormap = vis->colormap;
dc_fullbright = colormaps;
@ -1017,10 +1009,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn]));
if (bmpatch)
bmcol = (column_t *)((UINT8 *)bmpatch->columns + (bmpatch->columnofs[texturecolumn]));
localcolfunc (column, bmcol, baseclip);
localcolfunc (column, NULL, baseclip);
}
}
else if (vis->cut & SC_SHEAR)
@ -1032,18 +1021,17 @@ static void R_DrawVisSprite(vissprite_t *vis)
// Vertically sheared sprite
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale, dc_texturemid -= vis->shear.tan)
{
texturecolumn = frac>>FRACBITS;
#ifdef RANGECHECK
texturecolumn = frac>>FRACBITS;
if (texturecolumn < 0 || texturecolumn >= pwidth)
I_Error("R_DrawSpriteRange: bad texturecolumn at %d from end", vis->x2 - dc_x);
#endif
column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn]));
if (bmpatch)
bmcol = (column_t *)((UINT8 *)bmpatch->columns + (bmpatch->columnofs[texturecolumn]));
#else
column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[frac>>FRACBITS]));
#endif
sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale));
localcolfunc (column, bmcol, baseclip);
localcolfunc (column, NULL, baseclip);
}
}
else
@ -1055,18 +1043,15 @@ static void R_DrawVisSprite(vissprite_t *vis)
// Non-paper drawing loop
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale, sprtopscreen += vis->shear.tan)
{
texturecolumn = frac>>FRACBITS;
#ifdef RANGECHECK
texturecolumn = frac>>FRACBITS;
if (texturecolumn < 0 || texturecolumn >= pwidth)
I_Error("R_DrawSpriteRange: bad texturecolumn at %d from end", vis->x2 - dc_x);
#endif
column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn]));
if (bmpatch)
bmcol = (column_t *)((UINT8 *)bmpatch->columns + (bmpatch->columnofs[texturecolumn]));
localcolfunc (column, bmcol, baseclip);
#else
column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[frac>>FRACBITS]));
#endif
localcolfunc (column, NULL, baseclip);
}
}
@ -1081,7 +1066,9 @@ static void R_DrawVisSprite(vissprite_t *vis)
static void R_DrawPrecipitationVisSprite(vissprite_t *vis)
{
column_t *column;
#ifdef RANGECHECK
INT32 texturecolumn;
#endif
fixed_t frac;
patch_t *patch;
fixed_t this_scale = vis->thingscale;
@ -1128,15 +1115,16 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis)
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale)
{
#ifdef RANGECHECK
texturecolumn = frac>>FRACBITS;
#ifdef RANGECHECK
if (texturecolumn < 0 || texturecolumn >= patch->width)
I_Error("R_DrawPrecipitationSpriteRange: bad texturecolumn");
#endif
column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn]));
#else
column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[frac>>FRACBITS]));
#endif
R_DrawMaskedColumn(column, NULL, -1);
}
@ -1223,25 +1211,6 @@ static void R_SplitSprite(vissprite_t *sprite)
}
}
static patch_t *R_CacheSpriteBrightMap(const spriteinfo_t *sprinfo, UINT8 frame)
{
const char *name = sprinfo->bright[frame];
if (name == NULL)
{
name = sprinfo->bright[SPRINFO_DEFAULT_PIVOT];
}
const lumpnum_t num = W_CheckNumForLongName(name);
if (num == LUMPERROR)
{
return NULL;
}
return W_CachePatchNum(num, PU_SPRITE);
}
//
// R_GetShadowZ(thing, shadowslope)
// Get the first visible floor below the object for shadows
@ -1418,7 +1387,6 @@ static void R_ProjectDropShadow(
shadow = R_NewVisSprite();
shadow->patch = patch;
shadow->bright = NULL;
shadow->heightsec = vis->heightsec;
shadow->mobjflags = 0;
@ -2323,7 +2291,6 @@ static void R_ProjectSprite(mobj_t *thing)
vis->cut |= SC_SPLAT; // I like ya cut g
vis->patch = patch;
vis->bright = R_CacheSpriteBrightMap(sprinfo, frame);
if (thing->subsector->sector->numlights && !(shadowdraw || splat))
R_SplitSprite(vis);
@ -2513,8 +2480,6 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
//Fab: lumppat is the lump number of the patch to use, this is different
// than lumpid for sprites-in-pwad : the graphics are patched
vis->patch = W_CachePatchNum(sprframe->lumppat[0], PU_SPRITE);
vis->bright = R_CacheSpriteBrightMap(&spriteinfo[thing->sprite],
thing->frame & FF_FRAMEMASK);
vis->transmap = R_GetBlendTable(blendmode, trans);

View file

@ -188,7 +188,6 @@ typedef struct vissprite_s
fixed_t texturemid;
patch_t *patch;
patch_t *bright;
lighttable_t *colormap; // for color translation and shadow draw
// maxbright frames as well