From 145eecf8a40e9b573dd9a9aa60c3b41886556106 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 19 Aug 2025 11:30:28 +0200 Subject: [PATCH] move sprite reset stuff into R_ResetMobjInterpolationState this also gets called at the start of the tic and sets a bunch of rendering crap eitherways so we can save another thinker loop and a bunch of checks with this bit of perf gain, 3-4fps on that awful hadal trench timedemo --- src/p_mobj.c | 6 ++++-- src/p_tick.c | 34 ---------------------------------- src/r_fps.c | 13 +++++++++++++ 3 files changed, 17 insertions(+), 36 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index ff0a35949..ada4dbcdb 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9854,7 +9854,6 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster) mobj->radius = info->radius; mobj->height = info->height; mobj->flags = info->flags; - mobj->blendmode = AST_TRANSLUCENT; mobj->health = info->spawnhealth; @@ -9890,7 +9889,10 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster) } // Sprite rendering - mobj->spritexscale = mobj->spriteyscale = mobj->scale; + mobj->blendmode = AST_TRANSLUCENT; + mobj->realxscale = mobj->realyscale = mobj->scale; + mobj->spritexscale = mobj->realxscale; + mobj->spriteyscale = mobj->realyscale; // set subsector and/or block links P_SetThingPosition(mobj); diff --git a/src/p_tick.c b/src/p_tick.c index 76379f5a0..752e60794 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -614,38 +614,6 @@ static void P_RunQuakes(void) --quake.time; } -// Reset our Sprite scales and offsets -// at the start of our tic -// this is just to make things simpler -// as we dont have to reset it ourselves after use -// done at the start so lua can still overwrite everything -static inline void P_ResetSpriteStuff(void) -{ - thinker_t *th; - - if (rendermode == render_none) - return; - - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - mobj_t *mo; - - if (th->function != (actionf_p1)P_MobjThinker) // not a mobj - continue; - - mo = (mobj_t *)th; - - if (!mo || (mo->sprite == SPR_NULL) - || (mo->flags2 & MF2_DONTDRAW) || (mo->type == MT_SHADOW)) - continue; - - mo->spritexscale = mo->realxscale; - mo->spriteyscale = mo->realyscale; - mo->spritexoffset = mo->realxoffset; - mo->spriteyoffset = mo->realyoffset; - } -} - // // P_Ticker // @@ -747,8 +715,6 @@ void P_Ticker(boolean run) ps_lua_mobjhooks.value.i = 0; ps_checkposition_calls.value.i = 0; - P_ResetSpriteStuff(); - PS_START_TIMING(ps_lua_prethinkframe_time); LUA_HookPreThinkFrame(); PS_STOP_TIMING(ps_lua_prethinkframe_time); diff --git a/src/r_fps.c b/src/r_fps.c index 710210939..6bd385066 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -860,6 +860,19 @@ void R_ResetMobjInterpolationState(mobj_t *mobj) mobj->player->old_frameangle = mobj->player->frameangle; } + // Reset our Sprite scales and offsets + // at the start of the tic + // this is just to make things simpler + // as we dont have to reset it ourselves after use + // done at the start so lua can still overwrite everything + + // technically not interpolation related + // but this saves us another thinkerloop and multiple checks lel + mobj->spritexscale = mobj->realxscale; + mobj->spriteyscale = mobj->realyscale; + mobj->spritexoffset = mobj->realxoffset; + mobj->spriteyoffset = mobj->realyoffset; + mobj->resetinterp = false; }