- Add r_model_distance_cull to control when models turn into sprites

This commit is contained in:
Magnus Norddahl 2017-11-29 01:09:26 +01:00
parent b621dccb9c
commit 8cad912db1

View file

@ -80,6 +80,7 @@ namespace
{ {
double sprite_distance_cull = 1e16; double sprite_distance_cull = 1e16;
double line_distance_cull = 1e16; double line_distance_cull = 1e16;
double model_distance_cull = 1e16;
} }
CUSTOM_CVAR(Float, r_sprite_distance_cull, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CUSTOM_CVAR(Float, r_sprite_distance_cull, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
@ -106,6 +107,18 @@ CUSTOM_CVAR(Float, r_line_distance_cull, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
} }
} }
CUSTOM_CVAR(Float, r_model_distance_cull, 1024, 0/*CVAR_ARCHIVE | CVAR_GLOBALCONFIG*/) // Experimental for the moment until a good default is chosen
{
if (r_model_distance_cull > 0.0)
{
model_distance_cull = r_model_distance_cull * r_model_distance_cull;
}
else
{
model_distance_cull = 1e16;
}
}
namespace swrenderer namespace swrenderer
{ {
RenderOpaquePass::RenderOpaquePass(RenderThread *thread) : renderline(thread) RenderOpaquePass::RenderOpaquePass(RenderThread *thread) : renderline(thread)
@ -955,7 +968,7 @@ namespace swrenderer
int spritenum = thing->sprite; int spritenum = thing->sprite;
bool isPicnumOverride = thing->picnum.isValid(); bool isPicnumOverride = thing->picnum.isValid();
FSpriteModelFrame *modelframe = isPicnumOverride ? nullptr : gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, !!(thing->flags & MF_DROPPED)); FSpriteModelFrame *modelframe = isPicnumOverride ? nullptr : gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, !!(thing->flags & MF_DROPPED));
if (modelframe) if (modelframe && (thing->Pos() - Thread->Viewport->viewpoint.Pos).LengthSquared() < model_distance_cull)
{ {
DVector3 pos = thing->InterpolatedPosition(Thread->Viewport->viewpoint.TicFrac); DVector3 pos = thing->InterpolatedPosition(Thread->Viewport->viewpoint.TicFrac);
RenderModel::Project(Thread, (float)pos.X, (float)pos.Y, (float)pos.Z, modelframe, thing); RenderModel::Project(Thread, (float)pos.X, (float)pos.Y, (float)pos.Z, modelframe, thing);