[Scummvm-git-logs] scummvm master -> 27a7952679596e7f03869814ad0f66947a43a326

aquadran aquadran at gmail.com
Tue Dec 8 18:31:14 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
27a7952679 MATH: make Angle class more robust


Commit: 27a7952679596e7f03869814ad0f66947a43a326
    https://github.com/scummvm/scummvm/commit/27a7952679596e7f03869814ad0f66947a43a326
Author: Christian Krause (chkr at plauener.de)
Date: 2020-12-08T19:30:04+01:00

Commit Message:
MATH: make Angle class more robust

- clamp some intermediate values to the defined range
  which could be slightly violated due to floating point rounding

Changed paths:
    math/vector3d.h


diff --git a/math/vector3d.h b/math/vector3d.h
index 837c89c126..2c5c06cdea 100644
--- a/math/vector3d.h
+++ b/math/vector3d.h
@@ -82,7 +82,7 @@ public:
 	 * @return	The computed angle
 	 */
 	inline static Angle angle(const Vector3d& v1, const Vector3d& v2) {
-		return Angle::arcCosine(dotProduct(v1, v2) / (v1.getMagnitude() * v2.getMagnitude()));
+		return Angle::arcCosine(fminf(fmaxf(dotProduct(v1, v2) / (v1.getMagnitude() * v2.getMagnitude()), -1.0f), 1.0f));
 	}
 
 };




More information about the Scummvm-git-logs mailing list