From 9f42da46867539d9a9be14cdaf9119ec7de57863 Mon Sep 17 00:00:00 2001 From: smallmodel <15067410+smallmodel@users.noreply.github.com> Date: Tue, 3 Oct 2023 17:04:26 +0200 Subject: [PATCH] Hide tempmodel when it is outside of the min/max distance range --- code/cgame/cg_tempmodels.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/code/cgame/cg_tempmodels.cpp b/code/cgame/cg_tempmodels.cpp index 1073a65ca..0da92300e 100644 --- a/code/cgame/cg_tempmodels.cpp +++ b/code/cgame/cg_tempmodels.cpp @@ -1048,6 +1048,14 @@ void ClientGameCommandManager::SpawnTempModel(int mcount) Vector delta; Vector start; Vector vForward, vLeft, vUp; + float fDist; + + delta = m_spawnthing->cgd.origin - cg.refdef.vieworg; + fDist = delta * delta * (cg.refdef.fov_x * cg.refdef.fov_x / 6400.0); + if (fDist >= m_spawnthing->fMaxRangeSquared || fDist < m_spawnthing->fMinRangeSquared) { + // don't draw above the distance + return; + } if (current_entity) { current_entity_scale = current_entity->scale;