From 5e2477e5711f468bdb342333a6baf034cf56a5bd Mon Sep 17 00:00:00 2001 From: Markus Mikonsaari Date: Thu, 28 Mar 2024 00:42:01 +0200 Subject: [PATCH] Fix separating axes for 3D cylinder-face collisions When checking for lateral surfaces of a cylinder against the points on a face, the axis projection does not remove the cylinder position. This results in the axis pointing to the wrong direction and reports collisions when there shouldn't be. (cherry picked from commit 3f69af9e64760a9a56dc175b8e23289e6d8dfc25) --- servers/physics_3d/godot_collision_solver_3d_sat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servers/physics_3d/godot_collision_solver_3d_sat.cpp b/servers/physics_3d/godot_collision_solver_3d_sat.cpp index 3aa2f256c18..5a3d58c3c7d 100644 --- a/servers/physics_3d/godot_collision_solver_3d_sat.cpp +++ b/servers/physics_3d/godot_collision_solver_3d_sat.cpp @@ -1962,7 +1962,7 @@ static void _collision_cylinder_face(const GodotShape3D *p_a, const Transform3D // Points of B, cylinder lateral surface. for (int i = 0; i < 3; i++) { - const Vector3 &point = vertex[i]; + const Vector3 point = vertex[i] - p_transform_a.origin; Vector3 axis = Plane(cyl_axis).project(point).normalized(); if (axis.dot(normal) < 0.0) { axis *= -1.0;