Browse Source

Fixed ground normal and velocity when jumping against vertical wall (#266)

Jorrit Rouwe 2 years ago
parent
commit
d2b9094529

+ 5 - 0
Jolt/Physics/Character/CharacterVirtual.cpp

@@ -673,6 +673,11 @@ void CharacterVirtual::UpdateSupportingContact(bool inSkipContactVelocityCheck,
 		mGroundNormal = avg_normal.Normalized();
 		mGroundNormal = avg_normal.Normalized();
 		mGroundVelocity = avg_velocity / float(num_avg_normal);
 		mGroundVelocity = avg_velocity / float(num_avg_normal);
 	}
 	}
+	else if (supporting_contact != nullptr)
+	{
+		mGroundNormal = supporting_contact->mSurfaceNormal;
+		mGroundVelocity = supporting_contact->mLinearVelocity;
+	}
 	else
 	else
 	{
 	{
 		mGroundNormal = Vec3::sZero();
 		mGroundNormal = Vec3::sZero();

+ 6 - 1
Samples/Tests/Character/CharacterBaseTest.cpp

@@ -81,7 +81,7 @@ void CharacterBaseTest::Initialize()
 	else if (strcmp(sSceneName, "ObstacleCourse") == 0)
 	else if (strcmp(sSceneName, "ObstacleCourse") == 0)
 	{
 	{
 		// Default terrain
 		// Default terrain
-		CreateFloor(300.0f);
+		CreateFloor(350.0f);
 
 
 		{
 		{
 			// Create ramps with different inclinations
 			// Create ramps with different inclinations
@@ -177,6 +177,11 @@ void CharacterBaseTest::Initialize()
 			mBodyInterface->CreateAndAddBody(bcs, EActivation::Activate);
 			mBodyInterface->CreateAndAddBody(bcs, EActivation::Activate);
 		}
 		}
 
 
+		{
+			// A floating static block
+			mBodyInterface->CreateAndAddBody(BodyCreationSettings(new BoxShape(Vec3::sReplicate(0.5f)), Vec3(30.0f, 1.5f, 0.0f), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
+		}
+
 		{
 		{
 			// Create ramp
 			// Create ramp
 			BodyCreationSettings ramp(new BoxShape(Vec3(4.0f, 0.1f, 3.0f)), cRampPosition, cRampOrientation, EMotionType::Static, Layers::NON_MOVING);
 			BodyCreationSettings ramp(new BoxShape(Vec3(4.0f, 0.1f, 3.0f)), cRampPosition, cRampOrientation, EMotionType::Static, Layers::NON_MOVING);