- Added GL version of sprite distance culling.

This commit is contained in:
drfrag 2019-09-04 22:14:44 +02:00
parent d47af90a56
commit ba835a14a4

View file

@ -682,6 +682,21 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingp
// //
//========================================================================== //==========================================================================
CVAR(Float, gl_sprite_distance_cull, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
inline bool IsDistanceCulled(AActor* thing)
{
double culldist = gl_sprite_distance_cull * gl_sprite_distance_cull;
if (culldist <= 0.0)
return false;
double dist = (thing->Pos() - r_viewpoint.Pos).LengthSquared();
if (dist > culldist)
return true;
return false;
}
void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
{ {
sector_t rs; sector_t rs;
@ -690,6 +705,9 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
if (thing == nullptr) if (thing == nullptr)
return; return;
if (IsDistanceCulled(thing))
return;
// [ZZ] allow CustomSprite-style direct picnum specification // [ZZ] allow CustomSprite-style direct picnum specification
bool isPicnumOverride = thing->picnum.isValid(); bool isPicnumOverride = thing->picnum.isValid();