Add dynamic memory-based asset caching and aggressive loading

- Add MemoryMonitor class for dynamic cache sizing based on available RAM
- Increase terrain load radius to 8 tiles (17x17 grid, 289 tiles)
- Scale worker threads to 75% of logical cores (no cap)
- Increase cache budget to 80% of available RAM, max file size to 50%
- Increase M2 render distance: 1200 units during taxi, 800 when >2000 instances
- Fix camera positioning during taxi flights (external follow mode)
- Add 2-second landing cooldown to prevent re-entering taxi mode on lag
- Update interval reduced to 33ms for faster streaming responsiveness

Optimized for high-memory systems while scaling gracefully to lower-end hardware.
Cache and render distances now fully utilize available VRAM on minimum spec GPUs.
This commit is contained in:
Kelsi 2026-02-08 23:15:26 -08:00
parent 132c6aebbc
commit 51e93808b3
12 changed files with 198 additions and 19 deletions

View file

@ -0,0 +1,47 @@
#pragma once
#include <cstddef>
#include <cstdint>
namespace wowee {
namespace core {
/**
* Monitors system memory and provides dynamic cache sizing
*/
class MemoryMonitor {
public:
static MemoryMonitor& getInstance();
/**
* Initialize memory monitoring
*/
void initialize();
/**
* Get total system RAM in bytes
*/
size_t getTotalRAM() const { return totalRAM_; }
/**
* Get currently available RAM in bytes
*/
size_t getAvailableRAM() const;
/**
* Get recommended cache budget (30% of available RAM)
*/
size_t getRecommendedCacheBudget() const;
/**
* Check if system is under memory pressure
*/
bool isMemoryPressure() const;
private:
MemoryMonitor() = default;
size_t totalRAM_ = 0;
};
} // namespace core
} // namespace wowee

View file

@ -965,6 +965,7 @@ private:
bool taxiActivatePending_ = false;
float taxiActivateTimer_ = 0.0f;
bool taxiClientActive_ = false;
float taxiLandingCooldown_ = 0.0f; // Prevent re-entering taxi right after landing
size_t taxiClientIndex_ = 0;
std::vector<glm::vec3> taxiClientPath_;
float taxiClientSpeed_ = 18.0f; // Reduced from 32 to prevent loading hitches

View file

@ -104,7 +104,7 @@ private:
mutable std::mutex readMutex;
std::map<std::string, std::shared_ptr<DBCFile>> dbcCache;
// Decompressed file cache (LRU, 1GB budget for modern RAM)
// Decompressed file cache (LRU, dynamic budget based on system RAM)
struct CachedFile {
std::vector<uint8_t> data;
uint64_t lastAccessTime;
@ -114,7 +114,7 @@ private:
mutable uint64_t fileCacheAccessCounter = 0;
mutable size_t fileCacheHits = 0;
mutable size_t fileCacheMisses = 0;
static constexpr size_t FILE_CACHE_BUDGET = 1024 * 1024 * 1024; // 1GB
mutable size_t fileCacheBudget = 1024 * 1024 * 1024; // Dynamic, starts at 1GB
/**
* Normalize path for case-insensitive lookup

View file

@ -272,9 +272,9 @@ private:
// Streaming parameters
bool streamingEnabled = true;
int loadRadius = 2; // Load tiles within this radius (5x5 grid)
int unloadRadius = 3; // Unload tiles beyond this radius
float updateInterval = 0.1f; // Check streaming every 0.1 seconds
int loadRadius = 8; // Load tiles within this radius (17x17 grid)
int unloadRadius = 12; // Unload tiles beyond this radius
float updateInterval = 0.033f; // Check streaming every 33ms (~30 fps)
float timeSinceLastUpdate = 0.0f;
// Tile size constants (WoW ADT specifications)
@ -300,7 +300,7 @@ private:
std::unordered_map<TileCoord, CachedTile, TileCoord::Hash> tileCache_;
std::list<TileCoord> tileCacheLru_;
size_t tileCacheBytes_ = 0;
size_t tileCacheBudgetBytes_ = 8ull * 1024 * 1024 * 1024; // 8GB for modern systems
size_t tileCacheBudgetBytes_ = 8ull * 1024 * 1024 * 1024; // Dynamic, set at init based on RAM
std::mutex tileCacheMutex_;
std::shared_ptr<PendingTile> getCachedTile(const TileCoord& coord);