diff options
author | Chris Robinson <[email protected]> | 2015-11-11 08:19:33 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2015-11-11 08:19:33 -0800 |
commit | 5d039309b355c350fd087a48c4b896d31871d174 (patch) | |
tree | dc47089479cadef370435273fbfe18fed5d6dd0e /OpenAL32 | |
parent | ff62d22d3178ce640966f0fc1ff44d53cb98391a (diff) |
Use doubles for the constructed listener matrix
This helps the stability of transforms to local space for sources that are at
or near the listener. With a single-precision matrix, even FLT_EPSILON might
not be enough to detect matching positions.
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/Include/alListener.h | 4 | ||||
-rw-r--r-- | OpenAL32/Include/alu.h | 49 |
2 files changed, 39 insertions, 14 deletions
diff --git a/OpenAL32/Include/alListener.h b/OpenAL32/Include/alListener.h index 42b5a11f..c9bd9be0 100644 --- a/OpenAL32/Include/alListener.h +++ b/OpenAL32/Include/alListener.h @@ -17,8 +17,8 @@ typedef struct ALlistener { volatile ALfloat MetersPerUnit; struct { - aluMatrix Matrix; - aluVector Velocity; + aluMatrixd Matrix; + aluVector Velocity; } Params; } ALlistener; diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index 0832fbfb..a309c4ab 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -72,12 +72,12 @@ inline void aluVectorSet(aluVector *vector, ALfloat x, ALfloat y, ALfloat z, ALf } -typedef union aluMatrix { +typedef union aluMatrixf { alignas(16) ALfloat m[4][4]; -} aluMatrix; +} aluMatrixf; -inline void aluMatrixSetRow(aluMatrix *matrix, ALuint row, - ALfloat m0, ALfloat m1, ALfloat m2, ALfloat m3) +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; @@ -85,15 +85,40 @@ inline void aluMatrixSetRow(aluMatrix *matrix, ALuint row, matrix->m[row][3] = m3; } -inline void aluMatrixSet(aluMatrix *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) +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) { - aluMatrixSetRow(matrix, 0, m00, m01, m02, m03); - aluMatrixSetRow(matrix, 1, m10, m11, m12, m13); - aluMatrixSetRow(matrix, 2, m20, m21, m22, m23); - aluMatrixSetRow(matrix, 3, m30, m31, m32, 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); +} + + +typedef union aluMatrixd { + alignas(16) ALdouble m[4][4]; +} aluMatrixd; + +inline void aluMatrixdSetRow(aluMatrixd *matrix, ALuint row, + ALdouble m0, ALdouble m1, ALdouble m2, ALdouble m3) +{ + matrix->m[row][0] = m0; + matrix->m[row][1] = m1; + matrix->m[row][2] = m2; + matrix->m[row][3] = m3; +} + +inline void aluMatrixdSet(aluMatrixd *matrix, ALdouble m00, ALdouble m01, ALdouble m02, ALdouble m03, + ALdouble m10, ALdouble m11, ALdouble m12, ALdouble m13, + ALdouble m20, ALdouble m21, ALdouble m22, ALdouble m23, + ALdouble m30, ALdouble m31, ALdouble m32, ALdouble m33) +{ + aluMatrixdSetRow(matrix, 0, m00, m01, m02, m03); + aluMatrixdSetRow(matrix, 1, m10, m11, m12, m13); + aluMatrixdSetRow(matrix, 2, m20, m21, m22, m23); + aluMatrixdSetRow(matrix, 3, m30, m31, m32, m33); } |