summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2008-01-15 21:23:14 -0800
committerChris Robinson <[email protected]>2008-01-15 21:23:14 -0800
commitabc69dd3d044fb5370b0a9afee05c3f2b9e79c21 (patch)
tree4eddf62618a2cc6dc88cb0d30987cdb9a64a78eb
parentbf87aed459a2546bcc8762dd8a849485690ffd89 (diff)
Use acosf when available
-rw-r--r--Alc/ALu.c9
-rw-r--r--CMakeLists.txt3
-rw-r--r--config.h.in3
3 files changed, 13 insertions, 2 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 3e9387bb..22f3ad12 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -49,6 +49,12 @@ typedef long long ALint64;
#define aluSqrt(x) ((ALfloat)sqrt((double)(x)))
#endif
+#ifdef HAVE_ACOSF
+#define aluAcos(x) ((ALfloat)acosf((float)(x)))
+#else
+#define aluAcos(x) ((ALfloat)acos((double)(x)))
+#endif
+
// fixes for mingw32.
#if defined(max) && !defined(__max)
#define __max max
@@ -390,7 +396,8 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource,
SourceToListener[2] = -Position[2];
aluNormalize(Direction);
aluNormalize(SourceToListener);
- Angle = (ALfloat)(180.0*acos(aluDotproduct(Direction,SourceToListener))/3.141592654f);
+ Angle = aluAcos(aluDotproduct(Direction,SourceToListener)) * 180.0f /
+ 3.141592654f;
if(Angle >= InnerAngle && Angle <= OuterAngle)
{
ALfloat scale = (Angle-InnerAngle) / (OuterAngle-InnerAngle);
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ff74f23d..056b6fdd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -101,7 +101,8 @@ ENDIF()
CHECK_LIBRARY_EXISTS(m sqrtf "" HAVE_SQRTF)
-IF(HAVE_SQRTF)
+CHECK_LIBRARY_EXISTS(m acosf "" HAVE_ACOSF)
+IF(HAVE_SQRTF OR HAVE_ACOSF)
SET(EXTRA_LIBS m ${EXTRA_LIBS})
ENDIF()
CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
diff --git a/config.h.in b/config.h.in
index 931d16ae..5890b6fd 100644
--- a/config.h.in
+++ b/config.h.in
@@ -19,6 +19,9 @@
/* Define if we have the sqrtf function */
#cmakedefine HAVE_SQRTF
+/* Define if we have the acosf function */
+#cmakedefine HAVE_ACOSF
+
/* Define if we have the strtof function */
#cmakedefine HAVE_STRTOF