Make alpha use fixed_t and add alpha field to precipmobj_t

This commit is contained in:
MIDIMan 2024-03-01 16:29:39 -05:00
parent d18a4cca1e
commit a76544a376
4 changed files with 11 additions and 10 deletions

View file

@ -357,7 +357,7 @@ static int mobj_get(lua_State *L)
lua_pushinteger(L, mo->blendmode);
break;
case mobj_alpha:
lua_pushinteger(L, mo->alpha);
lua_pushfixed(L, mo->alpha);
break;
case mobj_bnext:
if (mo->blocknode && mo->blocknode->bnext) {
@ -740,7 +740,7 @@ static int mobj_set(lua_State *L)
}
case mobj_alpha:
{
INT32 alpha = (INT32)luaL_checkinteger(L, 3);
fixed_t alpha = luaL_checkfixed(L, 3);
if (alpha < 0)
alpha = 0;
else if (alpha > FRACUNIT)

View file

@ -313,7 +313,7 @@ typedef struct mobj_s
UINT32 renderflags; // render flags
INT32 blendmode; // blend mode
UINT32 alpha; // alpha
fixed_t alpha; // alpha
fixed_t spritexscale, spriteyscale;
fixed_t spritexoffset, spriteyoffset;
fixed_t old_spritexscale, old_spriteyscale;
@ -457,6 +457,7 @@ typedef struct precipmobj_s
UINT32 renderflags; // render flags
INT32 blendmode; // blend mode
fixed_t alpha; // alpha
fixed_t spritexscale, spriteyscale;
fixed_t spritexoffset, spriteyoffset;
fixed_t old_spritexscale, old_spriteyscale;

View file

@ -1745,7 +1745,7 @@ typedef enum
MD2_DRAWONLYFORPLAYER = 1<<24,
MD2_DONTDRAWFORVIEWMOBJ = 1<<25,
MD2_TRANSLATION = 1<<26,
MD2_ALPHA = 1<<27
MD2_ALPHA = 1<<27
} mobj_diff2_t;
typedef enum
@ -2174,7 +2174,7 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type)
if (diff2 & MD2_TRANSLATION)
WRITEUINT16(save_p, mobj->translation);
if (diff2 & MD2_ALPHA)
WRITEUINT32(save_p, mobj->alpha);
WRITEFIXED(save_p, mobj->alpha);
WRITEUINT32(save_p, mobj->mobjnum);
}
@ -3242,7 +3242,7 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker)
if (diff2 & MD2_TRANSLATION)
mobj->translation = READUINT16(save_p);
if (diff2 & MD2_ALPHA)
mobj->alpha = READUINT32(save_p);
mobj->alpha = READFIXED(save_p);
if (diff & MD_REDFLAG)
{

View file

@ -1276,7 +1276,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale,
floordiff = abs((isflipped ? interp.height : 0) + interp.z - groundz);
trans = floordiff / (100*FRACUNIT) + 3;
trans = R_GetTransmapFromAlpha(thing->alpha, trans);
trans = R_GetTransmapFromAlpha((UINT32)thing->alpha, trans);
if (trans >= 9) return;
scalemul = FixedMul(FRACUNIT - floordiff/640, scale);
@ -1963,9 +1963,9 @@ static void R_ProjectSprite(mobj_t *thing)
trans = 0;
if ((oldthing->flags2 & MF2_LINKDRAW) && oldthing->tracer)
trans = R_GetTransmapFromAlpha(oldthing->tracer->alpha, trans);
trans = R_GetTransmapFromAlpha((UINT32)oldthing->tracer->alpha, trans);
else
trans = R_GetTransmapFromAlpha(oldthing->alpha, trans);
trans = R_GetTransmapFromAlpha((UINT32)oldthing->alpha, trans);
// Check if this sprite needs to be rendered like a shadow
shadowdraw = (!!(thing->renderflags & RF_SHADOWDRAW) && !(papersprite || splat));
@ -3428,7 +3428,7 @@ boolean R_ThingVisible (mobj_t *thing)
(thing->sprite == SPR_NULL) || // Don't draw null-sprites
(thing->flags2 & MF2_DONTDRAW) || // Don't draw MF2_LINKDRAW objects
(thing->drawonlyforplayer && thing->drawonlyforplayer != viewplayer) || // Don't draw other players' personal objects
((rendermode == render_soft && R_GetTransmapFromAlpha(thing->alpha, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT) >= 10) ||
((rendermode == render_soft && R_GetTransmapFromAlpha((UINT32)thing->alpha, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT) >= 10) ||
(rendermode == render_opengl && thing->alpha == 0)) ||
(!P_MobjWasRemoved(r_viewmobj) && (
(r_viewmobj == thing) || // Don't draw first-person players or awayviewmobj objects