aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALu.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-06-28 17:26:00 -0700
committerChris Robinson <[email protected]>2012-06-28 17:26:00 -0700
commitbc6751237c7cdd0277bd0dc864a207f200258201 (patch)
tree975e93be301997747bcdd095340e8f19b76f870a /Alc/ALu.c
parent6f3be31b607b76add84ae835e422c3314bc82a8b (diff)
Clamp the Y position before trying to get the elevation
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r--Alc/ALu.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index d3965dfd..7fac1771 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -677,8 +677,9 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
/* Calculate elevation and azimuth only when the source is not at
* the listener. This prevents +0 and -0 Z from producing
- * inconsistent panning. */
- ev = aluAsin(Position[1]);
+ * inconsistent panning. Also, clamp Y in case FP precision errors
+ * cause it to land outside of -1..+1. */
+ ev = aluAsin(clampf(Position[1], -1.0f, 1.0f));
az = aluAtan2(Position[0], -Position[2]*ZScale);
}