godotengine / godotengine/godot

Geometry2D Union generates invalid Polygon2D/Self-intersection Transitivity

Open
#99,745 3 comments 0 reactions 0 assignees View on GitHub
confirmed discussion enhancement topic:2d
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

Reproducible in 4.3 and back in 3.x

### System information

Godot v4.3.stable - Windows 10.0.22631 - GLES3 (Compatibility) - NVIDIA GeForce RTX 4050 Laptop GPU (NVIDIA; 32.0.15.6070) - Intel(R) Core(TM) Ultra 7 155H (22 Threads)

### Issue description

So I've been experimenting with Polygon2D in the editor and managed to create some shapes that will disappear.
I'm not quite sure what the issue is since the polygon does not intersect itself, but if we move any of the points then it will reappear.

![Image](https://github.com/user-attachments/assets/03691fbd-3788-4ed9-ab07-35e7fb1dcaaf)
![Image](https://github.com/user-attachments/assets/c9767167-5db4-464c-a7b3-d8a757d0baf0)

### Steps to reproduce

Copy these points into a Polygon2D and notice it doesn't render:
```
polygon = PackedVector2Array(450, 300, 550, 300, 550, 450, 600, 450, 600, 300, 550, 300, 550, 250, 700.68, 249, 700, 450, 700.68, 506, 449.68, 500)
```

### Minimal reproduction project (MRP)

I gave the points to the Polygon2D in reproduce steps.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue in a Polygon2D using the points from the report, then inspect the Geometry2D union and Polygon2D paths involved in constructing and rendering the shape. Done means the supplied polygon renders correctly without producing an invalid or self-intersecting result, while preserving the existing behavior for valid polygons.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.