Browse Source

Bugfix: It was possible to trigger an assert in CharacterVirtual, changed to early out

Jorrit Rouwe 2 years ago
parent
commit
57190cd0ab
1 changed files with 2 additions and 1 deletions
  1. 2 1
      Jolt/Physics/Character/CharacterVirtual.cpp

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

@@ -1179,7 +1179,8 @@ bool CharacterVirtual::WalkStairs(float inDeltaTime, Vec3Arg inStepUp, Vec3Arg i
 			&& c.mSurfaceNormal.Dot(horizontal_velocity - c.mLinearVelocity) < 0.0f // Pushing into the contact
 			&& c.mSurfaceNormal.Dot(horizontal_velocity - c.mLinearVelocity) < 0.0f // Pushing into the contact
 			&& IsSlopeTooSteep(c.mSurfaceNormal)) // Slope too steep
 			&& IsSlopeTooSteep(c.mSurfaceNormal)) // Slope too steep
 			steep_slope_normals.push_back(c.mSurfaceNormal);
 			steep_slope_normals.push_back(c.mSurfaceNormal);
-	JPH_ASSERT(!steep_slope_normals.empty(), "CanWalkStairs should have returned false!");
+	if (steep_slope_normals.empty())
+		return false; // No steep slopes, cancel
 
 
 	// Horizontal movement
 	// Horizontal movement
 	RVec3 new_position = up_position;
 	RVec3 new_position = up_position;