diff options
author | Chris Robinson <[email protected]> | 2018-11-17 23:21:37 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-17 23:21:37 -0800 |
commit | e79d9bdd1a6aa6d6d9852bf5a380a8cd01cbc315 (patch) | |
tree | d0c7be1efda1c2c72f035d5b8be5e942d70b8908 | |
parent | fa3c34268dd7d9bc380ecd19aedb28924d29b295 (diff) |
Move the vector and matrix declarations to a separate header
-rw-r--r-- | Alc/alc.cpp | 2 | ||||
-rw-r--r-- | Alc/alu.cpp | 7 | ||||
-rw-r--r-- | Alc/effects/autowah.cpp | 3 | ||||
-rw-r--r-- | Alc/effects/compressor.cpp | 4 | ||||
-rw-r--r-- | Alc/effects/equalizer.cpp | 3 | ||||
-rw-r--r-- | Alc/effects/modulator.cpp | 3 | ||||
-rw-r--r-- | Alc/effects/reverb.cpp | 1 | ||||
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | OpenAL32/Include/alListener.h | 23 | ||||
-rw-r--r-- | OpenAL32/Include/alu.h | 39 | ||||
-rw-r--r-- | common/vecmat.cpp | 12 | ||||
-rw-r--r-- | common/vecmat.h | 46 |
12 files changed, 81 insertions, 64 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp index ec9a0adf..daa0818d 100644 --- a/Alc/alc.cpp +++ b/Alc/alc.cpp @@ -2658,7 +2658,7 @@ static ALvoid InitContext(ALCcontext *Context) Context->ExtensionList = alExtList; - listener->Params.Matrix = IdentityMatrixf; + listener->Params.Matrix = aluMatrixf::Identity; aluVectorSet(&listener->Params.Velocity, 0.0f, 0.0f, 0.0f, 0.0f); listener->Params.Gain = listener->Gain; listener->Params.MetersPerUnit = Context->MetersPerUnit; diff --git a/Alc/alu.cpp b/Alc/alu.cpp index 1895b777..2a6dcfe0 100644 --- a/Alc/alu.cpp +++ b/Alc/alu.cpp @@ -56,13 +56,6 @@ ALfloat ZScale = 1.0f; /* Force default speed of sound for distance-related reverb decay. */ ALboolean OverrideReverbSpeedOfSound = AL_FALSE; -const aluMatrixf IdentityMatrixf = {{ - { 1.0f, 0.0f, 0.0f, 0.0f }, - { 0.0f, 1.0f, 0.0f, 0.0f }, - { 0.0f, 0.0f, 1.0f, 0.0f }, - { 0.0f, 0.0f, 0.0f, 1.0f }, -}}; - static void ClearArray(ALfloat f[MAX_OUTPUT_CHANNELS]) { diff --git a/Alc/effects/autowah.cpp b/Alc/effects/autowah.cpp index e2f07b6f..a8e4fe6e 100644 --- a/Alc/effects/autowah.cpp +++ b/Alc/effects/autowah.cpp @@ -29,6 +29,7 @@ #include "alError.h" #include "alu.h" #include "filters/defs.h" +#include "vecmat.h" #define MIN_FREQ 20.0f #define MAX_FREQ 2500.0f @@ -131,7 +132,7 @@ static ALvoid ALautowahState_update(ALautowahState *state, const ALCcontext *con STATIC_CAST(ALeffectState,state)->OutBuffer = device->FOAOut.Buffer; STATIC_CAST(ALeffectState,state)->OutChannels = device->FOAOut.NumChannels; for(i = 0;i < MAX_EFFECT_CHANNELS;i++) - ComputePanGains(&device->FOAOut, IdentityMatrixf.m[i], slot->Params.Gain, + ComputePanGains(&device->FOAOut, aluMatrixf::Identity.m[i], slot->Params.Gain, state->Chans[i].TargetGains); } diff --git a/Alc/effects/compressor.cpp b/Alc/effects/compressor.cpp index 5603deea..464e98ec 100644 --- a/Alc/effects/compressor.cpp +++ b/Alc/effects/compressor.cpp @@ -27,6 +27,7 @@ #include "alu.h" #include "alAuxEffectSlot.h" #include "alError.h" +#include "vecmat.h" #define AMP_ENVELOPE_MIN 0.5f @@ -101,7 +102,8 @@ static ALvoid ALcompressorState_update(ALcompressorState *state, const ALCcontex STATIC_CAST(ALeffectState,state)->OutBuffer = device->FOAOut.Buffer; STATIC_CAST(ALeffectState,state)->OutChannels = device->FOAOut.NumChannels; for(i = 0;i < 4;i++) - ComputePanGains(&device->FOAOut, IdentityMatrixf.m[i], slot->Params.Gain, state->Gain[i]); + ComputePanGains(&device->FOAOut, aluMatrixf::Identity.m[i], slot->Params.Gain, + state->Gain[i]); } static ALvoid ALcompressorState_process(ALcompressorState *state, ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels) diff --git a/Alc/effects/equalizer.cpp b/Alc/effects/equalizer.cpp index 48c6d1e2..e8d50fad 100644 --- a/Alc/effects/equalizer.cpp +++ b/Alc/effects/equalizer.cpp @@ -29,6 +29,7 @@ #include "alError.h" #include "alu.h" #include "filters/defs.h" +#include "vecmat.h" /* The document "Effects Extension Guide.pdf" says that low and high * @@ -173,7 +174,7 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCcontext STATIC_CAST(ALeffectState,state)->OutBuffer = device->FOAOut.Buffer; STATIC_CAST(ALeffectState,state)->OutChannels = device->FOAOut.NumChannels; for(i = 0;i < MAX_EFFECT_CHANNELS;i++) - ComputePanGains(&device->FOAOut, IdentityMatrixf.m[i], slot->Params.Gain, + ComputePanGains(&device->FOAOut, aluMatrixf::Identity.m[i], slot->Params.Gain, state->Chans[i].TargetGains); } diff --git a/Alc/effects/modulator.cpp b/Alc/effects/modulator.cpp index 7e8f8ce4..9790af79 100644 --- a/Alc/effects/modulator.cpp +++ b/Alc/effects/modulator.cpp @@ -29,6 +29,7 @@ #include "alError.h" #include "alu.h" #include "filters/defs.h" +#include "vecmat.h" #define MAX_UPDATE_SAMPLES 128 @@ -159,7 +160,7 @@ static ALvoid ALmodulatorState_update(ALmodulatorState *state, const ALCcontext STATIC_CAST(ALeffectState,state)->OutBuffer = device->FOAOut.Buffer; STATIC_CAST(ALeffectState,state)->OutChannels = device->FOAOut.NumChannels; for(i = 0;i < MAX_EFFECT_CHANNELS;i++) - ComputePanGains(&device->FOAOut, IdentityMatrixf.m[i], slot->Params.Gain, + ComputePanGains(&device->FOAOut, aluMatrixf::Identity.m[i], slot->Params.Gain, state->Chans[i].TargetGains); } diff --git a/Alc/effects/reverb.cpp b/Alc/effects/reverb.cpp index fe9cc9f7..ebb9b7da 100644 --- a/Alc/effects/reverb.cpp +++ b/Alc/effects/reverb.cpp @@ -31,6 +31,7 @@ #include "alListener.h" #include "alError.h" #include "filters/defs.h" +#include "vecmat.h" /* This is a user config option for modifying the overall output of the reverb * effect. diff --git a/CMakeLists.txt b/CMakeLists.txt index e81dc403..476b241f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -710,6 +710,8 @@ SET(COMMON_OBJS common/threads.cpp common/threads.h common/uintmap.h + common/vecmat.cpp + common/vecmat.h ) SET(OPENAL_OBJS OpenAL32/Include/bs2b.h diff --git a/OpenAL32/Include/alListener.h b/OpenAL32/Include/alListener.h index 33dea4f3..ec6ee509 100644 --- a/OpenAL32/Include/alListener.h +++ b/OpenAL32/Include/alListener.h @@ -1,12 +1,13 @@ #ifndef _AL_LISTENER_H_ #define _AL_LISTENER_H_ -#include "alMain.h" -#include "alu.h" +#include "AL/alc.h" +#include "AL/al.h" +#include "AL/alext.h" + +#include "atomic.h" +#include "vecmat.h" -#ifdef __cplusplus -extern "C" { -#endif struct ALlistenerProps { ALfloat Position[3]; @@ -15,10 +16,10 @@ struct ALlistenerProps { ALfloat Up[3]; ALfloat Gain; - ATOMIC(struct ALlistenerProps*) next; + ATOMIC(ALlistenerProps*) next; }; -typedef struct ALlistener { +struct ALlistener { alignas(16) ALfloat Position[3]; ALfloat Velocity[3]; ALfloat Forward[3]; @@ -29,7 +30,7 @@ typedef struct ALlistener { /* Pointer to the most recent property values that are awaiting an update. */ - ATOMIC(struct ALlistenerProps*) Update; + ATOMIC(ALlistenerProps*) Update; struct { aluMatrixf Matrix; @@ -45,12 +46,8 @@ typedef struct ALlistener { ALboolean SourceDistanceModel; enum DistanceModel DistanceModel; } Params; -} ALlistener; +}; void UpdateListenerProps(ALCcontext *context); -#ifdef __cplusplus -} -#endif - #endif diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index 7031df70..d309c2a7 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -98,45 +98,6 @@ extern const struct BSincTable bsinc12; extern const struct BSincTable bsinc24; -typedef union aluVector { - alignas(16) ALfloat v[4]; -} aluVector; - -inline void aluVectorSet(aluVector *vector, ALfloat x, ALfloat y, ALfloat z, ALfloat w) -{ - vector->v[0] = x; - vector->v[1] = y; - vector->v[2] = z; - vector->v[3] = w; -} - - -typedef union aluMatrixf { - alignas(16) ALfloat m[4][4]; -} aluMatrixf; -extern const aluMatrixf IdentityMatrixf; - -inline void aluMatrixfSetRow(aluMatrixf *matrix, ALuint row, - ALfloat m0, ALfloat m1, ALfloat m2, ALfloat m3) -{ - matrix->m[row][0] = m0; - matrix->m[row][1] = m1; - matrix->m[row][2] = m2; - matrix->m[row][3] = m3; -} - -inline void aluMatrixfSet(aluMatrixf *matrix, ALfloat m00, ALfloat m01, ALfloat m02, ALfloat m03, - ALfloat m10, ALfloat m11, ALfloat m12, ALfloat m13, - ALfloat m20, ALfloat m21, ALfloat m22, ALfloat m23, - ALfloat m30, ALfloat m31, ALfloat m32, ALfloat m33) -{ - aluMatrixfSetRow(matrix, 0, m00, m01, m02, m03); - aluMatrixfSetRow(matrix, 1, m10, m11, m12, m13); - aluMatrixfSetRow(matrix, 2, m20, m21, m22, m23); - aluMatrixfSetRow(matrix, 3, m30, m31, m32, m33); -} - - enum { AF_None = 0, AF_LowPass = 1, diff --git a/common/vecmat.cpp b/common/vecmat.cpp new file mode 100644 index 00000000..ccb9ad9f --- /dev/null +++ b/common/vecmat.cpp @@ -0,0 +1,12 @@ + +#include "config.h" + +#include "vecmat.h" + + +const aluMatrixf aluMatrixf::Identity{{ + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f, 1.0f }, +}}; diff --git a/common/vecmat.h b/common/vecmat.h new file mode 100644 index 00000000..0a60cb9e --- /dev/null +++ b/common/vecmat.h @@ -0,0 +1,46 @@ +#ifndef COMMON_VECMAT_H +#define COMMON_VECMAT_H + +#include "AL/al.h" + + +struct aluVector { + alignas(16) ALfloat v[4]; +}; + +inline void aluVectorSet(aluVector *vector, ALfloat x, ALfloat y, ALfloat z, ALfloat w) +{ + vector->v[0] = x; + vector->v[1] = y; + vector->v[2] = z; + vector->v[3] = w; +} + + +struct aluMatrixf { + alignas(16) ALfloat m[4][4]; + + static const aluMatrixf Identity; +}; + +inline void aluMatrixfSetRow(aluMatrixf *matrix, ALuint row, + ALfloat m0, ALfloat m1, ALfloat m2, ALfloat m3) +{ + matrix->m[row][0] = m0; + matrix->m[row][1] = m1; + matrix->m[row][2] = m2; + matrix->m[row][3] = m3; +} + +inline void aluMatrixfSet(aluMatrixf *matrix, ALfloat m00, ALfloat m01, ALfloat m02, ALfloat m03, + ALfloat m10, ALfloat m11, ALfloat m12, ALfloat m13, + ALfloat m20, ALfloat m21, ALfloat m22, ALfloat m23, + ALfloat m30, ALfloat m31, ALfloat m32, ALfloat m33) +{ + aluMatrixfSetRow(matrix, 0, m00, m01, m02, m03); + aluMatrixfSetRow(matrix, 1, m10, m11, m12, m13); + aluMatrixfSetRow(matrix, 2, m20, m21, m22, m23); + aluMatrixfSetRow(matrix, 3, m30, m31, m32, m33); +} + +#endif /* COMMON_VECMAT_H */ |