瀏覽代碼

Fix RayShape collision jitter when used with a RigidBody

Scaling the depth was the wrong solution for the KinematicBody jitter
because it causes jitter with RigidBody. Instead scale the margin that
is ignored to allow KinematicBody to still pick up the ray shape in the
kinematic test when the shape is just at margin distance from another
one. This solution does not cause jitter with either KinematicBody or
RigidBody.
Daniel Rakos 6 年之前
父節點
當前提交
6587024207
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      modules/bullet/godot_ray_world_algorithm.cpp

+ 2 - 2
modules/bullet/godot_ray_world_algorithm.cpp

@@ -100,8 +100,8 @@ void GodotRayWorldAlgorithm::processCollision(const btCollisionObjectWrapper *bo
 
 
 		btScalar depth(ray_shape->getScaledLength() * (btResult.m_closestHitFraction - 1));
 		btScalar depth(ray_shape->getScaledLength() * (btResult.m_closestHitFraction - 1));
 
 
-		if (depth >= -ray_shape->getMargin())
-			depth *= 0.5;
+		if (depth >= -ray_shape->getMargin() * 0.5)
+			depth = 0;
 
 
 		if (ray_shape->getSlipsOnSlope())
 		if (ray_shape->getSlipsOnSlope())
 			resultOut->addContactPoint(btResult.m_hitNormalWorld, btResult.m_hitPointWorld, depth);
 			resultOut->addContactPoint(btResult.m_hitNormalWorld, btResult.m_hitPointWorld, depth);