Merge pull request #40490 from madmiraal/fix-40381-3.2

[3.2] Use difference in position to check whether motion in Bullet is too close to zero.
This commit is contained in:
Rémi Verschelde 2020-07-20 14:53:11 +02:00 committed by GitHub
commit 7f62c6a81e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

View File

@ -160,9 +160,6 @@ bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transf
btVector3 bt_motion;
G_TO_B(p_motion, bt_motion);
if (bt_motion.fuzzyZero())
return false;
ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape);
ERR_FAIL_COND_V(!shape, false);
@ -181,6 +178,10 @@ bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transf
btTransform bt_xform_to(bt_xform_from);
bt_xform_to.getOrigin() += bt_motion;
if ((bt_xform_to.getOrigin() - bt_xform_from.getOrigin()).fuzzyZero()) {
return false;
}
GodotClosestConvexResultCallback btResult(bt_xform_from.getOrigin(), bt_xform_to.getOrigin(), &p_exclude, p_collide_with_bodies, p_collide_with_areas);
btResult.m_collisionFilterGroup = 0;
btResult.m_collisionFilterMask = p_collision_mask;
@ -969,7 +970,7 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f
motionVec->end();
#endif
for (int shIndex = 0; shIndex < shape_count && !motion.fuzzyZero(); ++shIndex) {
for (int shIndex = 0; shIndex < shape_count; ++shIndex) {
if (p_body->is_shape_disabled(shIndex)) {
continue;
}
@ -991,6 +992,11 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f
btTransform shape_world_to(shape_world_from);
shape_world_to.getOrigin() += motion;
if ((shape_world_to.getOrigin() - shape_world_from.getOrigin()).fuzzyZero()) {
motion = btVector3(0, 0, 0);
break;
}
GodotKinClosestConvexResultCallback btResult(shape_world_from.getOrigin(), shape_world_to.getOrigin(), p_body, p_infinite_inertia);
btResult.m_collisionFilterGroup = p_body->get_collision_layer();
btResult.m_collisionFilterMask = p_body->get_collision_mask();