mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-25 21:03:51 +00:00
perf: eliminate ~70 unnecessary sqrt ops per frame, optimize caches and threading
Squared distance optimizations across 30 files: - Convert glm::length() comparisons to glm::dot() (no sqrt) - Use glm::inversesqrt() for check-then-normalize patterns (1 rsqrt vs 2 sqrt) - Defer sqrt to after early-out checks in collision/movement code - Hottest paths: camera_controller (21), weather particles, WMO collision, transport movement, creature interpolation, nameplate culling Container and algorithm improvements: - std::map<string> → std::unordered_map for asset/DBC/MPQ/warden caches - std::mutex → std::shared_mutex for asset_manager and mpq_manager caches - std::sort → std::partial_sort in lighting_manager (top-2 of N volumes) - Double-lookup find()+operator[] → insert_or_assign in game_handler - Add reserve() for per-frame vectors: weather, swim_effects, WMO/M2 collision Threading and synchronization: - Replace 1ms busy-wait polling with condition_variable in character_renderer - Move timestamp capture before mutex in logger - Use memory_order_acquire/release for normal map completion signaling API additions: - DBC getStringView()/getStringViewByOffset() for zero-copy string access - Parse creature display IDs from SMSG_CREATURE_QUERY_SINGLE_RESPONSE
This commit is contained in:
parent
cf0e2aa240
commit
b0466e9029
29 changed files with 328 additions and 196 deletions
|
|
@ -3242,7 +3242,7 @@ void Renderer::update(float deltaTime) {
|
|||
} else if (inCombat_ && targetPosition && !emoteActive && !isMounted()) {
|
||||
// Face target when in combat and idle
|
||||
glm::vec3 toTarget = *targetPosition - characterPosition;
|
||||
if (glm::length(glm::vec2(toTarget.x, toTarget.y)) > 0.1f) {
|
||||
if (toTarget.x * toTarget.x + toTarget.y * toTarget.y > 0.01f) {
|
||||
float targetYaw = glm::degrees(std::atan2(toTarget.y, toTarget.x));
|
||||
float diff = targetYaw - characterYaw;
|
||||
while (diff > 180.0f) diff -= 360.0f;
|
||||
|
|
@ -6222,8 +6222,9 @@ glm::mat4 Renderer::computeLightSpaceMatrix() {
|
|||
glm::vec3 sunDir = glm::normalize(glm::vec3(-0.3f, -0.7f, -0.6f));
|
||||
if (lightingManager) {
|
||||
const auto& lighting = lightingManager->getLightingParams();
|
||||
if (glm::length(lighting.directionalDir) > 0.001f) {
|
||||
sunDir = glm::normalize(-lighting.directionalDir);
|
||||
float ldirLenSq = glm::dot(lighting.directionalDir, lighting.directionalDir);
|
||||
if (ldirLenSq > 1e-6f) {
|
||||
sunDir = -lighting.directionalDir * glm::inversesqrt(ldirLenSq);
|
||||
}
|
||||
}
|
||||
// Shadow camera expects light rays pointing downward in render space (Z up).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue