diff options
author | Mansur Isaev <737dab2f169a@mail.ru> | 2022-09-19 14:09:56 +0400 |
---|---|---|
committer | Mansur Isaev <737dab2f169a@mail.ru> | 2022-09-21 09:40:03 +0400 |
commit | 623e23c6254b26cdb50434c2ee7941e2f9acb181 (patch) | |
tree | 8096bd6becae9ff3fcc780014987168b2f7ee4da /core/core_bind.cpp | |
parent | c8a0912f3647367d8cee5216f50c28a93e9ffdb5 (diff) | |
download | redot-engine-623e23c6254b26cdb50434c2ee7941e2f9acb181.tar.gz |
Add method bind for `Geometry2D.decompose_polygon_in_convex`
Diffstat (limited to 'core/core_bind.cpp')
-rw-r--r-- | core/core_bind.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 2149ee4512..a164221fc2 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -709,6 +709,17 @@ Vector<Point2> Geometry2D::convex_hull(const Vector<Point2> &p_points) { return ::Geometry2D::convex_hull(p_points); } +TypedArray<PackedVector2Array> Geometry2D::decompose_polygon_in_convex(const Vector<Vector2> &p_polygon) { + Vector<Vector<Point2>> decomp = ::Geometry2D::decompose_polygon_in_convex(p_polygon); + + TypedArray<PackedVector2Array> ret; + + for (int i = 0; i < decomp.size(); ++i) { + ret.push_back(decomp[i]); + } + return ret; +} + TypedArray<PackedVector2Array> Geometry2D::merge_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) { Vector<Vector<Point2>> polys = ::Geometry2D::merge_polygons(p_polygon_a, p_polygon_b); @@ -840,6 +851,7 @@ void Geometry2D::_bind_methods() { ClassDB::bind_method(D_METHOD("triangulate_polygon", "polygon"), &Geometry2D::triangulate_polygon); ClassDB::bind_method(D_METHOD("triangulate_delaunay", "points"), &Geometry2D::triangulate_delaunay); ClassDB::bind_method(D_METHOD("convex_hull", "points"), &Geometry2D::convex_hull); + ClassDB::bind_method(D_METHOD("decompose_polygon_in_convex", "polygon"), &Geometry2D::decompose_polygon_in_convex); ClassDB::bind_method(D_METHOD("merge_polygons", "polygon_a", "polygon_b"), &Geometry2D::merge_polygons); ClassDB::bind_method(D_METHOD("clip_polygons", "polygon_a", "polygon_b"), &Geometry2D::clip_polygons); |