mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-21 18:32:08 +00:00
Duplicated code is gone, so sad
This commit is contained in:
parent
542e38e717
commit
762223db7c
3 changed files with 68 additions and 78 deletions
|
@ -5399,7 +5399,7 @@ static void HWR_AddSprites(sector_t *sec)
|
|||
#ifdef HWPRECIP
|
||||
precipmobj_t *precipthing;
|
||||
#endif
|
||||
fixed_t approx_dist, limit_dist, hoop_limit_dist;
|
||||
fixed_t limit_dist, hoop_limit_dist;
|
||||
|
||||
// BSP is traversed by subsector.
|
||||
// A sector might have been split into several
|
||||
|
@ -5418,37 +5418,10 @@ static void HWR_AddSprites(sector_t *sec)
|
|||
// If a limit exists, handle things a tiny bit different.
|
||||
limit_dist = (fixed_t)(cv_drawdist.value) << FRACBITS;
|
||||
hoop_limit_dist = (fixed_t)(cv_drawdist_nights.value) << FRACBITS;
|
||||
if (limit_dist || hoop_limit_dist)
|
||||
for (thing = sec->thinglist; thing; thing = thing->snext)
|
||||
{
|
||||
for (thing = sec->thinglist; thing; thing = thing->snext)
|
||||
{
|
||||
if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW ||
|
||||
thing == r_viewmobj)
|
||||
continue;
|
||||
|
||||
approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y);
|
||||
|
||||
if (thing->sprite == SPR_HOOP)
|
||||
{
|
||||
if (hoop_limit_dist && approx_dist > hoop_limit_dist)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (limit_dist && approx_dist > limit_dist)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (R_ThingVisibleWithinDist(thing, limit_dist, hoop_limit_dist))
|
||||
HWR_ProjectSprite(thing);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Draw everything in sector, no checks
|
||||
for (thing = sec->thinglist; thing; thing = thing->snext)
|
||||
if (!(thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW ||
|
||||
thing == r_viewmobj))
|
||||
HWR_ProjectSprite(thing);
|
||||
}
|
||||
|
||||
#ifdef HWPRECIP
|
||||
|
@ -5457,15 +5430,8 @@ static void HWR_AddSprites(sector_t *sec)
|
|||
{
|
||||
for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext)
|
||||
{
|
||||
if (precipthing->precipflags & PCF_INVISIBLE)
|
||||
continue;
|
||||
|
||||
approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y);
|
||||
|
||||
if (approx_dist > limit_dist)
|
||||
continue;
|
||||
|
||||
HWR_ProjectPrecipitationSprite(precipthing);
|
||||
if (R_PrecipThingVisible(precipthing, limit_dist))
|
||||
HWR_ProjectPrecipitationSprite(precipthing);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1808,7 +1808,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
|
|||
mobj_t *thing;
|
||||
precipmobj_t *precipthing; // Tails 08-25-2002
|
||||
INT32 lightnum;
|
||||
fixed_t approx_dist, limit_dist, hoop_limit_dist;
|
||||
fixed_t limit_dist, hoop_limit_dist;
|
||||
|
||||
if (rendermode != render_soft)
|
||||
return;
|
||||
|
@ -1841,37 +1841,10 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
|
|||
// If a limit exists, handle things a tiny bit different.
|
||||
limit_dist = (fixed_t)(cv_drawdist.value) << FRACBITS;
|
||||
hoop_limit_dist = (fixed_t)(cv_drawdist_nights.value) << FRACBITS;
|
||||
if (limit_dist || hoop_limit_dist)
|
||||
for (thing = sec->thinglist; thing; thing = thing->snext)
|
||||
{
|
||||
for (thing = sec->thinglist; thing; thing = thing->snext)
|
||||
{
|
||||
if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW ||
|
||||
thing == r_viewmobj)
|
||||
continue;
|
||||
|
||||
approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y);
|
||||
|
||||
if (thing->sprite == SPR_HOOP)
|
||||
{
|
||||
if (hoop_limit_dist && approx_dist > hoop_limit_dist)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (limit_dist && approx_dist > limit_dist)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (R_ThingVisibleWithinDist(thing, limit_dist, hoop_limit_dist))
|
||||
R_ProjectSprite(thing);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Draw everything in sector, no checks
|
||||
for (thing = sec->thinglist; thing; thing = thing->snext)
|
||||
if (!(thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW ||
|
||||
thing == r_viewmobj))
|
||||
R_ProjectSprite(thing);
|
||||
}
|
||||
|
||||
// no, no infinite draw distance for precipitation. this option at zero is supposed to turn it off
|
||||
|
@ -1879,15 +1852,8 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
|
|||
{
|
||||
for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext)
|
||||
{
|
||||
if (precipthing->precipflags & PCF_INVISIBLE)
|
||||
continue;
|
||||
|
||||
approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y);
|
||||
|
||||
if (approx_dist > limit_dist)
|
||||
continue;
|
||||
|
||||
R_ProjectPrecipitationSprite(precipthing);
|
||||
if (R_PrecipThingVisible(precipthing, limit_dist))
|
||||
R_ProjectPrecipitationSprite(precipthing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2582,6 +2548,55 @@ void R_ClipSprites(drawseg_t* dsstart, portal_t* portal)
|
|||
}
|
||||
}
|
||||
|
||||
/* Check if thing may be drawn from our current view. */
|
||||
boolean R_ThingVisible (mobj_t *thing)
|
||||
{
|
||||
return (!(
|
||||
thing->sprite == SPR_NULL ||
|
||||
( thing->flags2 & (MF2_DONTDRAW) ) ||
|
||||
thing == r_viewmobj
|
||||
));
|
||||
}
|
||||
|
||||
boolean R_ThingVisibleWithinDist (mobj_t *thing,
|
||||
fixed_t limit_dist,
|
||||
fixed_t hoop_limit_dist)
|
||||
{
|
||||
fixed_t approx_dist;
|
||||
|
||||
if (! R_ThingVisible(thing))
|
||||
return false;
|
||||
|
||||
approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y);
|
||||
|
||||
if (thing->sprite == SPR_HOOP)
|
||||
{
|
||||
if (hoop_limit_dist && approx_dist > hoop_limit_dist)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (limit_dist && approx_dist > limit_dist)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Check if precipitation may be drawn from our current view. */
|
||||
boolean R_PrecipThingVisible (precipmobj_t *precipthing,
|
||||
fixed_t limit_dist)
|
||||
{
|
||||
fixed_t approx_dist;
|
||||
|
||||
if (( precipthing->precipflags & PCF_INVISIBLE ))
|
||||
return false;
|
||||
|
||||
approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y);
|
||||
|
||||
return ( approx_dist <= limit_dist );
|
||||
}
|
||||
|
||||
//
|
||||
// R_DrawMasked
|
||||
//
|
||||
|
|
|
@ -61,6 +61,15 @@ void R_InitSprites(void);
|
|||
void R_ClearSprites(void);
|
||||
void R_ClipSprites(drawseg_t* dsstart, portal_t* portal);
|
||||
|
||||
boolean R_ThingVisible (mobj_t *thing);
|
||||
|
||||
boolean R_ThingVisibleWithinDist (mobj_t *thing,
|
||||
fixed_t draw_dist,
|
||||
fixed_t nights_draw_dist);
|
||||
|
||||
boolean R_PrecipThingVisible (precipmobj_t *precipthing,
|
||||
fixed_t precip_draw_dist);
|
||||
|
||||
/** Used to count the amount of masked elements
|
||||
* per portal to later group them in separate
|
||||
* drawnode lists.
|
||||
|
|
Loading…
Reference in a new issue