From f7511511b12977d0385198ea0037ef4c62e75d47 Mon Sep 17 00:00:00 2001 From: Daniel Rakos Date: Mon, 11 Feb 2019 01:48:33 +0100 Subject: Fix RayShape collision when used with a KinematicBody (Bullet Physics) - Added code handling non-compound collision to recover_from_penetration_ray() which is now needed due to the optimization avoiding the use of compound collisions when only a single collision shape is used. - Removed arbitrary margin applied in the collision algorithm of RayShapes which causes jittered movement. For lack of a better replacement and for lack of any explanation on why it has been introduced, it's now using the shape's margin property instead which is small enough to not show visible jitter. - Tried to get rid of inconsistent uses of the collision margin. - Removed hack from GodotDeepPenetrationContactResultCallback::addContactPoint for RayShape collision as it's no longer needed as the collision algorithm of RayShapes correctly calculates the contact normal for a while now. Fixes #25227. --- modules/bullet/godot_ray_world_algorithm.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'modules/bullet/godot_ray_world_algorithm.cpp') diff --git a/modules/bullet/godot_ray_world_algorithm.cpp b/modules/bullet/godot_ray_world_algorithm.cpp index 449f625e17..cadc8dd59e 100644 --- a/modules/bullet/godot_ray_world_algorithm.cpp +++ b/modules/bullet/godot_ray_world_algorithm.cpp @@ -35,8 +35,6 @@ #include -#define RAY_STABILITY_MARGIN 0.1 - /** @author AndreaCatania */ @@ -102,8 +100,8 @@ void GodotRayWorldAlgorithm::processCollision(const btCollisionObjectWrapper *bo btScalar depth(ray_shape->getScaledLength() * (btResult.m_closestHitFraction - 1)); - if (depth >= -RAY_STABILITY_MARGIN) - depth = 0; + if (depth >= -ray_shape->getMargin()) + depth *= 0.5; if (ray_shape->getSlipsOnSlope()) resultOut->addContactPoint(btResult.m_hitNormalWorld, btResult.m_hitPointWorld, depth); -- cgit v1.2.3