Add BrightMap support to SPRTINFO

This commit is contained in:
James R 2022-12-03 03:34:54 -08:00 committed by NepDisk
parent b0f67f150e
commit e93de906e0
4 changed files with 48 additions and 12 deletions

View file

@ -1474,9 +1474,10 @@ static void R_ParseSpriteInfoFrame(struct ParseSpriteInfoState *parser, boolean
size_t sprinfoTokenLength;
char *frameChar = NULL;
UINT8 frameFrame = 0xFF;
INT16 frameXPivot = 0;
INT16 frameYPivot = 0;
INT16 frameXPivot = INT16_MIN;
INT16 frameYPivot = INT16_MIN;
rotaxis_t frameRotAxis = 0;
char *bright = NULL;
if (all)
{
@ -1541,6 +1542,11 @@ 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);
@ -1557,8 +1563,13 @@ 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;
set_bit_array(parser->info->available, frameFrame);
if (frameXPivot != INT16_MIN || frameYPivot != INT16_MIN)
{
set_bit_array(parser->info->available, frameFrame);
}
if (parser->spr2)
{

View file

@ -103,6 +103,7 @@ 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,12 +849,13 @@ UINT8 *R_GetSpriteTranslation(vissprite_t *vis)
//
static void R_DrawVisSprite(vissprite_t *vis)
{
column_t *column;
column_t *column, *bmcol = NULL;
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;
@ -1009,7 +1010,10 @@ static void R_DrawVisSprite(vissprite_t *vis)
column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn]));
localcolfunc (column, NULL, baseclip);
if (bmpatch)
bmcol = (column_t *)((UINT8 *)bmpatch->columns + (bmpatch->columnofs[texturecolumn]));
localcolfunc (column, bmcol, baseclip);
}
}
else if (vis->cut & SC_SHEAR)
@ -1025,13 +1029,14 @@ static void R_DrawVisSprite(vissprite_t *vis)
texturecolumn = frac>>FRACBITS;
if (texturecolumn < 0 || texturecolumn >= pwidth)
I_Error("R_DrawSpriteRange: bad texturecolumn at %d from end", vis->x2 - dc_x);
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]));
if (bmpatch)
bmcol = (column_t *)((UINT8 *)bmpatch->columns + (bmpatch->columnofs[texturecolumn]));
#endif
sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale));
localcolfunc (column, NULL, baseclip);
localcolfunc (column, bmcol, baseclip);
}
}
else
@ -1047,11 +1052,13 @@ static void R_DrawVisSprite(vissprite_t *vis)
texturecolumn = frac>>FRACBITS;
if (texturecolumn < 0 || texturecolumn >= pwidth)
I_Error("R_DrawSpriteRange: bad texturecolumn at %d from end", vis->x2 - dc_x);
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]));
if (bmpatch)
bmcol = (column_t *)((UINT8 *)bmpatch->columns + (bmpatch->columnofs[texturecolumn]));
#endif
localcolfunc (column, NULL, baseclip);
localcolfunc (column, bmcol, baseclip);
}
}
@ -1211,6 +1218,18 @@ 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];
}
return W_CachePatchNum(W_CheckNumForLongName(name), PU_SPRITE);
}
//
// R_GetShadowZ(thing, shadowslope)
// Get the first visible floor below the object for shadows
@ -1387,6 +1406,7 @@ static void R_ProjectDropShadow(
shadow = R_NewVisSprite();
shadow->patch = patch;
shadow->bright = NULL;
shadow->heightsec = vis->heightsec;
shadow->mobjflags = 0;
@ -2342,6 +2362,7 @@ 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);
@ -2531,6 +2552,8 @@ 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,6 +188,7 @@ 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