From 3344806a9829c43761a7ca04f63b79168b96a156 Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Mon, 19 Jan 2026 22:32:43 +0100 Subject: [PATCH] perf(particlesys): Optimize angleBetween in Particle System --- .../Source/GameClient/System/ParticleSys.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp b/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp index 8a9d48e30e..273733e2ca 100644 --- a/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp +++ b/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp @@ -3454,16 +3454,17 @@ void ParticleSystemDebugDisplay( DebugDisplayInterface *dd, void *, FILE *fp ) // ------------------------------------------------------------------------------------------------ static Real angleBetween(const Coord2D *vecA, const Coord2D *vecB) { - if (!(vecA && vecA->length() && vecB && vecB->length())) { - return 0.0; + const Real lengthA = vecA->length(); + const Real lengthB = vecB->length(); + + if (!(lengthA && lengthB)) { + return 0.0f; } - Real lengthA = vecA->length(); - Real lengthB = vecB->length(); Real dotProduct = (vecA->x * vecB->x + vecA->y * vecB->y); Real cosTheta = dotProduct / (lengthA * lengthB); - // If the dotproduct is 0.0, then they are orthogonal + // If the dot product is 0.0, then they are orthogonal if (dotProduct == 0.0f) { if (vecB->x > 0) { return PI;