hiulit / Delaunator-GDScript

A GDScript port of Delaunator: A fast library for Delaunay triangulation of 2D points.
MIT License
80 stars 8 forks source link

For godot4 users: slice end is now exclusive #5

Open ODtian opened 1 year ago

ODtian commented 1 year ago

Godot4 array api has changed a lot, and the meaning of end param in slice method has changed, which is the inclusive index previously and now is the exclusive index, same as the original javascript lib.

In this case, line 295-296 should be

    triangles = _triangles.slice(0, triangles_len)
    halfedges = _halfedges.slice(0, triangles_len)

otherwise you will got a non-3-multiply length array .triangles, which is invild.

hiulit commented 1 year ago

Thank you for the heads up! I haven't had time to try Godot 4.0.

t-karcher commented 1 year ago

FYI: I just updated my "ClickableMap" demo including the Delaunator script to work with Godot 4.0: https://github.com/t-karcher/ClickableMap

Feel free to copy the script from this project back here. (I don't want to open a pull request because you'll also have to update you the rest of the project to make it work, and the 4.0 version is not backward compatible with 3.x)