From 469c497849ab12e1a18484254ee49825e145a5b3 Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Tue, 24 Jul 2018 11:05:06 -0500 Subject: [PATCH] dsound: Correctly calculate angle between vectors with equal and opposite directions. Signed-off-by: Andrew Eikum Signed-off-by: Alexandre Julliard --- dlls/dsound/sound3d.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dlls/dsound/sound3d.c b/dlls/dsound/sound3d.c index 03fd3d46782..118bb604565 100644 --- a/dlls/dsound/sound3d.c +++ b/dlls/dsound/sound3d.c @@ -111,7 +111,13 @@ static inline D3DVALUE AngleBetweenVectorsRad (const D3DVECTOR *a, const D3DVECT return 0; cos = product/(la*lb); - angle = acos(cos); + if(cos > 1.f){ + angle = 0; + }else if(cos < -1.f){ + angle = M_PI; + }else{ + angle = acos(cos); + } TRACE("angle between (%f,%f,%f) and (%f,%f,%f) = %f radians (%f degrees)\n", a->x, a->y, a->z, b->x, b->y, b->z, angle, RadToDeg(angle)); return angle;