godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.88k stars 21.02k forks source link

Improper normal detection with CharacterBody3D on edges of trimesh collision shapes #70508

Open Gamepro5 opened 1 year ago

Gamepro5 commented 1 year ago

Godot version

4.0.2 Stable

System information

Windows 10; Intel(R) Core(TM) i7-10875H CPU @ 2.30GHz 2.30 GHz

Issue description

Corners of CharacterBody collision shapes don't properly detect the collision normal. This happens on the corners of rectangular collider shapes and also at the very vertex of the capsule shape when on a flat version of the slope included in this example project. This is likely related to https://github.com/godotengine/godot/issues/69137.

https://user-images.githubusercontent.com/23440295/209416069-09db21b8-3a43-45ee-b46e-ed5f879dbddd.mp4

There is a high chance that this also happens on the edges of all shapes, not just concave collision shapes. It's harder to replicate with primitive shapes because the angles between the edges are usually 90 degrees.

Steps to reproduce

1.) Download the sample project 2.) Turn on visible collision shapes 3.) Slowly move on the line (the edge of the concave shape) 4.) Observe as the raycast that shows the floor normal does not properly show the normal when on the "crack".

Minimal reproduction project

NormalDetectionBug.zip

Gamepro5 commented 1 year ago

This bug seems to happen to edges of shapes in general, not just trimesh. It's harder to replicate on a rectangular shape because the edges are 90 degrees, but I did notice some odd behavior when colliding with the edge of these shapes.

mgiraud commented 1 year ago

I've experienced the same issue with 2 rigidbodies colliding

I could log that some times the collision normal was completely wrong

Edit : I found this old discussion on bullet3 project which might be related to issue : https://github.com/bulletphysics/bullet3/discussions/3473 and there are some tickets on UE4 that describe somehow the same problem

etodd commented 1 year ago

I'm currently running into this as well, with a spherical RigidBody3D and a trimesh.

edit: this worked fine for me all the way up through 4.0.3 RC2, then started causing problems in 4.1 dev 2.

FischeritDE commented 9 months ago

Same here. Rigidbody sphere & CSG Mesh or mesh with hole

Bildschirmfoto 2023-12-30 um 20 12 54