2
0
Эх сурвалжийг харах

Fixed random generator in two instances

* Unit tests should use UnitTestRandom
* MutableCompoundShapeTest seeded the random number generator every frame, but some platforms (macOS/Linux) return the seed as the first random value
Jorrit Rouwe 7 сар өмнө
parent
commit
5addcb464a

+ 2 - 1
Samples/Tests/Shapes/MutableCompoundShapeTest.cpp

@@ -86,7 +86,8 @@ void MutableCompoundShapeTest::PrePhysicsUpdate(const PreUpdateParams &inParams)
 			shape->ModifyShapes(0, count, &pos_rot.front().mPosition, &pos_rot.front().mRotation, sizeof(PositionRotation), sizeof(PositionRotation));
 
 			// Initialize frame dependent random number generator
-			default_random_engine frame_random(mFrameNumber++);
+			// Note: Explicitly using the Mersenne Twister random generator as on some platforms you get the seed back as the first random number
+			mt19937 frame_random(mFrameNumber++);
 
 			// Roll the dice
 			float roll = roll_distribution(frame_random);

+ 1 - 1
UnitTests/Math/EigenValueSymmetricTests.cpp

@@ -10,7 +10,7 @@ TEST_SUITE("EigenValueSymmetricTests")
 {
 	TEST_CASE("TestEigenValueSymmetric")
 	{
-		default_random_engine random;
+		UnitTestRandom random;
 		uniform_real_distribution<float> angle_distribution(0, 2.0f * JPH_PI);
 		uniform_real_distribution<float> scale_distribution(0.1f, 10.0f);