godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Replace Clipper with more performant Clipper2 for Geometry2D operations #6146

Open brianwinterpixel opened 1 year ago

brianwinterpixel commented 1 year ago

Describe the project you are working on

n/a

Describe the problem or limitation you are having in your project

n/a

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Clipper2 advertises ~4x performance improvements and fewer artifacts over Clipper. It was released in September 2022.

While I don't think very many projects are bottlenecked by geometric operations, this sounds like a relatively easy performance win.

http://www.angusj.com/clipper2/Docs/Changes.htm

image

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

n/a

If this enhancement will not be used often, can it be worked around with a few lines of script?

n/a

Is there a reason why this should be core and not an add-on in the asset library?

Godot already uses Clipper.

fire commented 1 year ago

We don't have a good plan to upgrade, and clipper isn't limiting any feature except being slower so the upgrade has less priority.

Even this plan has no idea how to upgrade.

Open to implementations!

brianwinterpixel commented 1 year ago

Upgrade should be very easy. Clipper2 has all of the features as the original, with a very similar API. It might even result in less code required to interface with it than is currently implemented in the Godot codebase.

But yes, low priority 😄

smix8 commented 1 year ago

The number one feature that is actively blocked by the current bare bone state of the 2D polygon operations in Godot is navigation mesh baking for 2D. Godot has currently no API to handle geometry operations with more than 2 polygons at the same time efficiently. All the exposed Geometry2D functions were design-limited in the past to only work with max two polygons instead of arrays of polygons that even Clipper1 could handle.