Giter Site home page Giter Site logo

pkern90 / gdextension_delaunator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from treer/gdextension_delaunator

0.0 0.0 0.0 47 KB

Delaunator C++ as a Godot 4 extension (fast Delaunay triangulation, and Voronoi)

License: MIT License

Shell 1.49% C++ 77.70% Python 20.42% C 0.39%

gdextension_delaunator's Introduction

License: MIT example workflow

Delaunator GDExtension for Godot 4

A fast library for Delaunay triangulation. It's currently managing 100,000 points in ~50ms on a 2015 processor (i7-6700).

This GDExtension is in alpha and I've switched to a C# implementation, so this might not get updated. It was probably a bit soon to try working with a GDExtension.

See Delaunator guide (how to get Voronoi polygons etc.) and API reference for interim details, as documentation here is a work in progress

Installation

Download delaunator_gdextension.zip from the latest Release page and copy the delaunator_gdextension folder from inside the zip file into your project's addons folder.

It supports Windows and Linux.

Example GDScript

var delaunator = Delaunator.new();

var points = [Vector2(1,1), Vector2(10, 0), Vector2(5, 1), Vector2(1, 5)];
delaunator.from(PackedVector2Array(points));
    
prints("Delaunator triangles:", delaunator.triangles)
prints("           half edges:", delaunator.halfedges)
prints("           hull:", delaunator.hull)
prints("           hull area:", delaunator.hull_area)

points = [Vector2(-1,1), Vector2(1, 1), Vector2(1, -1), Vector2(-1, -1)];
delaunator.from(PackedVector2Array(points));

prints("Delaunator triangles:", delaunator.triangles)
prints("           half edges:", delaunator.halfedges)
prints("           hull:", delaunator.hull)
prints("           hull area:", delaunator.hull_area)

Note that currently the array is copied back into Godot every time a property is accessed, so take a GDScript copy of it rather than accessing the property more than once.

Suggested work remaining

Any help appreciated

  • Github actions, so nobody needs to setup a build environment to use this
  • C# bindings
  • Optimization (lots of low-hanging memory gains if delaunator_cpp is switched to operating on Godot types directly)
  • Godot example project & documentation

Troubleshooting

  • Godot crashes or closes when using this GDExtenion:
    • Godot 4's native interface isn't finalized/stable yet so the delaunator binaries might only work with a version of Godot 4 compiled around the same time this project's godot-cpp submodule was last updated. Older releases are available, as are older releases of Godot, but better to just wait until everything is stable.
    • Memory related bugs in this [alpha] project are possible too, in which case limiting which calls are being made might narrow the bug down.

Acknowledgements

gdextension_delaunator's People

Contributors

treer avatar pkern90 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.