Skip to content

Commit

Permalink
Fixed random generator in two instances
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jrouwe committed Jan 13, 2025
1 parent cb3f34f commit 5addcb4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Samples/Tests/Shapes/MutableCompoundShapeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion UnitTests/Math/EigenValueSymmetricTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 5addcb4

Please sign in to comment.