Bläddra i källkod

Fixed unit test failure in MSVC 17.10 (#1109)

- Increased tolerance on angle between vectors because MSVC 17.10 produces different results than older versions
- Declaring Squared and other math functions as JPH_INLINE because MSVC wasn't inlining these super simple constexpr functions.
Jorrit Rouwe 1 år sedan
förälder
incheckning
deeb4bca04
2 ändrade filer med 8 tillägg och 8 borttagningar
  1. 6 6
      Jolt/Math/Math.h
  2. 2 2
      UnitTests/Geometry/EPATests.cpp

+ 6 - 6
Jolt/Math/Math.h

@@ -10,13 +10,13 @@ JPH_NAMESPACE_BEGIN
 static constexpr float JPH_PI = 3.14159265358979323846f;
 
 /// Convert a value from degrees to radians
-constexpr float DegreesToRadians(float inV)
+JPH_INLINE constexpr float DegreesToRadians(float inV)
 {
 	return inV * (JPH_PI / 180.0f);
 }
 
 /// Convert a value from radians to degrees
-constexpr float RadiansToDegrees(float inV)
+JPH_INLINE constexpr float RadiansToDegrees(float inV)
 {
 	return inV * (180.0f / JPH_PI);
 }
@@ -42,28 +42,28 @@ inline float CenterAngleAroundZero(float inV)
 
 /// Clamp a value between two values
 template <typename T>
-constexpr T Clamp(T inV, T inMin, T inMax)
+JPH_INLINE constexpr T Clamp(T inV, T inMin, T inMax)
 {
 	return min(max(inV, inMin), inMax);
 }
 
 /// Square a value
 template <typename T>
-constexpr T Square(T inV)
+JPH_INLINE constexpr T Square(T inV)
 {
 	return inV * inV;
 }
 
 /// Returns \f$inV^3\f$.
 template <typename T>
-constexpr T Cubed(T inV)
+JPH_INLINE constexpr T Cubed(T inV)
 {
 	return inV * inV * inV;
 }
 
 /// Get the sign of a value
 template <typename T>
-constexpr T Sign(T inV)
+JPH_INLINE constexpr T Sign(T inV)
 {
 	return inV < 0? T(-1) : T(1);
 }

+ 2 - 2
UnitTests/Geometry/EPATests.cpp

@@ -149,7 +149,7 @@ TEST_SUITE("EPATests")
 		float delta_penetration = (pa - pb).Length() - 2.0f * sphere.GetRadius();
 		CHECK(abs(delta_penetration) < 0.14f);
 		float angle = AngleBetweenVectors(v, pa - pb);
-		CHECK(angle < 1.0e-3f);
+		CHECK(angle < 0.02f);
 	}
 
 	TEST_CASE("TestEPASphereSphereNearOverlapping")
@@ -168,7 +168,7 @@ TEST_SUITE("EPATests")
 		float delta_penetration = (pa - pb).Length() - (sphere1.GetRadius() + sphere2.GetRadius() - (sphere1.GetCenter() - sphere2.GetCenter()).Length());
 		CHECK(abs(delta_penetration) < 0.06f);
 		float angle = AngleBetweenVectors(v, pa - pb);
-		CHECK(angle < 1.0e-3f);
+		CHECK(angle < 0.02f);
 	}
 
 	TEST_CASE("TestEPACastSphereSphereMiss")