godotengine / godotengine/godot

Internal edge collision and penetration of concave CollisionPolygon2D

Open
#89,778 0 comments 0 reactions 0 assignees View on GitHub
discussion needs testing topic:2d topic:physics
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

v3.5.2.stable.mono.official [170ba337a]

### System information

WIndows 10

### Issue description

Physical bodies that should be able to slide across a CollisionPolygon2D concave suface, instead regularly catch or penetrate it at its corners.
The engine decomposes the concave polygon into convex polys, and it appears to essentially function as a set of separate shapes. Its surface is no longer continuous, instead the added internal edges seem to introduce unexpected collisions to a sliding body and in some cases can aggravate penetration.
No continuous collision or other settings found to be effective against this issue.
https://github.com/godotengine/godot/assets/7935207/70472521-9233-4817-bd65-ca1907cb7ed1

A polygon is expected to function as a singular shape with continuous surface. Decomposition the engine applies to it is expected to introduce no new collision surfaces or holes. Collision processing is expected to avoid penetration of shapes (at least in Solids + CCD) so long as the constraints acting on bodies allow that.

### Steps to reproduce

The attached project contains a scene with a concave static body, and a wedge shaped rigid body driven across its surface.
- enable Visible Collision Shapes
- run TestConcaveSliding.tscn, observe the rigid body occasionally penetrate into static body between the convex subshapes it is decomposed into, observe collisions indicated at the internal edges of the static body

### Minimal reproduction project (MRP)

[TestConcaveSliding.zip](https://github.com/godotengine/godot/files/14720657/TestConcaveSliding.zip)
TestConcaveSliding.tscn demonstrates sliding across an automatically decomposed concave shape and the penetration it results in.
TestConcaveSliding2.tscn demonstrates sliding across a concave shape with the same surface outline, but decomposed into convex subshapes in a different way that manages to prevent penetration.

Contributor guide

Open the contributing guide

Research direction

Run the attached reproduction project with Visible Collision Shapes enabled, starting with TestConcaveSliding.tscn and comparing it with TestConcaveSliding2.tscn. Inspect how the two concave decompositions behave while the wedge slides across the surface. Done means the concave shape has no unexpected internal-edge collisions, holes, or penetration during the demonstrated motion.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.