1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-21 14:57:09 +00:00

Expose 2D Delaunay triangulation in Geometry singleton

Can be used via scripting as `Geometry.triangulate_delaunay_2d(points)`

The interface is the same as in `Triangulate` library, returning indices
into triangulated points.
This commit is contained in:
Andrii Doroshenko (Xrayez)
2019-05-23 16:53:53 +03:00
parent 1deb41226d
commit 24e9a881c0
4 changed files with 30 additions and 0 deletions

View File

@@ -1501,6 +1501,11 @@ Vector<int> _Geometry::triangulate_polygon(const Vector<Vector2> &p_polygon) {
return Geometry::triangulate_polygon(p_polygon);
}
Vector<int> _Geometry::triangulate_delaunay_2d(const Vector<Vector2> &p_points) {
return Geometry::triangulate_delaunay_2d(p_points);
}
Vector<Point2> _Geometry::convex_hull_2d(const Vector<Point2> &p_points) {
return Geometry::convex_hull_2d(p_points);
@@ -1674,6 +1679,7 @@ void _Geometry::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_polygon_clockwise", "polygon"), &_Geometry::is_polygon_clockwise);
ClassDB::bind_method(D_METHOD("triangulate_polygon", "polygon"), &_Geometry::triangulate_polygon);
ClassDB::bind_method(D_METHOD("triangulate_delaunay_2d", "points"), &_Geometry::triangulate_delaunay_2d);
ClassDB::bind_method(D_METHOD("convex_hull_2d", "points"), &_Geometry::convex_hull_2d);
ClassDB::bind_method(D_METHOD("clip_polygon", "points", "plane"), &_Geometry::clip_polygon);