Skip to content

Commit

Permalink
Merge pull request microsoft#2473 from madratman/PR/2357
Browse files Browse the repository at this point in the history
FastPhysicsEngine: body isGrounded logic fix
  • Loading branch information
madratman authored Mar 23, 2020
2 parents f84fdd0 + ea73cd4 commit 4cddf3f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions AirLib/include/physics/FastPhysicsEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,11 @@ class FastPhysicsEngine : public PhysicsEngineBase {
const Wrench body_wrench = getBodyWrench(body, current.pose.orientation);

if (body.isGrounded()) {
// make it stick to the ground until we see body wrench force greater than gravity.
float normalizedForce = body_wrench.force.squaredNorm();
float normalizedGravity = body.getEnvironment().getState().gravity.squaredNorm();
if (normalizedForce >= normalizedGravity)
// make it stick to the ground until the magnitude of net external force on body exceeds its weight.
float external_force_magnitude = body_wrench.force.squaredNorm();
Vector3r weight = body.getMass() * body.getEnvironment().getState().gravity;
float weight_magnitude = weight.squaredNorm();
if (external_force_magnitude >= weight_magnitude)
{
//throttledLogOutput("*** Losing ground lock due to body_wrench " + VectorMath::toString(body_wrench.force), 0.1);
body.setGrounded(false);
Expand Down

0 comments on commit 4cddf3f

Please sign in to comment.