diff options
-rw-r--r-- | Alc/ALc.c | 2 | ||||
-rw-r--r-- | Alc/ALu.c | 39 | ||||
-rw-r--r-- | OpenAL32/Include/alListener.h | 5 | ||||
-rw-r--r-- | OpenAL32/alListener.c | 31 |
4 files changed, 42 insertions, 35 deletions
@@ -1818,7 +1818,7 @@ static ALvoid InitContext(ALCcontext *Context) for(i = 0;i < 4;i++) { for(j = 0;j < 4;j++) - Context->Listener->Matrix[i][j] = ((i==j) ? 1.0f : 0.0f); + Context->Listener->Params.Matrix[i][j] = ((i==j) ? 1.0f : 0.0f); } //Validate Context @@ -27,8 +27,6 @@ #include <assert.h> #include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" #include "alSource.h" #include "alBuffer.h" #include "alListener.h" @@ -433,7 +431,7 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext) for(i = 0;i < 4;i++) { for(j = 0;j < 4;j++) - Matrix[i][j] = ALContext->Listener->Matrix[i][j]; + Matrix[i][j] = ALContext->Listener->Params.Matrix[i][j]; } /* Get source properties */ @@ -911,6 +909,41 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) if(!DeferUpdates) UpdateSources = ExchangeInt(&ctx->UpdateSources, AL_FALSE); + if(UpdateSources) + { + ALlistener *listener = ctx->Listener; + ALfloat N[3], V[3], U[3]; + /* AT then UP */ + N[0] = listener->Forward[0]; + N[1] = listener->Forward[1]; + N[2] = listener->Forward[2]; + aluNormalize(N); + V[0] = listener->Up[0]; + V[1] = listener->Up[1]; + V[2] = listener->Up[1]; + aluNormalize(V); + /* Build and normalize right-vector */ + aluCrossproduct(N, V, U); + aluNormalize(U); + + listener->Params.Matrix[0][0] = U[0]; + listener->Params.Matrix[0][1] = V[0]; + listener->Params.Matrix[0][2] = -N[0]; + listener->Params.Matrix[0][3] = 0.0f; + listener->Params.Matrix[1][0] = U[1]; + listener->Params.Matrix[1][1] = V[1]; + listener->Params.Matrix[1][2] = -N[1]; + listener->Params.Matrix[1][3] = 0.0f; + listener->Params.Matrix[2][0] = U[2]; + listener->Params.Matrix[2][1] = V[2]; + listener->Params.Matrix[2][2] = -N[2]; + listener->Params.Matrix[2][3] = 0.0f; + listener->Params.Matrix[3][0] = 0.0f; + listener->Params.Matrix[3][1] = 0.0f; + listener->Params.Matrix[3][2] = 0.0f; + listener->Params.Matrix[3][3] = 1.0f; + } + /* source processing */ src = ctx->ActiveSources; src_end = src + ctx->ActiveSourceCount; diff --git a/OpenAL32/Include/alListener.h b/OpenAL32/Include/alListener.h index 8c5fe734..830b70da 100644 --- a/OpenAL32/Include/alListener.h +++ b/OpenAL32/Include/alListener.h @@ -12,9 +12,12 @@ typedef struct ALlistener { volatile ALfloat Velocity[3]; volatile ALfloat Forward[3]; volatile ALfloat Up[3]; - volatile ALfloat Matrix[4][4]; volatile ALfloat Gain; volatile ALfloat MetersPerUnit; + + struct { + ALfloat Matrix[4][4]; + } Params; } ALlistener; #ifdef __cplusplus diff --git a/OpenAL32/alListener.c b/OpenAL32/alListener.c index f026c8b2..682acbb5 100644 --- a/OpenAL32/alListener.c +++ b/OpenAL32/alListener.c @@ -129,7 +129,6 @@ AL_API ALvoid AL_APIENTRY alListenerfv(ALenum param, const ALfloat *values) al_try { - ALfloat U[3], V[3], N[3]; CHECK_VALUE(Context, values); switch(param) { @@ -138,42 +137,14 @@ AL_API ALvoid AL_APIENTRY alListenerfv(ALenum param, const ALfloat *values) isfinite(values[2]) && isfinite(values[3]) && isfinite(values[4]) && isfinite(values[5])); - /* AT then UP */ - N[0] = values[0]; - N[1] = values[1]; - N[2] = values[2]; - aluNormalize(N); - V[0] = values[3]; - V[1] = values[4]; - V[2] = values[5]; - aluNormalize(V); - /* Build and normalize right-vector */ - aluCrossproduct(N, V, U); - aluNormalize(U); - LockContext(Context); + /* AT then UP */ Context->Listener->Forward[0] = values[0]; Context->Listener->Forward[1] = values[1]; Context->Listener->Forward[2] = values[2]; Context->Listener->Up[0] = values[3]; Context->Listener->Up[1] = values[4]; Context->Listener->Up[2] = values[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); break; |