Delaunator-GDScript icon indicating copy to clipboard operation
Delaunator-GDScript copied to clipboard

For godot4 users: slice end is now exclusive

Open ODtian opened this issue 2 years ago • 2 comments

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.

ODtian avatar Mar 08 '23 01:03 ODtian

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

hiulit avatar Mar 13 '23 11:03 hiulit

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)

t-karcher avatar Jun 09 '23 10:06 t-karcher