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/alListener.c | |
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/alListener.c')
-rw-r--r-- | OpenAL32/alListener.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/OpenAL32/alListener.c b/OpenAL32/alListener.c index 37982b5c..32a12cfb 100644 --- a/OpenAL32/alListener.c +++ b/OpenAL32/alListener.c @@ -142,14 +142,44 @@ AL_API ALvoid AL_APIENTRY alListenerfv(ALenum eParam, const ALfloat *pflValues) isfinite(pflValues[2]) && isfinite(pflValues[3]) && isfinite(pflValues[4]) && isfinite(pflValues[5])) { + ALfloat U[3], V[3], N[3]; + + /* AT then UP */ + N[0] = pflValues[0]; + N[1] = pflValues[1]; + N[2] = pflValues[2]; + aluNormalize(N); + V[0] = pflValues[3]; + V[1] = pflValues[4]; + V[2] = pflValues[5]; + aluNormalize(V); + /* Build and normalize right-vector */ + aluCrossproduct(N, V, U); + aluNormalize(U); + LockContext(Context); - // AT then UP Context->Listener.Forward[0] = pflValues[0]; Context->Listener.Forward[1] = pflValues[1]; Context->Listener.Forward[2] = pflValues[2]; Context->Listener.Up[0] = pflValues[3]; Context->Listener.Up[1] = pflValues[4]; Context->Listener.Up[2] = pflValues[5]; + Context->Listener.Matrix[0][0] = U[0]; + Context->Listener.Matrix[0][1] = V[0]; + Context->Listener.Matrix[0][2] = -N[0]; + Context->Listener.Matrix[0][3] = 0.0f; + Context->Listener.Matrix[1][0] = U[1]; + Context->Listener.Matrix[1][1] = V[1]; + Context->Listener.Matrix[1][2] = -N[1]; + Context->Listener.Matrix[1][3] = 0.0f; + Context->Listener.Matrix[2][0] = U[2]; + Context->Listener.Matrix[2][1] = V[2]; + Context->Listener.Matrix[2][2] = -N[2]; + Context->Listener.Matrix[2][3] = 0.0f; + Context->Listener.Matrix[3][0] = 0.0f; + Context->Listener.Matrix[3][1] = 0.0f; + Context->Listener.Matrix[3][2] = 0.0f; + Context->Listener.Matrix[3][3] = 1.0f; Context->UpdateSources = AL_TRUE; UnlockContext(Context); } |