Browse Source

LoadSnapshotTest: Soft bodies also need their layers overridden / orientations fixed

Jorrit Rouwe 1 month ago
parent
commit
be9036cf77
1 changed files with 19 additions and 1 deletions
  1. 19 1
      Samples/Tests/Tools/LoadSnapshotTest.cpp

+ 19 - 1
Samples/Tests/Tools/LoadSnapshotTest.cpp

@@ -65,12 +65,20 @@ void LoadSnapshotTest::Initialize()
 	// Determine if we are forced to override the object layers because one of the bodies has a layer number that is invalid in the context of this application
 	bool override_layers = sOverrideLayers;
 	if (!override_layers)
-		for (BodyCreationSettings &settings : scene->GetBodies())
+	{
+		for (const BodyCreationSettings &settings : scene->GetBodies())
+			if (settings.mObjectLayer >= Layers::NUM_LAYERS)
+			{
+				override_layers = true;
+				break;
+			}
+		for (const SoftBodyCreationSettings &settings : scene->GetSoftBodies())
 			if (settings.mObjectLayer >= Layers::NUM_LAYERS)
 			{
 				override_layers = true;
 				break;
 			}
+	}
 
 	for (BodyCreationSettings &settings : scene->GetBodies())
 	{
@@ -88,6 +96,16 @@ void LoadSnapshotTest::Initialize()
 		settings.mRotation = up_rotation * settings.mRotation;
 	}
 
+	for (SoftBodyCreationSettings &settings : scene->GetSoftBodies())
+	{
+		if (override_layers)
+			settings.mObjectLayer = Layers::MOVING;
+
+		// Rotate the body so that it matches Y is up
+		settings.mPosition = RMat44::sRotation(up_rotation) * settings.mPosition;
+		settings.mRotation = up_rotation * settings.mRotation;
+	}
+
 	scene->CreateBodies(mPhysicsSystem);
 }