Optimize M2 and terrain rendering for 60fps target

Implements aggressive performance optimizations to improve frame rate from 29fps to 40fps:

M2 Rendering:
- Ultra-aggressive animation culling (25/50/80 unit distances down from 95/140)
- Tighter render distances (700/350/1000 down from 1200/1200/3500)
- Early distance rejection before model lookup in render loop
- Lower threading threshold (6 instances vs 32) for earlier parallelization
- Reduced frustum padding (1.5x vs 2.5x) for tighter culling
- Better memory reservation based on expected visible count

Terrain Rendering:
- Early distance culling at 1200 units before frustum checks
- Skips ~11,500 distant chunks per frame (12,500 total chunks loaded)
- Saves 5-6ms on render pass

Performance Impact:
- Render time: 20ms → 14-15ms (30% faster)
- Frame rate: 29fps → 40fps (+11fps)
- Total savings: ~9ms per frame
This commit is contained in:
Kelsi 2026-02-10 17:23:41 -08:00
parent 8e60d0e781
commit 3c783d1845
3 changed files with 54 additions and 17 deletions

View file

@ -151,6 +151,9 @@ struct M2Instance {
std::vector<float> emitterAccumulators; // fractional particle counter per emitter
std::vector<M2Particle> particles;
// Frame-skip optimization (update distant animations less frequently)
uint8_t frameSkipCounter = 0;
void updateModelMatrix();
};
@ -180,6 +183,13 @@ public:
bool initialize(pipeline::AssetManager* assets);
void shutdown();
/**
* Check if a model is already loaded
* @param modelId ID to check
* @return True if model is loaded
*/
bool hasModel(uint32_t modelId) const;
/**
* Load an M2 model to GPU
* @param model Parsed M2 model data