diff options
author | Chris Robinson <[email protected]> | 2011-10-30 08:27:24 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-10-30 08:27:24 -0700 |
commit | fcf9034c2bb9945a69f5cdb9c5a24ad199800552 (patch) | |
tree | 59c60217f90d650cac82ff9f5316a3c8beaeb2eb /OpenAL32/Include | |
parent | 956e6f95ec877f17d9ddbb7c77b4196cad70485d (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')
-rw-r--r-- | OpenAL32/Include/alListener.h | 1 | ||||
-rw-r--r-- | OpenAL32/Include/alu.h | 28 |
2 files changed, 29 insertions, 0 deletions
diff --git a/OpenAL32/Include/alListener.h b/OpenAL32/Include/alListener.h index 0f399e5f..0e69f6c5 100644 --- a/OpenAL32/Include/alListener.h +++ b/OpenAL32/Include/alListener.h @@ -13,6 +13,7 @@ typedef struct ALlistener_struct volatile ALfloat Velocity[3]; volatile ALfloat Forward[3]; volatile ALfloat Up[3]; + volatile ALfloat Matrix[4][4]; volatile ALfloat Gain; volatile ALfloat MetersPerUnit; } ALlistener; 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); |