put interp distance stuff into a function

just some code dupe cleanup
also account for c++ so we can use the same macro lel
This commit is contained in:
Alug committed 2025-07-01 15:26:18 +02:00
1 parent 148fcc8dab
commit 3f5328371a
4 files changed
+26 -35

No files matched your search

+3 -17
View File
@@ -3517,8 +3517,6 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
}
}
#define std_R_QuickCamDist(x, y) std::max(abs(((x)>>FRACBITS) - (viewx>>FRACBITS)), abs(((y)>>FRACBITS) - (viewy>>FRACBITS)))
// This is expecting a pointer to an array containing 4 wallVerts for a sprite
static void HWR_RotateSpritePolyToAim(gl_vissprite_t *spr, FOutVector *wallVerts, const boolean precip, const boolean papersprite)
{
@@ -3530,13 +3528,9 @@ static void HWR_RotateSpritePolyToAim(gl_vissprite_t *spr, FOutVector *wallVerts
// uncapped/interpolation
interpmobjstate_t interp = {};
float basey, lowy;
INT32 dist = -1;
if (cv_maxinterpdist.value)
dist = std_R_QuickCamDist(spr->mobj->x, spr->mobj->y);
// do interpolation
if (R_UsingFrameInterpolation() && !paused && (!cv_maxinterpdist.value || dist < cv_maxinterpdist.value))
if (R_UsingFrameInterpolation() && !paused && R_CheckInterpDist(spr->mobj))
{
if (precip)
{
@@ -4647,7 +4641,6 @@ static void HWR_ProjectSprite(mobj_t *thing)
angle_t camang = 0;
#endif
INT32 heightsec, phs;
INT32 dist = -1;
fixed_t spr_width, spr_height;
fixed_t spr_offset, spr_topoffset;
@@ -4664,10 +4657,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
// uncapped/interpolation
interpmobjstate_t interp = {};
if (cv_maxinterpdist.value)
dist = std_R_QuickCamDist(thing->x, thing->y);
if (R_UsingFrameInterpolation() && !paused && (!cv_maxinterpdist.value || dist < cv_maxinterpdist.value))
if (R_UsingFrameInterpolation() && !paused && R_CheckInterpDist(thing))
{
R_InterpolateMobjState(thing, rendertimefrac, &interp);
}
@@ -5008,7 +4998,6 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
size_t lumpoff;
unsigned rot = 0;
UINT8 flip;
INT32 dist = -1;
if (!thing)
return;
@@ -5022,11 +5011,8 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
// uncapped/interpolation
interpmobjstate_t interp = {};
if (cv_maxinterpdist.value)
dist = std_R_QuickCamDist(thing->x, thing->y);
// do interpolation
if (R_UsingFrameInterpolation() && !paused && (!cv_maxinterpdist.value || dist < cv_maxinterpdist.value))
if (R_UsingFrameInterpolation() && !paused && R_CheckInterpDist((mobj_t*)thing))
{
R_InterpolatePrecipMobjState(thing, rendertimefrac, &interp);
}
+1 -1
View File
@@ -1187,7 +1187,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
spriteinfo_t *sprinfo;
interpmobjstate_t interp;
if (R_UsingFrameInterpolation() && !paused && (!cv_maxinterpdist.value || R_QuickCamDist(spr->mobj->x, spr->mobj->y) < cv_maxinterpdist.value))
if (R_UsingFrameInterpolation() && !paused && R_CheckInterpDist(spr->mobj))
{
R_InterpolateMobjState(spr->mobj, rendertimefrac, &interp);
}
+16 -17
View File
@@ -1164,8 +1164,6 @@ fixed_t R_GetSpriteDirectionalLighting(angle_t angle)
return extralight;
}
#define std_R_QuickCamDist(x, y) std::max(abs(((x)>>FRACBITS) - (viewx>>FRACBITS)), abs(((y)>>FRACBITS) - (viewy>>FRACBITS)))
//
// R_ProjectSprite
// Generates a vissprite for a thing
@@ -1206,7 +1204,6 @@ static void R_ProjectSprite(mobj_t *thing)
//SoM: 3/17/2000
fixed_t gz, gzt;
INT32 heightsec, phs;
INT32 dist = -1;
INT32 light = 0;
lighttable_t **lights_array = spritelights;
fixed_t this_scale;
@@ -1233,14 +1230,11 @@ static void R_ProjectSprite(mobj_t *thing)
const boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored);
const boolean papersprite = (thing->frame & FF_PAPERSPRITE);
if (cv_maxinterpdist.value)
dist = std_R_QuickCamDist(thing->x, thing->y);
// uncapped/interpolation
interpmobjstate_t interp = {};
// do interpolation
if (R_UsingFrameInterpolation() && !paused && (!cv_maxinterpdist.value || dist < cv_maxinterpdist.value))
if (R_UsingFrameInterpolation() && !paused && R_CheckInterpDist(oldthing))
{
R_InterpolateMobjState(oldthing, rendertimefrac, &interp);
}
@@ -1862,25 +1856,20 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
fixed_t gz, gzt;
fixed_t this_scale;
INT32 dist = 1;
if (!thing || thing->subsector == NULL)
return;
if (cv_maxinterpdist.value)
dist = std_R_QuickCamDist(thing->x, thing->y);
// uncapped/interpolation
interpmobjstate_t interp = {};
// okay... this is a hack, but weather isn't networked, so it should be ok
if (!P_PrecipThinker(thing))
{
return;
}
// uncapped/interpolation
interpmobjstate_t interp = {};
// do interpolation
if (R_UsingFrameInterpolation() && !paused && (!cv_maxinterpdist.value || dist < cv_maxinterpdist.value))
if (R_UsingFrameInterpolation() && !paused && R_CheckInterpDist((mobj_t*)thing))
{
R_InterpolatePrecipMobjState(thing, rendertimefrac, &interp);
}
@@ -2919,7 +2908,7 @@ boolean R_ThingVisible (mobj_t *thing)
if (splitscreen)
{
if ((viewssnum == 0 && (thing->eflags & MFE_DRAWONLYFORP1))
if ((viewssnum == 0 && (thing->eflags & MFE_DRAWONLYFORP1))
|| (viewssnum == 1 && (thing->eflags & MFE_DRAWONLYFORP2))
|| (viewssnum == 2 && (thing->eflags & MFE_DRAWONLYFORP2))
|| (viewssnum == 3 && (thing->eflags & MFE_DRAWONLYFORP4)))
@@ -2942,6 +2931,16 @@ boolean R_ThingWithinDist(mobj_t *thing, INT32 limit_dist)
return true;
}
boolean R_CheckInterpDist(mobj_t *thing)
{
if (!cv_maxinterpdist.value)
return true;
const INT32 dist = R_QuickCamDist(thing->x, thing->y);
return (dist < cv_maxinterpdist.value);
}
boolean R_ThingIsFullBright(mobj_t *thing)
{
return ((thing->frame & FF_BRIGHTMASK) == FF_FULLBRIGHT);
+6
View File
@@ -39,7 +39,12 @@ extern "C" {
// as an non-fixed-point integer.
// It is very rough, tho it is used only for optimizing out unnecessary
// interpolation, so it is kinda ok on big distances.
#ifdef __cplusplus
#define R_QuickCamDist(x, y) std::max(std::abs(((x)>>FRACBITS) - (viewx>>FRACBITS)), std::abs(((y)>>FRACBITS) - (viewy>>FRACBITS)))
#else
#define R_QuickCamDist(x, y) max(abs(((x)>>FRACBITS) - (viewx>>FRACBITS)), abs(((y)>>FRACBITS) - (viewy>>FRACBITS)))
#endif
// Constant arrays used for psprite clipping
// and initializing clipping.
@@ -84,6 +89,7 @@ void R_DrawMasked(maskcount_t* masks, INT32 nummasks);
boolean R_ThingVisible(mobj_t *thing);
boolean R_ThingWithinDist(mobj_t *thing, INT32 limit_dist);
boolean R_CheckInterpDist(mobj_t *thing);
boolean R_ThingIsFullBright(mobj_t *thing);
boolean R_ThingIsSemiBright(mobj_t *thing);