Browse Source

Removed the use of `std::uniform_real_distribution` (#1350)

When going from MSVC 19.41.34123.0 -> 19.42.34433.0 it started to generate different numbers between Windows and Linux, causing the cross platform determinism check to start failing. On Linux, std::uniform_real_distribution is implemented using doubles and on Windows it is not. Removed the use of random from this test.

Fixes #1345
Jorrit Rouwe 9 months ago
parent
commit
48b664bde5

+ 7 - 9
.github/workflows/determinism_check.yml

@@ -2,7 +2,7 @@ name: Determinism Check
 
 
 env:
 env:
   CONVEX_VS_MESH_HASH: '0x16ca5bf7f9da5f74'
   CONVEX_VS_MESH_HASH: '0x16ca5bf7f9da5f74'
-  RAGDOLL_HASH: '0xf33d6c177e59f69'
+  RAGDOLL_HASH: '0xa50ce2dc5684626d'
   EMSCRIPTEN_VERSION: 3.1.64
   EMSCRIPTEN_VERSION: 3.1.64
   UBUNTU_CLANG_VERSION: clang++-15
   UBUNTU_CLANG_VERSION: clang++-15
   UBUNTU_GCC_VERSION: g++-12
   UBUNTU_GCC_VERSION: g++-12
@@ -85,10 +85,9 @@ jobs:
     - name: Test ConvexVsMesh
     - name: Test ConvexVsMesh
       working-directory: ${{github.workspace}}/Build/VS2022_CL/Distribution
       working-directory: ${{github.workspace}}/Build/VS2022_CL/Distribution
       run: ./PerformanceTest -q=LinearCast -t=max -s=ConvexVsMesh "-validate_hash=$env:CONVEX_VS_MESH_HASH"
       run: ./PerformanceTest -q=LinearCast -t=max -s=ConvexVsMesh "-validate_hash=$env:CONVEX_VS_MESH_HASH"
-    # Temporarily disabling the Ragdoll check since it fails since upgrading from MSVC 19.41.34123.0 -> 19.42.34433.0
-    #- name: Test Ragdoll
-    #  working-directory: ${{github.workspace}}/Build/VS2022_CL/Distribution
-    #  run: ./PerformanceTest -q=LinearCast -t=max -s=Ragdoll "-validate_hash=$env:RAGDOLL_HASH"
+    - name: Test Ragdoll
+      working-directory: ${{github.workspace}}/Build/VS2022_CL/Distribution
+      run: ./PerformanceTest -q=LinearCast -t=max -s=Ragdoll "-validate_hash=$env:RAGDOLL_HASH"
 
 
   msvc_cl_32:
   msvc_cl_32:
     runs-on: windows-latest
     runs-on: windows-latest
@@ -110,10 +109,9 @@ jobs:
     - name: Test ConvexVsMesh
     - name: Test ConvexVsMesh
       working-directory: ${{github.workspace}}/Build/VS2022_CL_32BIT/Distribution
       working-directory: ${{github.workspace}}/Build/VS2022_CL_32BIT/Distribution
       run: ./PerformanceTest -q=LinearCast -t=max -s=ConvexVsMesh "-validate_hash=$env:CONVEX_VS_MESH_HASH"
       run: ./PerformanceTest -q=LinearCast -t=max -s=ConvexVsMesh "-validate_hash=$env:CONVEX_VS_MESH_HASH"
-    # Temporarily disabling the Ragdoll check since it fails since upgrading from MSVC 19.41.34123.0 -> 19.42.34433.0
-    #- name: Test Ragdoll
-    #  working-directory: ${{github.workspace}}/Build/VS2022_CL_32BIT/Distribution
-    #  run: ./PerformanceTest -q=LinearCast -t=max -s=Ragdoll "-validate_hash=$env:RAGDOLL_HASH"
+    - name: Test Ragdoll
+      working-directory: ${{github.workspace}}/Build/VS2022_CL_32BIT/Distribution
+      run: ./PerformanceTest -q=LinearCast -t=max -s=Ragdoll "-validate_hash=$env:RAGDOLL_HASH"
 
 
   macos:
   macos:
     runs-on: macos-latest
     runs-on: macos-latest

+ 10 - 0
Build/cmake_vs2022_clang_cross_platform_deterministic.bat

@@ -0,0 +1,10 @@
+@echo off
+cmake -S . -B VS2022_Clang_CPD -G "Visual Studio 17 2022" -A x64 -T ClangCL -DCROSS_PLATFORM_DETERMINISTIC=ON %*
+echo:
+echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+echo Make sure to install:
+echo - C++ Clang Compiler for Windows 12.0.0+
+echo - C++ Clang-cl for v143+ build tools (x64/x86)
+echo Using the Visual Studio Installer
+echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+echo Open VS2022_Clang_CPD/JoltPhysics.sln to build the project.

+ 2 - 3
PerformanceTest/RagdollScene.h

@@ -82,8 +82,6 @@ public:
 		mBackground->CreateBodies(&inPhysicsSystem);
 		mBackground->CreateBodies(&inPhysicsSystem);
 
 
 		// Create ragdoll piles
 		// Create ragdoll piles
-		mt19937 random;
-		uniform_real_distribution<float> angle(0.0f, JPH_PI);
 		CollisionGroup::GroupID group_id = 1;
 		CollisionGroup::GroupID group_id = 1;
 		for (int row = 0; row < mNumPilesPerAxis; ++row)
 		for (int row = 0; row < mNumPilesPerAxis; ++row)
 			for (int col = 0; col < mNumPilesPerAxis; ++col)
 			for (int col = 0; col < mNumPilesPerAxis; ++col)
@@ -108,7 +106,8 @@ public:
 					pose_copy.SetRootOffset(start);
 					pose_copy.SetRootOffset(start);
 					SkeletonPose::JointState &root = pose_copy.GetJoint(0);
 					SkeletonPose::JointState &root = pose_copy.GetJoint(0);
 					root.mTranslation = Vec3(0, mVerticalSeparation * (i + 1), 0);
 					root.mTranslation = Vec3(0, mVerticalSeparation * (i + 1), 0);
-					root.mRotation = Quat::sRotation(Vec3::sAxisY(), angle(random)) * root.mRotation;
+					float angle = 2.0f * JPH_PI * float(i) / float(mPileSize);
+					root.mRotation = Quat::sRotation(Vec3::sAxisY(), angle) * root.mRotation;
 					pose_copy.CalculateJointMatrices();
 					pose_copy.CalculateJointMatrices();
 
 
 					// Drive to pose
 					// Drive to pose