Procházet zdrojové kódy

Changed shape and body user data to uint64 (#50)

Fixes #48
Jorrit Rouwe před 3 roky
rodič
revize
14e062ac96
32 změnil soubory, kde provedl 77 přidání a 57 odebrání
  1. 4 4
      .github/workflows/build.yml
  2. 2 2
      HelloWorld/HelloWorld.cpp
  3. 4 4
      Jolt/Physics/Body/Body.h
  4. 2 2
      Jolt/Physics/Body/BodyActivationListener.h
  5. 1 0
      Jolt/Physics/Body/BodyCreationSettings.cpp
  6. 3 0
      Jolt/Physics/Body/BodyCreationSettings.h
  7. 2 2
      Jolt/Physics/Body/BodyInterface.cpp
  8. 1 1
      Jolt/Physics/Body/BodyInterface.h
  9. 1 0
      Jolt/Physics/Body/BodyManager.cpp
  10. 3 4
      Jolt/Physics/Character/Character.cpp
  11. 4 4
      Jolt/Physics/Character/Character.h
  12. 1 1
      Jolt/Physics/Collision/Shape/CompoundShape.cpp
  13. 5 5
      Jolt/Physics/Collision/Shape/CompoundShape.h
  14. 1 1
      Jolt/Physics/Collision/Shape/DecoratedShape.cpp
  15. 1 1
      Jolt/Physics/Collision/Shape/DecoratedShape.h
  16. 5 5
      Jolt/Physics/Collision/Shape/Shape.h
  17. 1 1
      Jolt/Physics/Collision/TransformedShape.h
  18. 1 1
      Jolt/Physics/Ragdoll/Ragdoll.cpp
  19. 1 1
      Jolt/Physics/Ragdoll/Ragdoll.h
  20. 1 1
      PerformanceTest/RagdollScene.h
  21. 1 1
      Samples/Tests/Character/CharacterTest.cpp
  22. 1 1
      Samples/Tests/General/MultithreadedTest.cpp
  23. 1 1
      Samples/Tests/General/SensorTest.cpp
  24. 2 2
      Samples/Tests/General/SimpleTest.h
  25. 1 1
      Samples/Tests/Rig/KinematicRigTest.cpp
  26. 1 1
      Samples/Tests/Rig/LoadRigTest.cpp
  27. 1 1
      Samples/Tests/Rig/LoadSaveBinaryRigTest.cpp
  28. 1 1
      Samples/Tests/Rig/PoweredRigTest.cpp
  29. 1 1
      Samples/Tests/Rig/RigPileTest.cpp
  30. 2 2
      UnitTests/LoggingBodyActivationListener.h
  31. 16 0
      UnitTests/Physics/PhysicsTests.cpp
  32. 5 5
      UnitTests/Physics/ShapeTests.cpp

+ 4 - 4
.github/workflows/build.yml

@@ -47,13 +47,13 @@ jobs:
     - name: Checkout Code
       uses: actions/checkout@v2
     - name: Add msbuild to PATH
-      uses: microsoft/setup-msbuild@v1.0.2
+      uses: microsoft/setup-msbuild@v1.1
     - name: Configure CMake
-      run: cmake -B ${{github.workspace}}/Build/VS2019_CL -G "Visual Studio 16 2019" -A x64 Build
+      run: cmake -B ${{github.workspace}}/Build/VS2022_CL -G "Visual Studio 17 2022" -A x64 Build
     - name: Build
-      run: msbuild Build\VS2019_CL\JoltPhysics.sln /property:Configuration=${{matrix.build_type}}
+      run: msbuild Build\VS2022_CL\JoltPhysics.sln /property:Configuration=${{matrix.build_type}}
     - name: Test
-      working-directory: ${{github.workspace}}/Build/VS2019_CL/${{matrix.build_type}}
+      working-directory: ${{github.workspace}}/Build/VS2022_CL/${{matrix.build_type}}
       run: ./UnitTests.exe
 
   android:

+ 2 - 2
HelloWorld/HelloWorld.cpp

@@ -139,12 +139,12 @@ public:
 class MyBodyActivationListener : public BodyActivationListener
 {
 public:
-	virtual void		OnBodyActivated(const BodyID &inBodyID, void *inBodyUserData) override
+	virtual void		OnBodyActivated(const BodyID &inBodyID, uint64 inBodyUserData) override
 	{
 		cout << "A body got activated" << endl;
 	}
 
-	virtual void		OnBodyDeactivated(const BodyID &inBodyID, void *inBodyUserData) override
+	virtual void		OnBodyDeactivated(const BodyID &inBodyID, uint64 inBodyUserData) override
 	{
 		cout << "A body went to sleep" << endl;
 	}

+ 4 - 4
Jolt/Physics/Body/Body.h

@@ -182,9 +182,9 @@ public:
 	const MotionProperties *GetMotionPropertiesUnchecked() const							{ return mMotionProperties; }
 	MotionProperties *		GetMotionPropertiesUnchecked()									{ return mMotionProperties; }
 
-	/// Access to the user data pointer
-	void *					GetUserData() const												{ return mUserData; }
-	void					SetUserData(void *inUserData)									{ mUserData = inUserData; }
+	/// Access to the user data, can be used for anything by the application
+	uint64					GetUserData() const												{ return mUserData; }
+	void					SetUserData(uint64 inUserData)									{ mUserData = inUserData; }
 
 	/// Get surface normal of a particular sub shape and its world space surface position on this body
 	inline Vec3				GetWorldSpaceSurfaceNormal(const SubShapeID &inSubShapeID, Vec3Arg inPosition) const;
@@ -286,7 +286,7 @@ private:
 	// 8 byte aligned
 	RefConst<Shape>			mShape;															///< Shape representing the volume of this body
 	MotionProperties *		mMotionProperties = nullptr;									///< If this is a keyframed or dynamic object, this object holds all information about the movement
-	void *					mUserData = nullptr;											///< User data pointer, can be used for anything by the application
+	uint64					mUserData = 0;													///< User data, can be used for anything by the application
 	CollisionGroup			mCollisionGroup;												///< The collision group this body belongs to (determines if two objects can collide)
 
 	// 4 byte aligned

+ 2 - 2
Jolt/Physics/Body/BodyActivationListener.h

@@ -17,11 +17,11 @@ public:
 
 	/// Called whenever a body activates, note this can be called from any thread so make sure your code is thread safe.
 	/// At the time of the callback the body inBodyID will be locked and no bodies can be activated/deactivated from the callback.
-	virtual void			OnBodyActivated(const BodyID &inBodyID, void *inBodyUserData) = 0;
+	virtual void			OnBodyActivated(const BodyID &inBodyID, uint64 inBodyUserData) = 0;
 
 	/// Called whenever a body deactivates, note this can be called from any thread so make sure your code is thread safe.
 	/// At the time of the callback the body inBodyID will be locked and no bodies can be activated/deactivated from the callback.
-	virtual void			OnBodyDeactivated(const BodyID &inBodyID, void *inBodyUserData) = 0;
+	virtual void			OnBodyDeactivated(const BodyID &inBodyID, uint64 inBodyUserData) = 0;
 };
 
 } // JPH

+ 1 - 0
Jolt/Physics/Body/BodyCreationSettings.cpp

@@ -14,6 +14,7 @@ JPH_IMPLEMENT_SERIALIZABLE_NON_VIRTUAL(BodyCreationSettings)
 {
 	JPH_ADD_ATTRIBUTE(BodyCreationSettings, mPosition)
 	JPH_ADD_ATTRIBUTE(BodyCreationSettings, mRotation)
+	JPH_ADD_ATTRIBUTE(BodyCreationSettings, mUserData)
 	JPH_ADD_ATTRIBUTE(BodyCreationSettings, mShape)
 	JPH_ADD_ATTRIBUTE(BodyCreationSettings, mCollisionGroup)
 	JPH_ADD_ENUM_ATTRIBUTE(BodyCreationSettings, mObjectLayer)

+ 3 - 0
Jolt/Physics/Body/BodyCreationSettings.h

@@ -80,6 +80,9 @@ public:
 	/// Rotation of the body
 	Quat					mRotation = Quat::sIdentity();
 
+	/// User data value (can be used by application)
+	uint64					mUserData = 0;
+
 	///@name Collision settings
 	ObjectLayer				mObjectLayer = 0;												///< The collision layer this body belongs to (determines if two objects can collide)
 	CollisionGroup			mCollisionGroup;												///< The collision group this body belongs to (determines if two objects can collide)

+ 2 - 2
Jolt/Physics/Body/BodyInterface.cpp

@@ -694,13 +694,13 @@ TransformedShape BodyInterface::GetTransformedShape(const BodyID &inBodyID) cons
 		return TransformedShape();
 }
 
-void *BodyInterface::GetUserData(const BodyID &inBodyID) const
+uint64 BodyInterface::GetUserData(const BodyID &inBodyID) const
 {
 	BodyLockRead lock(*mBodyLockInterface, inBodyID);
 	if (lock.Succeeded())
 		return lock.GetBody().GetUserData();
 	else
-		return nullptr;
+		return 0;
 }
 
 const PhysicsMaterial *BodyInterface::GetMaterial(const BodyID &inBodyID, const SubShapeID &inSubShapeID) const

+ 1 - 1
Jolt/Physics/Body/BodyInterface.h

@@ -167,7 +167,7 @@ public:
 	TransformedShape			GetTransformedShape(const BodyID &inBodyID) const;
 
 	/// Get the user data for a body
-	void *						GetUserData(const BodyID &inBodyID) const;
+	uint64						GetUserData(const BodyID &inBodyID) const;
 
 	/// Get the material for a particular sub shape
 	const PhysicsMaterial *		GetMaterial(const BodyID &inBodyID, const SubShapeID &inSubShapeID) const;

+ 1 - 0
Jolt/Physics/Body/BodyManager.cpp

@@ -164,6 +164,7 @@ Body *BodyManager::CreateBody(const BodyCreationSettings &inBodyCreationSettings
 	}
 	body->mID = BodyID(idx, seq_no);
 	body->mShape = inBodyCreationSettings.GetShape();
+	body->mUserData = inBodyCreationSettings.mUserData;
 	body->SetFriction(inBodyCreationSettings.mFriction);
 	body->SetRestitution(inBodyCreationSettings.mRestitution);
 	body->mMotionType = inBodyCreationSettings.mMotionType;

+ 3 - 4
Jolt/Physics/Character/Character.cpp

@@ -22,7 +22,7 @@ static inline const NarrowPhaseQuery &sGetNarrowPhaseQuery(PhysicsSystem *inSyst
 	return inLockBodies? inSystem->GetNarrowPhaseQuery() : inSystem->GetNarrowPhaseQueryNoLock();
 }
 
-Character::Character(CharacterSettings *inSettings, Vec3Arg inPosition, QuatArg inRotation, void *inUserData, PhysicsSystem *inSystem) :
+Character::Character(CharacterSettings *inSettings, Vec3Arg inPosition, QuatArg inRotation, uint64 inUserData, PhysicsSystem *inSystem) :
 	mLayer(inSettings->mLayer),
 	mShape(inSettings->mShape),
 	mSystem(inSystem),
@@ -35,11 +35,10 @@ Character::Character(CharacterSettings *inSettings, Vec3Arg inPosition, QuatArg
 	BodyCreationSettings settings(mShape, inPosition, inRotation, EMotionType::Dynamic, mLayer);
 	settings.mFriction = inSettings->mFriction;
 	settings.mGravityFactor = inSettings->mGravityFactor;
+	settings.mUserData = inUserData;
 	Body *body = mSystem->GetBodyInterface().CreateBody(settings);
 	if (body != nullptr)
 	{
-		body->SetUserData(inUserData);
-
 		// Update the mass properties of the shape so that we set the correct mass and don't allow any rotation
 		body->GetMotionProperties()->SetInverseMass(1.0f / inSettings->mMass);
 		body->GetMotionProperties()->SetInverseInertia(Vec3::sZero(), Quat::sIdentity());
@@ -258,7 +257,7 @@ Character::EGroundState Character::GetGroundState() const
 		return EGroundState::Sliding;
 }
 
-void *Character::GetGroundUserData(bool inLockBodies) const
+uint64 Character::GetGroundUserData(bool inLockBodies) const
 {
 	return sGetBodyInterface(mSystem, inLockBodies).GetUserData(mGroundBodyID);
 }

+ 4 - 4
Jolt/Physics/Character/Character.h

@@ -46,9 +46,9 @@ public:
 	/// @param inSettings The settings for the character
 	/// @param inPosition Initial position for the character
 	/// @param inRotation Initial rotation for the character (usually only around Y)
-	/// @param inUserData Application specific data pointer
+	/// @param inUserData Application specific value
 	/// @param inSystem Physics system that this character will be added to later
-										Character(CharacterSettings *inSettings, Vec3Arg inPosition, QuatArg inRotation, void *inUserData, PhysicsSystem *inSystem);
+										Character(CharacterSettings *inSettings, Vec3Arg inPosition, QuatArg inRotation, uint64 inUserData, PhysicsSystem *inSystem);
 
 	/// Destructor
 										~Character();
@@ -149,8 +149,8 @@ public:
 	/// Sub part of the body that we're standing on.
 	SubShapeID							GetGroundSubShapeID() const								{ return mGroundBodySubShapeID; }
 
-	/// User data pointer of the body that we're standing on
-	void *								GetGroundUserData(bool inLockBodies = true) const;
+	/// User data value of the body that we're standing on
+	uint64								GetGroundUserData(bool inLockBodies = true) const;
 
 private:
 	/// Check collisions between inShape and the world

+ 1 - 1
Jolt/Physics/Collision/Shape/CompoundShape.cpp

@@ -127,7 +127,7 @@ const PhysicsMaterial *CompoundShape::GetMaterial(const SubShapeID &inSubShapeID
 	return mSubShapes[index].mShape->GetMaterial(remainder);
 }
 
-uint32 CompoundShape::GetSubShapeUserData(const SubShapeID &inSubShapeID) const
+uint64 CompoundShape::GetSubShapeUserData(const SubShapeID &inSubShapeID) const
 {
 	// Decode sub shape index
 	SubShapeID remainder;

+ 5 - 5
Jolt/Physics/Collision/Shape/CompoundShape.h

@@ -76,7 +76,7 @@ public:
 	virtual const PhysicsMaterial *	GetMaterial(const SubShapeID &inSubShapeID) const override;
 
 	// See Shape::GetSubShapeUserData
-	virtual uint32					GetSubShapeUserData(const SubShapeID &inSubShapeID) const override;
+	virtual uint64					GetSubShapeUserData(const SubShapeID &inSubShapeID) const override;
 
 	// See Shape::GetSubShapeTransformedShape
 	virtual TransformedShape		GetSubShapeTransformedShape(const SubShapeID &inSubShapeID, Vec3Arg inPositionCOM, QuatArg inRotation, Vec3Arg inScale, SubShapeID &outRemainder) const override;
@@ -239,11 +239,11 @@ public:
 	/// Access to a particular sub shape
 	const SubShape &				GetSubShape(uint inIdx) const							{ return mSubShapes[inIdx]; }
 
-	/// Get the user data of sub shape
-	uint32							GetSubShapeUserData(uint inIdx) const					{ return mSubShapes[inIdx].mUserData; }
+	/// Get the user data associated with a shape in this compound
+	uint32							GetCompoundUserData(uint inIdx) const					{ return mSubShapes[inIdx].mUserData; }
 
-	/// Set the user data of a sub shape
-	void							SetSubShapeUserData(uint inIdx, uint32 inUserData)		{ mSubShapes[inIdx].mUserData = inUserData; }
+	/// Set the user data associated with a shape in this compound
+	void							SetCompoundUserData(uint inIdx, uint32 inUserData)		{ mSubShapes[inIdx].mUserData = inUserData; }
 
 	/// Check if a sub shape ID is still valid for this shape
 	/// @param inSubShapeID Sub shape id that indicates the leaf shape relative to this shape

+ 1 - 1
Jolt/Physics/Collision/Shape/DecoratedShape.cpp

@@ -48,7 +48,7 @@ const PhysicsMaterial *DecoratedShape::GetMaterial(const SubShapeID &inSubShapeI
 	return mInnerShape->GetMaterial(inSubShapeID);
 }
 
-uint32 DecoratedShape::GetSubShapeUserData(const SubShapeID &inSubShapeID) const
+uint64 DecoratedShape::GetSubShapeUserData(const SubShapeID &inSubShapeID) const
 {
 	return mInnerShape->GetSubShapeUserData(inSubShapeID);
 }

+ 1 - 1
Jolt/Physics/Collision/Shape/DecoratedShape.h

@@ -45,7 +45,7 @@ public:
 	virtual const PhysicsMaterial *	GetMaterial(const SubShapeID &inSubShapeID) const override;
 
 	// See Shape::GetSubShapeUserData
-	virtual uint32					GetSubShapeUserData(const SubShapeID &inSubShapeID) const override;
+	virtual uint64					GetSubShapeUserData(const SubShapeID &inSubShapeID) const override;
 
 	// See Shape
 	virtual void					SaveSubShapeState(ShapeList &outSubShapes) const override;

+ 5 - 5
Jolt/Physics/Collision/Shape/Shape.h

@@ -128,7 +128,7 @@ public:
 	virtual ShapeResult				Create() const = 0;
 
 	/// User data (to be used freely by the application)
-	uint32							mUserData = 0;
+	uint64							mUserData = 0;
 
 protected:
 	mutable ShapeResult				mCachedResult;
@@ -169,8 +169,8 @@ public:
 	inline EShapeSubType			GetSubType() const													{ return mShapeSubType; }
 
 	/// User data (to be used freely by the application)
-	uint32							GetUserData() const													{ return mUserData; }
-	void							SetUserData(uint32 inUserData)										{ mUserData = inUserData; }
+	uint64							GetUserData() const													{ return mUserData; }
+	void							SetUserData(uint64 inUserData)										{ mUserData = inUserData; }
 
 	/// Check if this shape can only be used to create a static body or if it can also be dynamic/kinematic
 	virtual bool					MustBeStatic() const												{ return false; }
@@ -203,7 +203,7 @@ public:
 	virtual Vec3					GetSurfaceNormal(const SubShapeID &inSubShapeID, Vec3Arg inLocalSurfacePosition) const = 0;
 
 	/// Get the user data of a particular sub shape ID
-	virtual uint32					GetSubShapeUserData(const SubShapeID &inSubShapeID) const			{ return mUserData; }
+	virtual uint64					GetSubShapeUserData(const SubShapeID &inSubShapeID) const			{ return mUserData; }
 
 	/// Get the direct child sub shape and its transform for a sub shape ID.
 	/// @param inSubShapeID Sub shape ID that indicates the path to the leaf shape
@@ -359,7 +359,7 @@ protected:
 	virtual void					RestoreBinaryState(StreamIn &inStream);
 
 private:
-	uint32							mUserData = 0;
+	uint64							mUserData = 0;
 	EShapeType						mShapeType;
 	EShapeSubType					mShapeSubType;
 };

+ 1 - 1
Jolt/Physics/Collision/TransformedShape.h

@@ -131,7 +131,7 @@ public:
 	}
 
 	/// Get the user data of a particular sub shape
-	inline uint32				GetSubShapeUserData(const SubShapeID &inSubShapeID) const
+	inline uint64				GetSubShapeUserData(const SubShapeID &inSubShapeID) const
 	{
 		return mShape->GetSubShapeUserData(MakeSubShapeIDRelativeToShape(inSubShapeID));
 	}

+ 1 - 1
Jolt/Physics/Ragdoll/Ragdoll.cpp

@@ -263,7 +263,7 @@ RagdollSettings::RagdollResult RagdollSettings::sRestoreFromBinaryState(StreamIn
 	return result;
 }
 
-Ragdoll *RagdollSettings::CreateRagdoll(CollisionGroup::GroupID inCollisionGroup, void *inUserData, PhysicsSystem *inSystem) const
+Ragdoll *RagdollSettings::CreateRagdoll(CollisionGroup::GroupID inCollisionGroup, uint64 inUserData, PhysicsSystem *inSystem) const
 {
 	Ragdoll *r = new Ragdoll(inSystem);
 	r->mRagdollSettings = this;

+ 1 - 1
Jolt/Physics/Ragdoll/Ragdoll.h

@@ -39,7 +39,7 @@ public:
 
 	/// Create ragdoll instance from these settings
 	/// @return Newly created ragdoll or null when out of bodies
-	Ragdoll *							CreateRagdoll(CollisionGroup::GroupID inCollisionGroup, void *inUserData, PhysicsSystem *inSystem) const;
+	Ragdoll *							CreateRagdoll(CollisionGroup::GroupID inCollisionGroup, uint64 inUserData, PhysicsSystem *inSystem) const;
 
 	/// Access to the skeleton of this ragdoll
 	const Skeleton *					GetSkeleton() const												{ return mSkeleton; }

+ 1 - 1
PerformanceTest/RagdollScene.h

@@ -105,7 +105,7 @@ public:
 				for (int i = 0; i < cPileSize; ++i)
 				{
 					// Create ragdoll
-					Ref<Ragdoll> ragdoll = mRagdollSettings->CreateRagdoll(group_id++, nullptr, &inPhysicsSystem);
+					Ref<Ragdoll> ragdoll = mRagdollSettings->CreateRagdoll(group_id++, 0, &inPhysicsSystem);
 	
 					// Override root
 					SkeletonPose pose_copy = mPose;

+ 1 - 1
Samples/Tests/Character/CharacterTest.cpp

@@ -73,7 +73,7 @@ void CharacterTest::Initialize()
 	settings->mLayer = Layers::MOVING;
 	settings->mShape = mStandingShape;
 	settings->mFriction = 0.5f;
-	mCharacter = new Character(settings, Vec3::sZero(), Quat::sIdentity(), nullptr, mPhysicsSystem);
+	mCharacter = new Character(settings, Vec3::sZero(), Quat::sIdentity(), 0, mPhysicsSystem);
 	mCharacter->AddToPhysicsSystem(EActivation::Activate);
 }
 

+ 1 - 1
Samples/Tests/General/MultithreadedTest.cpp

@@ -162,7 +162,7 @@ void MultithreadedTest::RagdollSpawner()
 		if (ragdolls.size() < cMaxRagdolls)
 		{
 			// Create ragdoll
-			Ref<Ragdoll> ragdoll = ragdoll_settings->CreateRagdoll(group_id++, nullptr, mPhysicsSystem);
+			Ref<Ragdoll> ragdoll = ragdoll_settings->CreateRagdoll(group_id++, 0, mPhysicsSystem);
 	
 			// Override root
 			SkeletonPose::JointState &root = ragdoll_pose.GetJoint(0);

+ 1 - 1
Samples/Tests/General/SensorTest.cpp

@@ -64,7 +64,7 @@ void SensorTest::Initialize()
 	ragdoll_pose.CalculateJointMatrices();
 
 	// Create ragdoll
-	mRagdoll = ragdoll_settings->CreateRagdoll(1, nullptr, mPhysicsSystem);
+	mRagdoll = ragdoll_settings->CreateRagdoll(1, 0, mPhysicsSystem);
 	mRagdoll->SetPose(ragdoll_pose);
 	mRagdoll->AddToPhysicsSystem(EActivation::Activate);
 

+ 2 - 2
Samples/Tests/General/SimpleTest.h

@@ -23,12 +23,12 @@ private:
 	class Listener : public BodyActivationListener
 	{
 	public:
-		virtual void	OnBodyActivated(const BodyID &inBodyID, void *inBodyUserData) override
+		virtual void	OnBodyActivated(const BodyID &inBodyID, uint64 inBodyUserData) override
 		{
 			Trace("Body %d activated", inBodyID.GetIndex());
 		}
 
-		virtual void	OnBodyDeactivated(const BodyID &inBodyID, void *inBodyUserData) override
+		virtual void	OnBodyDeactivated(const BodyID &inBodyID, uint64 inBodyUserData) override
 		{
 			Trace("Body %d deactivated", inBodyID.GetIndex());
 		}

+ 1 - 1
Samples/Tests/Rig/KinematicRigTest.cpp

@@ -52,7 +52,7 @@ void KinematicRigTest::Initialize()
 	mRagdollSettings = RagdollLoader::sLoad("Assets/Human.tof", EMotionType::Kinematic);
 
 	// Create ragdoll
-	mRagdoll = mRagdollSettings->CreateRagdoll(0, nullptr, mPhysicsSystem);
+	mRagdoll = mRagdollSettings->CreateRagdoll(0, 0, mPhysicsSystem);
 	mRagdoll->AddToPhysicsSystem(EActivation::Activate);
 
 	// Load animation

+ 1 - 1
Samples/Tests/Rig/LoadRigTest.cpp

@@ -37,7 +37,7 @@ void LoadRigTest::Initialize()
 	mRagdollSettings = RagdollLoader::sLoad("Assets/Human.tof", EMotionType::Dynamic, sConstraintType);
 
 	// Create ragdoll
-	mRagdoll = mRagdollSettings->CreateRagdoll(0, nullptr, mPhysicsSystem);
+	mRagdoll = mRagdollSettings->CreateRagdoll(0, 0, mPhysicsSystem);
 	mRagdoll->AddToPhysicsSystem(EActivation::Activate);
 }
 

+ 1 - 1
Samples/Tests/Rig/LoadSaveBinaryRigTest.cpp

@@ -41,6 +41,6 @@ void LoadSaveBinaryRigTest::Initialize()
 		FatalError(result.GetError().c_str());
 
 	// Create ragdoll
-	mRagdoll = result.Get()->CreateRagdoll(0, nullptr, mPhysicsSystem);
+	mRagdoll = result.Get()->CreateRagdoll(0, 0, mPhysicsSystem);
 	mRagdoll->AddToPhysicsSystem(EActivation::Activate);
 }

+ 1 - 1
Samples/Tests/Rig/PoweredRigTest.cpp

@@ -41,7 +41,7 @@ void PoweredRigTest::Initialize()
 	mRagdollSettings = RagdollLoader::sLoad("Assets/Human.tof", EMotionType::Dynamic);
 
 	// Create ragdoll
-	mRagdoll = mRagdollSettings->CreateRagdoll(0, nullptr, mPhysicsSystem);
+	mRagdoll = mRagdollSettings->CreateRagdoll(0, 0, mPhysicsSystem);
 	mRagdoll->AddToPhysicsSystem(EActivation::Activate);
 	
 	// Load animation

+ 1 - 1
Samples/Tests/Rig/RigPileTest.cpp

@@ -108,7 +108,7 @@ void RigPileTest::Initialize()
 			for (int i = 0; i < cPileSize; ++i)
 			{
 				// Create ragdoll
-				Ref<Ragdoll> ragdoll = settings->CreateRagdoll(group_id++, nullptr, mPhysicsSystem);
+				Ref<Ragdoll> ragdoll = settings->CreateRagdoll(group_id++, 0, mPhysicsSystem);
 	
 				// Sample pose
 				SkeletonPose pose;

+ 2 - 2
UnitTests/LoggingBodyActivationListener.h

@@ -24,13 +24,13 @@ public:
 		BodyID				mBodyID;
 	};
 
-	virtual void		OnBodyActivated(const BodyID &inBodyID, void *inBodyUserData) override
+	virtual void		OnBodyActivated(const BodyID &inBodyID, uint64 inBodyUserData) override
 	{
 		lock_guard lock(mLogMutex);
 		mLog.push_back({ EType::Activated, inBodyID });
 	}
 
-	virtual void		OnBodyDeactivated(const BodyID &inBodyID, void *inBodyUserData) override
+	virtual void		OnBodyDeactivated(const BodyID &inBodyID, uint64 inBodyUserData) override
 	{
 		lock_guard lock(mLogMutex);
 		mLog.push_back({ EType::Deactivated, inBodyID });

+ 16 - 0
UnitTests/Physics/PhysicsTests.cpp

@@ -141,6 +141,22 @@ TEST_SUITE("PhysicsTests")
 		bi.DestroyBody(body0_id);
 	}
 
+	TEST_CASE("TestPhysicsBodyUserData")
+	{
+		PhysicsTestContext c(1.0f / 60.0f, 1, 1);
+		BodyInterface &bi = c.GetBodyInterface();
+
+		// Create a body and pass user data through the creation settings
+		BodyCreationSettings body_settings(new BoxShape(Vec3::sReplicate(1.0f)), Vec3::sZero(), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING);
+		body_settings.mUserData = 0x1234567887654321;
+		Body *body = bi.CreateBody(body_settings);
+		CHECK(body->GetUserData() == 0x1234567887654321);
+
+		// Change the user data
+		body->SetUserData(0x5678123443218765);
+		CHECK(body->GetUserData() == 0x5678123443218765);
+	}
+
 	TEST_CASE("TestPhysicsOverrideMassAndInertia")
 	{
 		PhysicsTestContext c(1.0f / 60.0f, 1, 1);

+ 5 - 5
UnitTests/Physics/ShapeTests.cpp

@@ -495,13 +495,13 @@ TEST_SUITE("ShapeTests")
 
 		// Create a sphere with user data
 		SphereShapeSettings sphere_settings(cRadius);
-		sphere_settings.mUserData = 1234;
+		sphere_settings.mUserData = 0x1234567887654321;
 		Ref<Shape> sphere = sphere_settings.Create().Get();
-		CHECK(sphere->GetUserData() == 1234);
+		CHECK(sphere->GetUserData() == 0x1234567887654321);
 
 		// Change the user data
-		sphere->SetUserData(5678);
-		CHECK(sphere->GetUserData() == 5678);
+		sphere->SetUserData(0x5678123443218765);
+		CHECK(sphere->GetUserData() == 0x5678123443218765);
 
 		stringstream data;
 
@@ -523,7 +523,7 @@ TEST_SUITE("ShapeTests")
 		// Check that the sphere and its user data was preserved
 		CHECK(sphere->GetType() == EShapeType::Convex);
 		CHECK(sphere->GetSubType() == EShapeSubType::Sphere);
-		CHECK(sphere->GetUserData() == 5678);
+		CHECK(sphere->GetUserData() == 0x5678123443218765);
 		CHECK(static_cast<SphereShape *>(sphere.GetPtr())->GetRadius() == cRadius);
 	}