Browse Source

Removed Body::GetDebugName

On windows every constructed std::string does a malloc in debug mode which is a bit wasteful. This can easily be implemented on application level as a look aside buffer.
Jorrit Rouwe 3 years ago
parent
commit
6db4d3beac

+ 0 - 9
Jolt/Physics/Body/Body.cpp

@@ -29,15 +29,6 @@ Body::Body(bool) :
 {
 {
 }
 }
 
 
-#ifdef _DEBUG
-
-string Body::GetDebugName() const
-{ 
-	return mDebugName.empty()? ConvertToString(mID.GetIndex()) : ConvertToString(mID.GetIndex()) + "-" + mDebugName; 
-}
-
-#endif
-
 void Body::SetMotionType(EMotionType inMotionType)
 void Body::SetMotionType(EMotionType inMotionType)
 {
 {
 	if (mMotionType == inMotionType)
 	if (mMotionType == inMotionType)

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

@@ -37,14 +37,6 @@ public:
 	/// Destructor							
 	/// Destructor							
 							~Body()															{ JPH_ASSERT(mMotionProperties == nullptr); }
 							~Body()															{ JPH_ASSERT(mMotionProperties == nullptr); }
 
 
-#ifdef _DEBUG
-	/// Name of the body for debugging purposes
-	void					SetDebugName(const string &inName)								{ mDebugName = inName; }
-	string					GetDebugName() const;
-#else
-	string					GetDebugName() const											{ return ConvertToString(mID.GetIndex()); }
-#endif
-
 	/// Get the id of this body
 	/// Get the id of this body
 	inline const BodyID &	GetID() const													{ return mID; }
 	inline const BodyID &	GetID() const													{ return mID; }
 
 
@@ -311,16 +303,10 @@ private:
 	atomic<uint8>			mFlags = 0;														///< See EFlags for possible flags
 	atomic<uint8>			mFlags = 0;														///< See EFlags for possible flags
 	
 	
 	// 121 bytes up to here
 	// 121 bytes up to here
-
-#ifdef _DEBUG
-	string					mDebugName;														///< Name for debugging purposes
-#endif
 };
 };
 
 
-#ifndef _DEBUG
-	static_assert(sizeof(Body) == 128, "Body should be 128 bytes");
-	static_assert(alignof(Body) == 16, "Body should align to 16 bytes");
-#endif
+static_assert(sizeof(Body) == 128, "Body should be 128 bytes");
+static_assert(alignof(Body) == 16, "Body should align to 16 bytes");
 
 
 JPH_NAMESPACE_END
 JPH_NAMESPACE_END
 
 

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

@@ -723,9 +723,6 @@ void BodyManager::Draw(const DrawSettings &inDrawSettings, const PhysicsSettings
 				for (int i = 0; i < 3; ++i)
 				for (int i = 0; i < 3; ++i)
 					inRenderer->DrawWireSphere(body->mMotionProperties->mSleepTestSpheres[i].GetCenter(), body->mMotionProperties->mSleepTestSpheres[i].GetRadius(), sleep_color);
 					inRenderer->DrawWireSphere(body->mMotionProperties->mSleepTestSpheres[i].GetCenter(), body->mMotionProperties->mSleepTestSpheres[i].GetRadius(), sleep_color);
 			}
 			}
-
-			if (inDrawSettings.mDrawNames)
-				inRenderer->DrawText3D(body->GetCenterOfMassPosition(), body->GetDebugName(), Color::sCyan, 0.2f);
 		}
 		}
 
 
 	UnlockAllBodies();
 	UnlockAllBodies();

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

@@ -176,7 +176,6 @@ public:
 		bool						mDrawVelocity = false;							///< Draw the velocity vector for each body
 		bool						mDrawVelocity = false;							///< Draw the velocity vector for each body
 		bool						mDrawMassAndInertia = false;					///< Draw the mass and inertia (as the box equivalent) for each body
 		bool						mDrawMassAndInertia = false;					///< Draw the mass and inertia (as the box equivalent) for each body
 		bool						mDrawSleepStats = false;						///< Draw stats regarding the sleeping algorithm of each body
 		bool						mDrawSleepStats = false;						///< Draw stats regarding the sleeping algorithm of each body
-		bool						mDrawNames = false;								///< (Debug only) Draw the object names for each body
 	};
 	};
 
 
 	/// Draw the state of the bodies (debugging purposes)
 	/// Draw the state of the bodies (debugging purposes)

+ 0 - 3
Jolt/Physics/Ragdoll/Ragdoll.cpp

@@ -355,9 +355,6 @@ Ragdoll *RagdollSettings::CreateRagdoll(CollisionGroup::GroupID inCollisionGroup
 		}
 		}
 		body2->GetCollisionGroup().SetGroupID(inCollisionGroup);
 		body2->GetCollisionGroup().SetGroupID(inCollisionGroup);
 		body2->SetUserData(inUserData);
 		body2->SetUserData(inUserData);
-#ifdef _DEBUG
-		body2->SetDebugName(mSkeleton->GetJoint(joint_idx).mName);
-#endif
 
 
 		// Temporarily store body pointer for hooking up constraints
 		// Temporarily store body pointer for hooking up constraints
 		bodies[joint_idx] = body2;
 		bodies[joint_idx] = body2;

+ 0 - 4
Samples/SamplesApp.cpp

@@ -367,7 +367,6 @@ SamplesApp::SamplesApp()
 #ifdef JPH_DEBUG_RENDERER
 #ifdef JPH_DEBUG_RENDERER
 	mDebugUI->CreateTextButton(main_menu, "Drawing Options", [this]() { 
 	mDebugUI->CreateTextButton(main_menu, "Drawing Options", [this]() { 
 		UIElement *drawing_options = mDebugUI->CreateMenu();
 		UIElement *drawing_options = mDebugUI->CreateMenu();
-		mDebugUI->CreateCheckBox(drawing_options, "Draw Body Names", mBodyDrawSettings.mDrawNames, [this](UICheckBox::EState inState) { mBodyDrawSettings.mDrawNames = inState == UICheckBox::STATE_CHECKED; });
 		mDebugUI->CreateCheckBox(drawing_options, "Draw Shapes (H)", mBodyDrawSettings.mDrawShape, [this](UICheckBox::EState inState) { mBodyDrawSettings.mDrawShape = inState == UICheckBox::STATE_CHECKED; });
 		mDebugUI->CreateCheckBox(drawing_options, "Draw Shapes (H)", mBodyDrawSettings.mDrawShape, [this](UICheckBox::EState inState) { mBodyDrawSettings.mDrawShape = inState == UICheckBox::STATE_CHECKED; });
 		mDebugUI->CreateCheckBox(drawing_options, "Draw Shapes Wireframe (Alt+W)", mBodyDrawSettings.mDrawShapeWireframe, [this](UICheckBox::EState inState) { mBodyDrawSettings.mDrawShapeWireframe = inState == UICheckBox::STATE_CHECKED; });
 		mDebugUI->CreateCheckBox(drawing_options, "Draw Shapes Wireframe (Alt+W)", mBodyDrawSettings.mDrawShapeWireframe, [this](UICheckBox::EState inState) { mBodyDrawSettings.mDrawShapeWireframe = inState == UICheckBox::STATE_CHECKED; });
 		mDebugUI->CreateComboBox(drawing_options, "Draw Shape Color", { "Instance", "Shape Type", "Motion Type", "Sleep", "Island", "Material" }, (int)mBodyDrawSettings.mDrawShapeColor, [this](int inItem) { mBodyDrawSettings.mDrawShapeColor = (BodyManager::EShapeColor)inItem; });
 		mDebugUI->CreateComboBox(drawing_options, "Draw Shape Color", { "Instance", "Shape Type", "Motion Type", "Sleep", "Island", "Material" }, (int)mBodyDrawSettings.mDrawShapeColor, [this](int inItem) { mBodyDrawSettings.mDrawShapeColor = (BodyManager::EShapeColor)inItem; });
@@ -1578,9 +1577,6 @@ void SamplesApp::UpdateDebug()
 						// Note that we don't add it to the world since we don't want anything to collide with it, we just
 						// Note that we don't add it to the world since we don't want anything to collide with it, we just
 						// need an anchor for a constraint
 						// need an anchor for a constraint
 						Body *drag_anchor = bi.CreateBody(BodyCreationSettings(new SphereShape(0.01f), hit_position, Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING));
 						Body *drag_anchor = bi.CreateBody(BodyCreationSettings(new SphereShape(0.01f), hit_position, Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING));
-					#ifdef _DEBUG
-						drag_anchor->SetDebugName("DragAnchor");
-					#endif
 						mDragAnchor = drag_anchor;
 						mDragAnchor = drag_anchor;
 
 
 						// Construct constraint that connects the drag anchor with the body that we want to drag
 						// Construct constraint that connects the drag anchor with the body that we want to drag

+ 0 - 6
Samples/Tests/General/DampingTest.cpp

@@ -24,9 +24,6 @@ void DampingTest::Initialize()
 	for (int i = 0; i <= 10; ++i)
 	for (int i = 0; i <= 10; ++i)
 	{
 	{
 		Body &body = *mBodyInterface->CreateBody(BodyCreationSettings(sphere, Vec3(-50.0f + i * 10.0f, 2.0f, -80.0f), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING));
 		Body &body = *mBodyInterface->CreateBody(BodyCreationSettings(sphere, Vec3(-50.0f + i * 10.0f, 2.0f, -80.0f), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING));
-#ifdef _DEBUG
-		body.SetDebugName(StringFormat("LinearDamping%d", i));
-#endif
 		body.GetMotionProperties()->SetAngularDamping(0.0f);
 		body.GetMotionProperties()->SetAngularDamping(0.0f);
 		body.GetMotionProperties()->SetLinearDamping(0.1f * i);
 		body.GetMotionProperties()->SetLinearDamping(0.1f * i);
 		body.SetLinearVelocity(Vec3(0, 0, 10));
 		body.SetLinearVelocity(Vec3(0, 0, 10));
@@ -36,9 +33,6 @@ void DampingTest::Initialize()
 	for (int i = 0; i <= 10; ++i)
 	for (int i = 0; i <= 10; ++i)
 	{
 	{
 		Body &body = *mBodyInterface->CreateBody(BodyCreationSettings(sphere, Vec3(-50.0f + i * 10.0f, 2.0f, -90.0f), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING));
 		Body &body = *mBodyInterface->CreateBody(BodyCreationSettings(sphere, Vec3(-50.0f + i * 10.0f, 2.0f, -90.0f), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING));
-#ifdef _DEBUG
-		body.SetDebugName(StringFormat("AngularDamping%d", i));
-#endif
 		body.GetMotionProperties()->SetLinearDamping(0.0f);
 		body.GetMotionProperties()->SetLinearDamping(0.0f);
 		body.GetMotionProperties()->SetAngularDamping(0.1f * i);
 		body.GetMotionProperties()->SetAngularDamping(0.1f * i);
 		body.SetAngularVelocity(Vec3(0, 10, 0));
 		body.SetAngularVelocity(Vec3(0, 10, 0));

+ 2 - 10
Samples/Tests/General/FunnelTest.cpp

@@ -30,11 +30,7 @@ void FunnelTest::Initialize()
 	{
 	{
 		Quat rotation = Quat::sRotation(Vec3::sAxisY(), 0.5f * JPH_PI * i);
 		Quat rotation = Quat::sRotation(Vec3::sAxisY(), 0.5f * JPH_PI * i);
 
 
-		Body &funnel = *mBodyInterface->CreateBody(BodyCreationSettings(box, rotation * Vec3(25, 25, 0), rotation * Quat::sRotation(Vec3::sAxisZ(), 0.25f * JPH_PI), EMotionType::Static, Layers::NON_MOVING));
-#ifdef _DEBUG
-		funnel.SetDebugName(StringFormat("Funnel%d", i));
-#endif
-		mBodyInterface->AddBody(funnel.GetID(), EActivation::DontActivate);
+		mBodyInterface->CreateAndAddBody(BodyCreationSettings(box, rotation * Vec3(25, 25, 0), rotation * Quat::sRotation(Vec3::sAxisZ(), 0.25f * JPH_PI), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
 	}
 	}
 
 
 	default_random_engine random;
 	default_random_engine random;
@@ -133,11 +129,7 @@ void FunnelTest::Initialize()
 			shape = new ScaledShape(shape, scale);
 			shape = new ScaledShape(shape, scale);
 
 
 		Vec3 position(position_variation(random), 100.0f + position_variation(random), position_variation(random));
 		Vec3 position(position_variation(random), 100.0f + position_variation(random), position_variation(random));
-		Body &body = *mBodyInterface->CreateBody(BodyCreationSettings(shape, position, Quat::sRandom(random), EMotionType::Dynamic, Layers::MOVING));
-#ifdef _DEBUG
-		body.SetDebugName(StringFormat("Body%d", i));
-#endif
-		mBodyInterface->AddBody(body.GetID(), EActivation::Activate);
+		mBodyInterface->CreateAndAddBody(BodyCreationSettings(shape, position, Quat::sRandom(random), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
 	}
 	}
 }
 }
 
 

+ 25 - 46
Samples/Tests/General/HighSpeedTest.cpp

@@ -44,36 +44,19 @@ void HighSpeedTest::CreateDominoBlocks(Vec3Arg inOffset, int inNumWalls, float i
 	// U shaped set of thin boxes
 	// U shaped set of thin boxes
 	for (int i = 0; i < inNumWalls; ++i)
 	for (int i = 0; i < inNumWalls; ++i)
 	{
 	{
-		{
-			box_settings.mPosition = inOffset + Vec3(2.0f * i, 1, -1.1f - inRadius);
-			Body &box = *mBodyInterface->CreateBody(box_settings);
-		#ifdef _DEBUG
-			box.SetDebugName("Neg Box " + ConvertToString(i));
-		#endif
-			mBodyInterface->AddBody(box.GetID(), EActivation::DontActivate);
-		}
+		box_settings.mPosition = inOffset + Vec3(2.0f * i, 1, -1.1f - inRadius);
+		mBodyInterface->CreateAndAddBody(box_settings, EActivation::DontActivate);
 
 
-		{
-			box_settings.mPosition = inOffset + Vec3(2.0f * i, 1, +1.1f + inRadius);
-			Body &box = *mBodyInterface->CreateBody(box_settings);
-		#ifdef _DEBUG
-			box.SetDebugName("Pos Box " + ConvertToString(i));
-		#endif
-			mBodyInterface->AddBody(box.GetID(), EActivation::DontActivate);
-		}
-	}
-	{
-		box_settings.mPosition = inOffset + Vec3(-1.1f - inRadius, 1, 0);
-		box_settings.mRotation = Quat::sRotation(Vec3::sAxisY(), 0.5f * JPH_PI);
-		Body &box = *mBodyInterface->CreateBody(box_settings);
-		#ifdef _DEBUG
-			box.SetDebugName("End Box");
-		#endif
-		mBodyInterface->AddBody(box.GetID(), EActivation::DontActivate);
+		box_settings.mPosition = inOffset + Vec3(2.0f * i, 1, +1.1f + inRadius);
+		mBodyInterface->CreateAndAddBody(box_settings, EActivation::DontActivate);
 	}
 	}
+
+	box_settings.mPosition = inOffset + Vec3(-1.1f - inRadius, 1, 0);
+	box_settings.mRotation = Quat::sRotation(Vec3::sAxisY(), 0.5f * JPH_PI);
+	mBodyInterface->CreateAndAddBody(box_settings, EActivation::DontActivate);
 }
 }
 
 
-void HighSpeedTest::CreateDynamicObject(const char *inName, Vec3 inPosition, Vec3 inVelocity, Shape *inShape, EMotionQuality inMotionQuality)
+void HighSpeedTest::CreateDynamicObject(Vec3 inPosition, Vec3 inVelocity, Shape *inShape, EMotionQuality inMotionQuality)
 {
 {
 	BodyCreationSettings creation_settings;
 	BodyCreationSettings creation_settings;
 	creation_settings.SetShape(inShape);
 	creation_settings.SetShape(inShape);
@@ -86,7 +69,6 @@ void HighSpeedTest::CreateDynamicObject(const char *inName, Vec3 inPosition, Vec
 	creation_settings.mPosition = inPosition;
 	creation_settings.mPosition = inPosition;
 
 
 	Body &body = *mBodyInterface->CreateBody(creation_settings);
 	Body &body = *mBodyInterface->CreateBody(creation_settings);
-	JPH_IF_DEBUG(body.SetDebugName(inName);)
 	body.SetLinearVelocity(inVelocity);
 	body.SetLinearVelocity(inVelocity);
 	mBodyInterface->AddBody(body.GetID(), inVelocity.IsNearZero()? EActivation::DontActivate : EActivation::Activate);
 	mBodyInterface->AddBody(body.GetID(), inVelocity.IsNearZero()? EActivation::DontActivate : EActivation::Activate);
 }
 }
@@ -113,13 +95,12 @@ void HighSpeedTest::CreateSimpleScene()
 		}
 		}
 		triangles.push_back(Triangle(Float3(-1-radius,0,-1), Float3(-1-radius,2,0), Float3(-1-radius,0,1)));
 		triangles.push_back(Triangle(Float3(-1-radius,0,-1), Float3(-1-radius,2,0), Float3(-1-radius,0,1)));
 		Body &walls = *mBodyInterface->CreateBody(BodyCreationSettings(new MeshShapeSettings(triangles), offset, Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING));
 		Body &walls = *mBodyInterface->CreateBody(BodyCreationSettings(new MeshShapeSettings(triangles), offset, Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING));
-		JPH_IF_DEBUG(walls.SetDebugName("Walls");)
 		walls.SetRestitution(1.0f);
 		walls.SetRestitution(1.0f);
 		walls.SetFriction(0.0f);
 		walls.SetFriction(0.0f);
 		mBodyInterface->AddBody(walls.GetID(), EActivation::DontActivate);
 		mBodyInterface->AddBody(walls.GetID(), EActivation::DontActivate);
 
 
 		// Fast moving sphere against mesh
 		// Fast moving sphere against mesh
-		CreateDynamicObject("Sphere Against Mesh", offset + Vec3(2.0f * num_walls - 1, 1, 0), Vec3(-speed, 0, -speed), new SphereShape(radius));
+		CreateDynamicObject(offset + Vec3(2.0f * num_walls - 1, 1, 0), Vec3(-speed, 0, -speed), new SphereShape(radius));
 	}
 	}
 
 
 	offset += Vec3(0, 0, 5);
 	offset += Vec3(0, 0, 5);
@@ -129,7 +110,7 @@ void HighSpeedTest::CreateSimpleScene()
 		CreateDominoBlocks(offset, num_walls, density, radius);
 		CreateDominoBlocks(offset, num_walls, density, radius);
 
 
 		// Fast moving sphere against domino blocks
 		// Fast moving sphere against domino blocks
-		CreateDynamicObject("Sphere Against Domino", offset + Vec3(2.0f * num_walls - 1, 1, 0), Vec3(-speed, 0, -speed), new SphereShape(radius));
+		CreateDynamicObject(offset + Vec3(2.0f * num_walls - 1, 1, 0), Vec3(-speed, 0, -speed), new SphereShape(radius));
 	}
 	}
 
 
 	offset += Vec3(0, 0, 5);
 	offset += Vec3(0, 0, 5);
@@ -139,15 +120,15 @@ void HighSpeedTest::CreateSimpleScene()
 		CreateDominoBlocks(offset, num_walls, density, radius);
 		CreateDominoBlocks(offset, num_walls, density, radius);
 
 
 		// Fast moving scaled box against domino blocks
 		// Fast moving scaled box against domino blocks
-		CreateDynamicObject("Scaled Box Against Domino", offset + Vec3(2.0f * num_walls - 1, 1, 0), Vec3(-speed, 0, -speed), new ScaledShape(new BoxShape(Vec3::sReplicate(0.5f * radius), 0.01f), Vec3::sReplicate(2.0f)));
+		CreateDynamicObject(offset + Vec3(2.0f * num_walls - 1, 1, 0), Vec3(-speed, 0, -speed), new ScaledShape(new BoxShape(Vec3::sReplicate(0.5f * radius), 0.01f), Vec3::sReplicate(2.0f)));
 	}
 	}
 
 
 	offset += Vec3(0, 0, 5);
 	offset += Vec3(0, 0, 5);
 
 
 	{
 	{
 		// Fast moving box stuck in ground moving, one moving up, one moving down
 		// Fast moving box stuck in ground moving, one moving up, one moving down
-		CreateDynamicObject("Stuck In Ground Up", offset + Vec3(-1, 0, 0), Vec3(0, speed, 0), new BoxShape(Vec3::sReplicate(radius)));
-		CreateDynamicObject("Stuck In Ground Down", offset + Vec3(1, 0, 0), Vec3(0, -speed, 0), new BoxShape(Vec3::sReplicate(radius)));
+		CreateDynamicObject(offset + Vec3(-1, 0, 0), Vec3(0, speed, 0), new BoxShape(Vec3::sReplicate(radius)));
+		CreateDynamicObject(offset + Vec3(1, 0, 0), Vec3(0, -speed, 0), new BoxShape(Vec3::sReplicate(radius)));
 	}
 	}
 
 
 	offset += Vec3(0, 0, 5);
 	offset += Vec3(0, 0, 5);
@@ -166,51 +147,50 @@ void HighSpeedTest::CreateSimpleScene()
 		enclosing_settings.mObjectLayer = Layers::MOVING;
 		enclosing_settings.mObjectLayer = Layers::MOVING;
 		enclosing_settings.mPosition = offset + Vec3(0, 1, 0);
 		enclosing_settings.mPosition = offset + Vec3(0, 1, 0);
 		Body &enclosing = *mBodyInterface->CreateBody(enclosing_settings);
 		Body &enclosing = *mBodyInterface->CreateBody(enclosing_settings);
-		JPH_IF_DEBUG(enclosing.SetDebugName("Enclosing Box");)
 		mBodyInterface->AddBody(enclosing.GetID(), EActivation::Activate);
 		mBodyInterface->AddBody(enclosing.GetID(), EActivation::Activate);
 
 
 		// Fast moving sphere in box
 		// Fast moving sphere in box
-		CreateDynamicObject("Sphere In Box", offset + Vec3(0, 0.5f, 0), Vec3(-speed, 0, -0.5f * speed), new SphereShape(radius));
+		CreateDynamicObject(offset + Vec3(0, 0.5f, 0), Vec3(-speed, 0, -0.5f * speed), new SphereShape(radius));
 	}
 	}
 
 
 	offset += Vec3(0, 0, 5);
 	offset += Vec3(0, 0, 5);
 
 
 	{
 	{
 		// Two boxes on a collision course
 		// Two boxes on a collision course
-		CreateDynamicObject("Box Vs Box Centered 1", offset + Vec3(1, 0.5f, 0), Vec3(-speed, 0, 0), new BoxShape(Vec3::sReplicate(radius)));
-		CreateDynamicObject("Box Vs Box Centered 2", offset + Vec3(-1, 0.5f, 0), Vec3(speed, 0, 0), new BoxShape(Vec3::sReplicate(radius)));
+		CreateDynamicObject(offset + Vec3(1, 0.5f, 0), Vec3(-speed, 0, 0), new BoxShape(Vec3::sReplicate(radius)));
+		CreateDynamicObject(offset + Vec3(-1, 0.5f, 0), Vec3(speed, 0, 0), new BoxShape(Vec3::sReplicate(radius)));
 	}
 	}
 
 
 	offset += Vec3(0, 0, 5);
 	offset += Vec3(0, 0, 5);
 
 
 	{
 	{
 		// Two boxes on a collision course, off center
 		// Two boxes on a collision course, off center
-		CreateDynamicObject("Box Vs Box Off Center 1", offset + Vec3(1, 0.5f, 0), Vec3(-speed, 0, 0), new BoxShape(Vec3::sReplicate(radius)));
-		CreateDynamicObject("Box Vs Box Off Center 2", offset + Vec3(-1, 0.5f, radius), Vec3(speed, 0, 0), new BoxShape(Vec3::sReplicate(radius)));
+		CreateDynamicObject(offset + Vec3(1, 0.5f, 0), Vec3(-speed, 0, 0), new BoxShape(Vec3::sReplicate(radius)));
+		CreateDynamicObject(offset + Vec3(-1, 0.5f, radius), Vec3(speed, 0, 0), new BoxShape(Vec3::sReplicate(radius)));
 	}
 	}
 
 
 	offset += Vec3(0, 0, 5);
 	offset += Vec3(0, 0, 5);
 
 
 	{
 	{
 		// Two boxes on a collision course, one discrete
 		// Two boxes on a collision course, one discrete
-		CreateDynamicObject("Box Vs Discrete Box 1", offset + Vec3(1, 0.5f, 0), Vec3(-speed, 0, 0), new BoxShape(Vec3::sReplicate(radius)));
-		CreateDynamicObject("Box Vs Discrete Box 2", offset + Vec3(-1, 0.5f, 0), Vec3(60.0f, 0, 0), new BoxShape(Vec3::sReplicate(radius)), EMotionQuality::Discrete);
+		CreateDynamicObject(offset + Vec3(1, 0.5f, 0), Vec3(-speed, 0, 0), new BoxShape(Vec3::sReplicate(radius)));
+		CreateDynamicObject(offset + Vec3(-1, 0.5f, 0), Vec3(60.0f, 0, 0), new BoxShape(Vec3::sReplicate(radius)), EMotionQuality::Discrete);
 	}
 	}
 
 
 	offset += Vec3(0, 0, 5);
 	offset += Vec3(0, 0, 5);
 
 
 	{
 	{
 		// Two boxes on a collision course, one inactive
 		// Two boxes on a collision course, one inactive
-		CreateDynamicObject("Box Vs Inactive Box 1", offset + Vec3(1, 0.5f, 0), Vec3(-speed, 0, 0), new BoxShape(Vec3::sReplicate(radius)));
-		CreateDynamicObject("Box Vs Inactive Box 2", offset + Vec3(0, 0.5f, 0), Vec3::sZero(), new BoxShape(Vec3::sReplicate(radius)));
+		CreateDynamicObject(offset + Vec3(1, 0.5f, 0), Vec3(-speed, 0, 0), new BoxShape(Vec3::sReplicate(radius)));
+		CreateDynamicObject(offset + Vec3(0, 0.5f, 0), Vec3::sZero(), new BoxShape(Vec3::sReplicate(radius)));
 	}
 	}
 
 
 	offset += Vec3(0, 0, 5);
 	offset += Vec3(0, 0, 5);
 
 
 	{
 	{
 		// Two boxes on a collision course, one inactive and discrete
 		// Two boxes on a collision course, one inactive and discrete
-		CreateDynamicObject("Box Vs Inactive Discrete Box 1", offset + Vec3(1, 0.5f, 0), Vec3(-speed, 0, 0), new BoxShape(Vec3::sReplicate(radius)));
-		CreateDynamicObject("Box Vs Inactive Discrete Box 2", offset + Vec3(0, 0.5f, 0), Vec3::sZero(), new BoxShape(Vec3::sReplicate(radius)), EMotionQuality::Discrete);
+		CreateDynamicObject(offset + Vec3(1, 0.5f, 0), Vec3(-speed, 0, 0), new BoxShape(Vec3::sReplicate(radius)));
+		CreateDynamicObject(offset + Vec3(0, 0.5f, 0), Vec3::sZero(), new BoxShape(Vec3::sReplicate(radius)), EMotionQuality::Discrete);
 	}
 	}
 
 
 	offset += Vec3(0, 0, 5);
 	offset += Vec3(0, 0, 5);
@@ -331,7 +311,6 @@ void HighSpeedTest::CreateFastSmallConvexObjects()
 
 
 				Body &body = *mPhysicsSystem->GetBodyInterface().CreateBody(body_settings);
 				Body &body = *mPhysicsSystem->GetBodyInterface().CreateBody(body_settings);
 				body.SetLinearVelocity(Vec3(velocity_distrib(rnd), -100.0f, velocity_distrib(rnd)));
 				body.SetLinearVelocity(Vec3(velocity_distrib(rnd), -100.0f, velocity_distrib(rnd)));
-				JPH_IF_DEBUG(body.SetDebugName(StringFormat("%dx%d", x, y));)
 				mPhysicsSystem->GetBodyInterface().AddBody(body.GetID(), EActivation::Activate);
 				mPhysicsSystem->GetBodyInterface().AddBody(body.GetID(), EActivation::Activate);
 			}
 			}
 		}
 		}

+ 1 - 1
Samples/Tests/General/HighSpeedTest.h

@@ -22,7 +22,7 @@ public:
 	virtual void		CreateSettingsMenu(DebugUI *inUI, UIElement *inSubMenu) override;
 	virtual void		CreateSettingsMenu(DebugUI *inUI, UIElement *inSubMenu) override;
 
 
 private:
 private:
-	void				CreateDynamicObject(const char *inName, Vec3 inPosition, Vec3 inVelocity, Shape *inShape, EMotionQuality inMotionQuality = EMotionQuality::LinearCast);
+	void				CreateDynamicObject(Vec3 inPosition, Vec3 inVelocity, Shape *inShape, EMotionQuality inMotionQuality = EMotionQuality::LinearCast);
 	void				CreateDominoBlocks(Vec3Arg inOffset, int inNumWalls, float inDensity, float inRadius);
 	void				CreateDominoBlocks(Vec3Arg inOffset, int inNumWalls, float inDensity, float inRadius);
 	void				CreateFastSmallConvexObjects();
 	void				CreateFastSmallConvexObjects();
 	void				CreateSimpleScene();
 	void				CreateSimpleScene();

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

@@ -33,17 +33,12 @@ void SensorTest::Initialize()
 	BodyCreationSettings sensor_settings(new SphereShape(10.0f), Vec3(0, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING);
 	BodyCreationSettings sensor_settings(new SphereShape(10.0f), Vec3(0, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING);
 	sensor_settings.mIsSensor = true;
 	sensor_settings.mIsSensor = true;
 	Body &sensor = *mBodyInterface->CreateBody(sensor_settings);
 	Body &sensor = *mBodyInterface->CreateBody(sensor_settings);
-	JPH_IF_DEBUG(sensor.SetDebugName("Sensor");)
 	mSensorID = sensor.GetID();
 	mSensorID = sensor.GetID();
 	mBodyInterface->AddBody(mSensorID, EActivation::DontActivate);
 	mBodyInterface->AddBody(mSensorID, EActivation::DontActivate);
 
 
 	// Dynamic bodies
 	// Dynamic bodies
 	for (int i = 0; i < 10; ++i)
 	for (int i = 0; i < 10; ++i)
-	{
-		Body &body = *mBodyInterface->CreateBody(BodyCreationSettings(new BoxShape(Vec3(0.1f, 0.5f, 0.2f)), Vec3(-15.0f + i * 3.0f, 25, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING));
-		JPH_IF_DEBUG(body.SetDebugName("Body " + ConvertToString(i)));
-		mBodyInterface->AddBody(body.GetID(), EActivation::Activate);
-	}
+		mBodyInterface->CreateAndAddBody(BodyCreationSettings(new BoxShape(Vec3(0.1f, 0.5f, 0.2f)), Vec3(-15.0f + i * 3.0f, 25, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
 
 
 	// Load ragdoll
 	// Load ragdoll
 	Ref<RagdollSettings> ragdoll_settings = RagdollLoader::sLoad("Assets/Human.tof", EMotionType::Dynamic);
 	Ref<RagdollSettings> ragdoll_settings = RagdollLoader::sLoad("Assets/Human.tof", EMotionType::Dynamic);

+ 0 - 12
Samples/Tests/Test.cpp

@@ -20,9 +20,6 @@ Body &Test::CreateFloor()
 	const float scale = GetWorldScale();
 	const float scale = GetWorldScale();
 
 
 	Body &floor = *mBodyInterface->CreateBody(BodyCreationSettings(new BoxShape(scale * Vec3(100.0f, 1.0f, 100.0f), 0.0f), scale * Vec3(0.0f, -1.0f, 0.0f), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING));
 	Body &floor = *mBodyInterface->CreateBody(BodyCreationSettings(new BoxShape(scale * Vec3(100.0f, 1.0f, 100.0f), 0.0f), scale * Vec3(0.0f, -1.0f, 0.0f), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING));
-#ifdef _DEBUG
-	floor.SetDebugName("Floor");
-#endif
 	mBodyInterface->AddBody(floor.GetID(), EActivation::DontActivate);
 	mBodyInterface->AddBody(floor.GetID(), EActivation::DontActivate);
 	return floor;
 	return floor;
 }
 }
@@ -100,9 +97,6 @@ Body &Test::CreateLargeTriangleFloor()
 	mesh_settings.SetEmbedded();
 	mesh_settings.SetEmbedded();
 	BodyCreationSettings floor_settings(&mesh_settings, Vec3(-256.0f, 0.0f, 256.0f), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING);
 	BodyCreationSettings floor_settings(&mesh_settings, Vec3(-256.0f, 0.0f, 256.0f), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING);
 	Body &floor = *mBodyInterface->CreateBody(floor_settings);
 	Body &floor = *mBodyInterface->CreateBody(floor_settings);
-#ifdef _DEBUG
-	floor.SetDebugName("Floor");
-#endif
 	mBodyInterface->AddBody(floor.GetID(), EActivation::DontActivate);
 	mBodyInterface->AddBody(floor.GetID(), EActivation::DontActivate);
 	return floor;
 	return floor;
 }
 }
@@ -149,9 +143,6 @@ Body &Test::CreateMeshTerrain()
 
 
 	// Floor
 	// Floor
 	Body &floor = *mBodyInterface->CreateBody(BodyCreationSettings(new MeshShapeSettings(triangles), Vec3::sZero(), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING));
 	Body &floor = *mBodyInterface->CreateBody(BodyCreationSettings(new MeshShapeSettings(triangles), Vec3::sZero(), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING));
-#ifdef _DEBUG
-	floor.SetDebugName("Terrain");
-#endif
 	mBodyInterface->AddBody(floor.GetID(), EActivation::DontActivate);
 	mBodyInterface->AddBody(floor.GetID(), EActivation::DontActivate);
 	return floor;
 	return floor;
 }
 }
@@ -175,9 +166,6 @@ Body &Test::CreateHeightFieldTerrain()
 
 
 	// Floor
 	// Floor
 	Body &floor = *mBodyInterface->CreateBody(BodyCreationSettings(height_field, Vec3::sZero(), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING));
 	Body &floor = *mBodyInterface->CreateBody(BodyCreationSettings(height_field, Vec3::sZero(), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING));
-#ifdef _DEBUG
-	floor.SetDebugName("Terrain");
-#endif
 	mBodyInterface->AddBody(floor.GetID(), EActivation::DontActivate);
 	mBodyInterface->AddBody(floor.GetID(), EActivation::DontActivate);
 	return floor;
 	return floor;
 }
 }

+ 0 - 10
Samples/Tests/Vehicle/VehicleSixDOFTest.cpp

@@ -36,10 +36,6 @@ void VehicleSixDOFTest::Initialize()
 		Vec3(half_vehicle_width, -half_vehicle_height, -half_vehicle_length + 2.0f * half_wheel_height),
 		Vec3(half_vehicle_width, -half_vehicle_height, -half_vehicle_length + 2.0f * half_wheel_height),
 	};
 	};
 
 
-#ifdef _DEBUG
-	const char *wheel_names[] = { "LeftFront", "RightFront", "LeftRear", "RightRear" };
-#endif
-
 	Vec3 position(0, 2, 0);
 	Vec3 position(0, 2, 0);
 
 
 	RefConst<Shape> body_shape = new BoxShape(Vec3(half_vehicle_width, half_vehicle_height, half_vehicle_length));
 	RefConst<Shape> body_shape = new BoxShape(Vec3(half_vehicle_width, half_vehicle_height, half_vehicle_length));
@@ -52,9 +48,6 @@ void VehicleSixDOFTest::Initialize()
 
 
 	// Create vehicle body
 	// Create vehicle body
 	mCarBody = mBodyInterface->CreateBody(BodyCreationSettings(body_shape, position, Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING));
 	mCarBody = mBodyInterface->CreateBody(BodyCreationSettings(body_shape, position, Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING));
-#ifdef _DEBUG
-	mCarBody->SetDebugName("CarBody");
-#endif
 	mCarBody->SetCollisionGroup(CollisionGroup(group_filter, 0, 0));
 	mCarBody->SetCollisionGroup(CollisionGroup(group_filter, 0, 0));
 	mBodyInterface->AddBody(mCarBody->GetID(), EActivation::Activate);
 	mBodyInterface->AddBody(mCarBody->GetID(), EActivation::Activate);
 
 
@@ -70,9 +63,6 @@ void VehicleSixDOFTest::Initialize()
 		// Create body
 		// Create body
 		Body &wheel = *mBodyInterface->CreateBody(BodyCreationSettings(wheel_shape, wheel_pos2, Quat::sRotation(Vec3::sAxisZ(), 0.5f * JPH_PI), EMotionType::Dynamic, Layers::MOVING));
 		Body &wheel = *mBodyInterface->CreateBody(BodyCreationSettings(wheel_shape, wheel_pos2, Quat::sRotation(Vec3::sAxisZ(), 0.5f * JPH_PI), EMotionType::Dynamic, Layers::MOVING));
 		wheel.SetFriction(1.0f);
 		wheel.SetFriction(1.0f);
-#ifdef _DEBUG
-		wheel.SetDebugName(wheel_names[i]);
-#endif
 		wheel.SetCollisionGroup(CollisionGroup(group_filter, 0, 0));
 		wheel.SetCollisionGroup(CollisionGroup(group_filter, 0, 0));
 		mBodyInterface->AddBody(wheel.GetID(), EActivation::Activate);
 		mBodyInterface->AddBody(wheel.GetID(), EActivation::Activate);
 
 

+ 0 - 3
Samples/Tests/Vehicle/VehicleTest.cpp

@@ -85,9 +85,6 @@ void VehicleTest::CreateBridge()
 
 
 		Body &part = i == 0? *mBodyInterface->CreateBody(BodyCreationSettings(large_part_shape, pos - first_part_rot * Vec3(0, large_part_half_size.GetY() - part_half_size.GetY(), large_part_half_size.GetZ() - part_half_size.GetZ()), first_part_rot, EMotionType::Static, Layers::NON_MOVING))
 		Body &part = i == 0? *mBodyInterface->CreateBody(BodyCreationSettings(large_part_shape, pos - first_part_rot * Vec3(0, large_part_half_size.GetY() - part_half_size.GetY(), large_part_half_size.GetZ() - part_half_size.GetZ()), first_part_rot, EMotionType::Static, Layers::NON_MOVING))
 					: *mBodyInterface->CreateBody(BodyCreationSettings(part_shape, pos, Quat::sIdentity(), i == 19? EMotionType::Static : EMotionType::Dynamic, i == 19? Layers::NON_MOVING : Layers::MOVING));
 					: *mBodyInterface->CreateBody(BodyCreationSettings(part_shape, pos, Quat::sIdentity(), i == 19? EMotionType::Static : EMotionType::Dynamic, i == 19? Layers::NON_MOVING : Layers::MOVING));
-	#ifdef _DEBUG
-		part.SetDebugName("Bridge Part " + ConvertToString(i));
-	#endif
 		part.SetCollisionGroup(CollisionGroup(group_filter, 1, CollisionGroup::SubGroupID(i)));
 		part.SetCollisionGroup(CollisionGroup(group_filter, 1, CollisionGroup::SubGroupID(i)));
 		part.SetFriction(1.0f);
 		part.SetFriction(1.0f);
 		mBodyInterface->AddBody(part.GetID(), EActivation::Activate);
 		mBodyInterface->AddBody(part.GetID(), EActivation::Activate);

+ 0 - 3
UnitTests/PhysicsTestContext.cpp

@@ -46,9 +46,6 @@ Body &PhysicsTestContext::CreateFloor()
 	settings.mObjectLayer = Layers::NON_MOVING;
 	settings.mObjectLayer = Layers::NON_MOVING;
 
 
 	Body &floor = *mSystem->GetBodyInterface().CreateBody(settings);
 	Body &floor = *mSystem->GetBodyInterface().CreateBody(settings);
-#ifdef _DEBUG
-	floor.SetDebugName("Floor");
-#endif
 	mSystem->GetBodyInterface().AddBody(floor.GetID(), EActivation::DontActivate);
 	mSystem->GetBodyInterface().AddBody(floor.GetID(), EActivation::DontActivate);
 	return floor;
 	return floor;
 }
 }