summaryrefslogtreecommitdiffstats
path: root/OpenAL32/Include/alu.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-10-30 08:27:24 -0700
committerChris Robinson <[email protected]>2011-10-30 08:27:24 -0700
commitfcf9034c2bb9945a69f5cdb9c5a24ad199800552 (patch)
tree59c60217f90d650cac82ff9f5316a3c8beaeb2eb /OpenAL32/Include/alu.h
parent956e6f95ec877f17d9ddbb7c77b4196cad70485d (diff)
Calculate the listener matrix when a new orientation is specified
This is so the matrix isn't derived each time a source is updated, and it will make supporting user-defined matrices easier.
Diffstat (limited to 'OpenAL32/Include/alu.h')
-rw-r--r--OpenAL32/Include/alu.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index ffc8fa39..a3584775 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -260,6 +260,34 @@ static __inline void RestoreFPUMode(int state)
}
+static __inline void aluCrossproduct(const ALfloat *inVector1, const ALfloat *inVector2, ALfloat *outVector)
+{
+ outVector[0] = inVector1[1]*inVector2[2] - inVector1[2]*inVector2[1];
+ outVector[1] = inVector1[2]*inVector2[0] - inVector1[0]*inVector2[2];
+ outVector[2] = inVector1[0]*inVector2[1] - inVector1[1]*inVector2[0];
+}
+
+static __inline ALfloat aluDotproduct(const ALfloat *inVector1, const ALfloat *inVector2)
+{
+ return inVector1[0]*inVector2[0] + inVector1[1]*inVector2[1] +
+ inVector1[2]*inVector2[2];
+}
+
+static __inline void aluNormalize(ALfloat *inVector)
+{
+ ALfloat length, inverse_length;
+
+ length = aluSqrt(aluDotproduct(inVector, inVector));
+ if(length > 0.0f)
+ {
+ inverse_length = 1.0f/length;
+ inVector[0] *= inverse_length;
+ inVector[1] *= inverse_length;
+ inVector[2] *= inverse_length;
+ }
+}
+
+
ALvoid aluInitPanning(ALCdevice *Device);
ALint aluCart2LUTpos(ALfloat re, ALfloat im);