Przeglądaj źródła

Fixed another case where characters could get stuck when wedged between steep slopes. (#1887)

The vertical planes that we create to prevent characters from moving up steep slopes included the depenetration velocity, which if the planes surrounded the character on all sides prevented the character from moving at all.
Jorrit Rouwe 6 dni temu
rodzic
commit
cae438db6f

+ 1 - 1
.github/workflows/determinism_check.yml

@@ -4,7 +4,7 @@ env:
   CONVEX_VS_MESH_HASH: '0xa7348cad585544bf'
   RAGDOLL_HASH: '0xc392d8f867b0be5b'
   PYRAMID_HASH: '0xafd93b295e75e3f6'
-  CHARACTER_VIRTUAL_HASH: '0x5bb957ed934a01f3'
+  CHARACTER_VIRTUAL_HASH: '0x898879a1a04196bb'
   EMSCRIPTEN_VERSION: 4.0.22
   NODE_VERSION: 24.x
   UBUNTU_CLANG_VERSION: clang++-18

+ 1 - 1
Jolt/Physics/Character/CharacterVirtual.cpp

@@ -683,7 +683,7 @@ void CharacterVirtual::DetermineConstraints(TempContactList &inContacts, float i
 				outConstraints.emplace_back();
 				Constraint &vertical_constraint = outConstraints.back();
 				vertical_constraint.mContact = &c;
-				vertical_constraint.mLinearVelocity = contact_velocity.Dot(normal) * normal; // Project the contact velocity on the new normal so that both planes push at an equal rate
+				vertical_constraint.mLinearVelocity = c.mLinearVelocity.Dot(normal) * normal; // Project the contact velocity on the new normal so that both planes push at an equal rate. We ignore velocity added to push characters out of collision as that can get characters stuck if they are surrounded on all sides by steep slopes.
 				vertical_constraint.mPlane = Plane(normal, c.mDistance / normal.Dot(c.mContactNormal)); // Calculate the distance we have to travel horizontally to hit the contact plane
 			}
 		}

+ 1 - 1
UnitTests/Physics/CharacterVirtualTests.cpp

@@ -821,7 +821,7 @@ TEST_SUITE("CharacterVirtualTests")
 			character.Step();
 		RVec3 expected_position = starting_position + character.mHorizontalSpeed * cNumSteps * c.GetDeltaTime();
 		expected_position.SetY(0);
-		CHECK_APPROX_EQUAL(character.GetPosition(), expected_position, 1e-3f);
+		CHECK_APPROX_EQUAL(character.GetPosition(), expected_position, 0.05f);
 	}
 
 	TEST_CASE("TestCharacterVsCharacter")