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 3f69af9e64)
This commit is contained in:
Markus Mikonsaari 2024-03-28 00:42:01 +02:00 committed by Rémi Verschelde
parent 7af7902121
commit 5e2477e571
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 1 additions and 1 deletions

View File

@ -1962,7 +1962,7 @@ static void _collision_cylinder_face(const GodotShape3D *p_a, const Transform3D
// Points of B, cylinder lateral surface. // Points of B, cylinder lateral surface.
for (int i = 0; i < 3; i++) { 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(); Vector3 axis = Plane(cyl_axis).project(point).normalized();
if (axis.dot(normal) < 0.0) { if (axis.dot(normal) < 0.0) {
axis *= -1.0; axis *= -1.0;