perf: constexpr reciprocals, cache redundant lookups, consolidate texture maps

- Hoist DBC field index lookups before loops in game_handler (7 DBC iteration loops)
- Cache getSkybox()/getPosition() calls instead of redundant per-frame queries
- Merge textureHasAlphaByPtr_ + textureColorKeyBlackByPtr_ into single map
- Add constexpr for DEG_TO_RAD, reciprocal constants, physics delta
- Add reserve() for WMO/M2 collision grid queries and portal BFS
- Frustum plane normalize: inversesqrt instead of length+divide
- M2 particle emission: inversesqrt for direction normalization
- Parse creature display IDs from query response
- UI: show spell names/IDs as fallback instead of "Unknown"
This commit is contained in:
Kelsi 2026-03-27 16:47:30 -07:00
parent b0466e9029
commit d26eed1e7c
9 changed files with 153 additions and 104 deletions

View file

@ -48,6 +48,10 @@ constexpr size_t ALPHA_MAP_PACKED = 2048; // 64×64 packed 4-bit alpha (half
constexpr uint8_t ALPHA_FILL_FLAG = 0x80; // RLE command: fill vs. copy
constexpr uint8_t ALPHA_COUNT_MASK = 0x7F; // RLE command: count bits
// Placement transform constants
constexpr float kDegToRad = 3.14159f / 180.0f;
constexpr float kInv1024 = 1.0f / 1024.0f;
int computeTerrainWorkerCount() {
const char* raw = std::getenv("WOWEE_TERRAIN_WORKERS");
if (raw && *raw) {
@ -491,11 +495,11 @@ std::shared_ptr<PendingTile> TerrainManager::prepareTile(int x, int y) {
p.uniqueId = placement.uniqueId;
p.position = glPos;
p.rotation = glm::vec3(
-placement.rotation[2] * 3.14159f / 180.0f,
-placement.rotation[0] * 3.14159f / 180.0f,
(placement.rotation[1] + 180.0f) * 3.14159f / 180.0f
-placement.rotation[2] * kDegToRad,
-placement.rotation[0] * kDegToRad,
(placement.rotation[1] + 180.0f) * kDegToRad
);
p.scale = placement.scale / 1024.0f;
p.scale = placement.scale * kInv1024;
pending->m2Placements.push_back(p);
}
@ -561,9 +565,9 @@ std::shared_ptr<PendingTile> TerrainManager::prepareTile(int x, int y) {
placement.position[2]);
glm::vec3 rot(
-placement.rotation[2] * 3.14159f / 180.0f,
-placement.rotation[0] * 3.14159f / 180.0f,
(placement.rotation[1] + 180.0f) * 3.14159f / 180.0f
-placement.rotation[2] * kDegToRad,
-placement.rotation[0] * kDegToRad,
(placement.rotation[1] + 180.0f) * kDegToRad
);
// Pre-load WMO doodads (M2 models inside WMO)