Fix multiple issues with one-way collisions

For RigidBodies, uses the collision normal determined by relative motion
to determine whether or not a one-way collision has occurred.

For KinematicBodies, performs additional checks to ensure a one-way
collision has occurred, and averages the recovery step over all collision
shapes.

Co-authored-by:    Sergej Gureev <sergej.gureev@relex.fi>
This commit is contained in:
Marcel Admiraal
2020-10-05 14:32:50 +01:00
parent a18df71789
commit 1061bb364e
4 changed files with 43 additions and 60 deletions

View File

@ -645,7 +645,7 @@ int SpaceSW::test_body_ray_separation(BodySW *p_body, const Transform &p_transfo
Vector3 a = sr[k * 2 + 0];
Vector3 b = sr[k * 2 + 1];
recover_motion += (b - a) * 0.4;
recover_motion += (b - a) / cbk.amount;
float depth = a.distance_to(b);
if (depth > result.collision_depth) {
@ -791,7 +791,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
Vector3 a = sr[i * 2 + 0];
Vector3 b = sr[i * 2 + 1];
recover_motion += (b - a) * 0.4;
recover_motion += (b - a) / cbk.amount;
}
if (recover_motion == Vector3()) {