@@ -1491,6 +1491,11 @@ PoolVector<Vector3> _Geometry::segment_intersects_convex(const Vector3 &p_from,
1491
1491
return r;
1492
1492
}
1493
1493
1494
+ bool _Geometry::is_polygon_clockwise (const Vector<Vector2> &p_polygon) {
1495
+
1496
+ return Geometry::is_polygon_clockwise (p_polygon);
1497
+ }
1498
+
1494
1499
Vector<int > _Geometry::triangulate_polygon (const Vector<Vector2> &p_polygon) {
1495
1500
1496
1501
return Geometry::triangulate_polygon (p_polygon);
@@ -1506,6 +1511,107 @@ Vector<Vector3> _Geometry::clip_polygon(const Vector<Vector3> &p_points, const P
1506
1511
return Geometry::clip_polygon (p_points, p_plane);
1507
1512
}
1508
1513
1514
+ Array _Geometry::merge_polygons_2d (const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
1515
+
1516
+ Vector<Vector<Point2> > polys = Geometry::merge_polygons_2d (p_polygon_a, p_polygon_b);
1517
+
1518
+ Array ret;
1519
+
1520
+ for (int i = 0 ; i < polys.size (); ++i) {
1521
+ ret.push_back (polys[i]);
1522
+ }
1523
+ return ret;
1524
+ }
1525
+
1526
+ Array _Geometry::clip_polygons_2d (const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
1527
+
1528
+ Vector<Vector<Point2> > polys = Geometry::clip_polygons_2d (p_polygon_a, p_polygon_b);
1529
+
1530
+ Array ret;
1531
+
1532
+ for (int i = 0 ; i < polys.size (); ++i) {
1533
+ ret.push_back (polys[i]);
1534
+ }
1535
+ return ret;
1536
+ }
1537
+
1538
+ Array _Geometry::intersect_polygons_2d (const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
1539
+
1540
+ Vector<Vector<Point2> > polys = Geometry::intersect_polygons_2d (p_polygon_a, p_polygon_b);
1541
+
1542
+ Array ret;
1543
+
1544
+ for (int i = 0 ; i < polys.size (); ++i) {
1545
+ ret.push_back (polys[i]);
1546
+ }
1547
+ return ret;
1548
+ }
1549
+
1550
+ Array _Geometry::exclude_polygons_2d (const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
1551
+
1552
+ Vector<Vector<Point2> > polys = Geometry::exclude_polygons_2d (p_polygon_a, p_polygon_b);
1553
+
1554
+ Array ret;
1555
+
1556
+ for (int i = 0 ; i < polys.size (); ++i) {
1557
+ ret.push_back (polys[i]);
1558
+ }
1559
+ return ret;
1560
+ }
1561
+
1562
+ Array _Geometry::clip_polyline_with_polygon_2d (const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon) {
1563
+
1564
+ Vector<Vector<Point2> > polys = Geometry::clip_polyline_with_polygon_2d (p_polyline, p_polygon);
1565
+
1566
+ Array ret;
1567
+
1568
+ for (int i = 0 ; i < polys.size (); ++i) {
1569
+ ret.push_back (polys[i]);
1570
+ }
1571
+ return ret;
1572
+ }
1573
+
1574
+ Array _Geometry::intersect_polyline_with_polygon_2d (const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon) {
1575
+
1576
+ Vector<Vector<Point2> > polys = Geometry::intersect_polyline_with_polygon_2d (p_polyline, p_polygon);
1577
+
1578
+ Array ret;
1579
+
1580
+ for (int i = 0 ; i < polys.size (); ++i) {
1581
+ ret.push_back (polys[i]);
1582
+ }
1583
+ return ret;
1584
+ }
1585
+
1586
+ Array _Geometry::offset_polygon_2d (const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type) {
1587
+
1588
+ Vector<Vector<Point2> > polys = Geometry::offset_polygon_2d (p_polygon, p_delta, Geometry::PolyJoinType (p_join_type));
1589
+
1590
+ Array ret;
1591
+
1592
+ for (int i = 0 ; i < polys.size (); ++i) {
1593
+ ret.push_back (polys[i]);
1594
+ }
1595
+ return ret;
1596
+ }
1597
+
1598
+ Array _Geometry::offset_polyline_2d (const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type, PolyEndType p_end_type) {
1599
+
1600
+ Vector<Vector<Point2> > polys = Geometry::offset_polyline_2d (p_polygon, p_delta, Geometry::PolyJoinType (p_join_type), Geometry::PolyEndType (p_end_type));
1601
+
1602
+ Array ret;
1603
+
1604
+ for (int i = 0 ; i < polys.size (); ++i) {
1605
+ ret.push_back (polys[i]);
1606
+ }
1607
+ return ret;
1608
+ }
1609
+
1610
+ Vector<Point2> _Geometry::transform_points_2d (const Vector<Point2> &p_points, const Transform2D &p_mat) {
1611
+
1612
+ return Geometry::transform_points_2d (p_points, p_mat);
1613
+ }
1614
+
1509
1615
Dictionary _Geometry::make_atlas (const Vector<Size2> &p_rects) {
1510
1616
1511
1617
Dictionary ret;
@@ -1566,11 +1672,40 @@ void _Geometry::_bind_methods() {
1566
1672
ClassDB::bind_method (D_METHOD (" segment_intersects_convex" , " from" , " to" , " planes" ), &_Geometry::segment_intersects_convex);
1567
1673
ClassDB::bind_method (D_METHOD (" point_is_inside_triangle" , " point" , " a" , " b" , " c" ), &_Geometry::point_is_inside_triangle);
1568
1674
1675
+ ClassDB::bind_method (D_METHOD (" is_polygon_clockwise" , " polygon" ), &_Geometry::is_polygon_clockwise);
1569
1676
ClassDB::bind_method (D_METHOD (" triangulate_polygon" , " polygon" ), &_Geometry::triangulate_polygon);
1570
1677
ClassDB::bind_method (D_METHOD (" convex_hull_2d" , " points" ), &_Geometry::convex_hull_2d);
1571
1678
ClassDB::bind_method (D_METHOD (" clip_polygon" , " points" , " plane" ), &_Geometry::clip_polygon);
1572
1679
1680
+ ClassDB::bind_method (D_METHOD (" merge_polygons_2d" , " polygon_a" , " polygon_b" ), &_Geometry::merge_polygons_2d);
1681
+ ClassDB::bind_method (D_METHOD (" clip_polygons_2d" , " polygon_a" , " polygon_b" ), &_Geometry::clip_polygons_2d);
1682
+ ClassDB::bind_method (D_METHOD (" intersect_polygons_2d" , " polygon_a" , " polygon_b" ), &_Geometry::intersect_polygons_2d);
1683
+ ClassDB::bind_method (D_METHOD (" exclude_polygons_2d" , " polygon_a" , " polygon_b" ), &_Geometry::exclude_polygons_2d);
1684
+
1685
+ ClassDB::bind_method (D_METHOD (" clip_polyline_with_polygon_2d" , " polyline" , " polygon" ), &_Geometry::clip_polyline_with_polygon_2d);
1686
+ ClassDB::bind_method (D_METHOD (" intersect_polyline_with_polygon_2d" , " polyline" , " polygon" ), &_Geometry::intersect_polyline_with_polygon_2d);
1687
+
1688
+ ClassDB::bind_method (D_METHOD (" offset_polygon_2d" , " polygon" , " delta" , " join_type" ), &_Geometry::offset_polygon_2d, DEFVAL (JOIN_SQUARE));
1689
+ ClassDB::bind_method (D_METHOD (" offset_polyline_2d" , " polyline" , " delta" , " join_type" , " end_type" ), &_Geometry::offset_polyline_2d, DEFVAL (JOIN_SQUARE), DEFVAL (END_SQUARE));
1690
+
1691
+ ClassDB::bind_method (D_METHOD (" transform_points_2d" , " points" , " transform" ), &_Geometry::transform_points_2d);
1692
+
1573
1693
ClassDB::bind_method (D_METHOD (" make_atlas" , " sizes" ), &_Geometry::make_atlas);
1694
+
1695
+ BIND_ENUM_CONSTANT (OPERATION_UNION);
1696
+ BIND_ENUM_CONSTANT (OPERATION_DIFFERENCE);
1697
+ BIND_ENUM_CONSTANT (OPERATION_INTERSECTION);
1698
+ BIND_ENUM_CONSTANT (OPERATION_XOR);
1699
+
1700
+ BIND_ENUM_CONSTANT (JOIN_SQUARE);
1701
+ BIND_ENUM_CONSTANT (JOIN_ROUND);
1702
+ BIND_ENUM_CONSTANT (JOIN_MITER);
1703
+
1704
+ BIND_ENUM_CONSTANT (END_POLYGON);
1705
+ BIND_ENUM_CONSTANT (END_JOINED);
1706
+ BIND_ENUM_CONSTANT (END_BUTT);
1707
+ BIND_ENUM_CONSTANT (END_SQUARE);
1708
+ BIND_ENUM_CONSTANT (END_ROUND);
1574
1709
}
1575
1710
1576
1711
_Geometry::_Geometry () {
0 commit comments