[PATCH] dsound: Correctly calculate angle between vectors with equal and opposite directions
Andrew Eikum
aeikum at codeweavers.com
Mon Jul 23 12:12:09 CDT 2018
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
---
dlls/dsound/sound3d.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/dlls/dsound/sound3d.c b/dlls/dsound/sound3d.c
index 03fd3d4678..8dafa1dd64 100644
--- a/dlls/dsound/sound3d.c
+++ b/dlls/dsound/sound3d.c
@@ -111,6 +111,13 @@ static inline D3DVALUE AngleBetweenVectorsRad (const D3DVECTOR *a, const D3DVECT
return 0;
cos = product/(la*lb);
+ if(fabs(1 - cos) < 0.0001f){
+ angle = 0;
+ }else if(fabs(-1 - cos) < 0.0001f){
+ angle = M_PI;
+ }else{
+ angle = acos(cos);
+ }
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));
--
2.18.0
More information about the wine-devel
mailing list