From 956e2c8bb14944dc02bc17798fd158b9a7047160 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 25 Feb 2026 12:16:55 -0800 Subject: [PATCH] Reduce city stutter: lower spawn rate, resync interval, M2 render distance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - MAX_SPAWNS_PER_FRAME 8→3 (each spawn does sync M2 load, 5-50ms each) - Creature resync scan interval 1s→3s (O(N) entity iteration) - M2 render distance: add 1000+ instance tier at 500 units, reduce 2000+ tier from 350→300 units to cap draw call count in dense cities --- include/core/application.hpp | 2 +- src/core/application.cpp | 2 +- src/rendering/m2_renderer.cpp | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/core/application.hpp b/include/core/application.hpp index 08da7458..1294ee12 100644 --- a/include/core/application.hpp +++ b/include/core/application.hpp @@ -244,7 +244,7 @@ private: float x, y, z, orientation; }; std::vector pendingCreatureSpawns_; - static constexpr int MAX_SPAWNS_PER_FRAME = 8; + static constexpr int MAX_SPAWNS_PER_FRAME = 3; static constexpr int MAX_NEW_CREATURE_MODELS_PER_FRAME = 1; static constexpr uint16_t MAX_CREATURE_SPAWN_RETRIES = 300; std::unordered_set pendingCreatureSpawnGuids_; diff --git a/src/core/application.cpp b/src/core/application.cpp index ee2697e7..eb9d0a7a 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -786,7 +786,7 @@ void Application::update(float deltaTime) { if (gameHandler) { static float creatureResyncTimer = 0.0f; creatureResyncTimer += deltaTime; - if (creatureResyncTimer >= 1.0f) { + if (creatureResyncTimer >= 3.0f) { creatureResyncTimer = 0.0f; glm::vec3 playerPos(0.0f); diff --git a/src/rendering/m2_renderer.cpp b/src/rendering/m2_renderer.cpp index 378a7b41..23c1c6d9 100644 --- a/src/rendering/m2_renderer.cpp +++ b/src/rendering/m2_renderer.cpp @@ -2081,8 +2081,10 @@ void M2Renderer::render(VkCommandBuffer cmd, VkDescriptorSet perFrameSet, const lastDrawCallCount = 0; - // Adaptive render distance: balanced for performance without excessive pop-in - const float maxRenderDistance = (instances.size() > 2000) ? 350.0f : 1000.0f; + // Adaptive render distance: tiered by instance density to cap draw calls + const float maxRenderDistance = (instances.size() > 2000) ? 300.0f + : (instances.size() > 1000) ? 500.0f + : 1000.0f; const float maxRenderDistanceSq = maxRenderDistance * maxRenderDistance; const float fadeStartFraction = 0.75f; const glm::vec3 camPos = camera.getPosition();