aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/Include
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-06-28 20:54:10 -0700
committerChris Robinson <[email protected]>2012-06-28 20:54:10 -0700
commit524c88c4025391aa17752d329cc2d548c9a6d261 (patch)
tree02170f3dbd5e4de3215fdb9c76e5111727cc44dd /OpenAL32/Include
parent1c096b101dc11e0f864e79bb5dbb730b90b52aeb (diff)
Test the squared length of a vector before normalizing
Diffstat (limited to 'OpenAL32/Include')
-rw-r--r--OpenAL32/Include/alu.h14
1 files changed, 6 insertions, 8 deletions
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 289614de..0540c699 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -281,15 +281,13 @@ static __inline ALfloat aluDotproduct(const ALfloat *inVector1, const ALfloat *i
static __inline void aluNormalize(ALfloat *inVector)
{
- ALfloat length, inverse_length;
-
- length = aluSqrt(aluDotproduct(inVector, inVector));
- if(length > 0.0f)
+ ALfloat lengthsqr = aluDotproduct(inVector, inVector);
+ if(lengthsqr > 0.0f)
{
- inverse_length = 1.0f/length;
- inVector[0] *= inverse_length;
- inVector[1] *= inverse_length;
- inVector[2] *= inverse_length;
+ ALfloat inv_length = 1.0f/aluSqrt(lengthsqr);
+ inVector[0] *= inv_length;
+ inVector[1] *= inv_length;
+ inVector[2] *= inv_length;
}
}