Skip to content

Commit 02e33d7

Browse files
authored
perf(particlesys): Optimize angleBetween() in Particle System (TheSuperHackers#2218)
1 parent fa4aabf commit 02e33d7

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

Core/GameEngine/Source/GameClient/System/ParticleSys.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3451,16 +3451,17 @@ void ParticleSystemDebugDisplay( DebugDisplayInterface *dd, void *, FILE *fp )
34513451
// ------------------------------------------------------------------------------------------------
34523452
static Real angleBetween(const Coord2D *vecA, const Coord2D *vecB)
34533453
{
3454-
if (!(vecA && vecA->length() && vecB && vecB->length())) {
3455-
return 0.0;
3454+
const Real lengthA = vecA->length();
3455+
const Real lengthB = vecB->length();
3456+
3457+
if (!(lengthA && lengthB)) {
3458+
return 0.0f;
34563459
}
34573460

3458-
Real lengthA = vecA->length();
3459-
Real lengthB = vecB->length();
34603461
Real dotProduct = (vecA->x * vecB->x + vecA->y * vecB->y);
34613462
Real cosTheta = dotProduct / (lengthA * lengthB);
34623463

3463-
// If the dotproduct is 0.0, then they are orthogonal
3464+
// If the dot product is 0.0, then they are orthogonal
34643465
if (dotProduct == 0.0f) {
34653466
if (vecB->x > 0) {
34663467
return PI;

0 commit comments

Comments
 (0)