super smol optimization R_ThingWithinDist

no need to run fixedhypot on every sprite when you dont use draw distance limit
This commit is contained in:
Alug committed 2024-09-13 12:44:38 +02:00
1 parent 4f1f1ede97
commit d5dc52d3d3
2 files changed
+9 -8

No files matched your search

+1 -1
View File
@@ -4561,7 +4561,7 @@ void HWR_AddSprites(sector_t *sec)
// BSP is traversed by subsector.
// A sector might have been split into several
// subsectors during BSP building.
// subsectors during BSP building.
// Thus we check whether its already added.
if (sec->validcount == validcount)
return;
+8 -7
View File
@@ -1931,14 +1931,13 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
{
mobj_t *thing;
INT32 lightnum;
fixed_t limit_dist;
if (rendermode != render_soft)
return;
// BSP is traversed by subsector.
// A sector might have been split into several
// subsectors during BSP building.
// subsectors during BSP building.
// Thus we check whether its already added.
if (sec->validcount == validcount)
return;
@@ -1962,7 +1961,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
// Handle all things in sector.
// If a limit exists, handle things a tiny bit different.
limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale;
const fixed_t limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale;
for (thing = sec->thinglist; thing; thing = thing->snext)
{
if (!R_ThingWithinDist(thing, limit_dist))
@@ -2798,11 +2797,13 @@ boolean R_ThingVisible (mobj_t *thing)
boolean R_ThingWithinDist (mobj_t *thing, fixed_t limit_dist)
{
const fixed_t dist = P_AproxDistance(viewx-thing->x, viewy-thing->y);
if (limit_dist && dist > limit_dist)
if (limit_dist)
{
return false;
const fixed_t dist = P_AproxDistance(viewx-thing->x, viewy-thing->y);
if (dist > limit_dist)
{
return false;
}
}
return true;