From c111d6b621b43d6a8a3fd4cf3fd64db2a87bdc97 Mon Sep 17 00:00:00 2001 From: smix8 <52464204+smix8@users.noreply.github.com> Date: Thu, 2 Jun 2022 09:25:42 +0200 Subject: [PATCH] Expose get_mesh() for NavigationPolygon Resources Expose get_mesh() for NavigationPolygon Resources. (cherry picked from commit 8bcce0ebb2ab5da94cc86f77df4c86f63bc5d22e) --- doc/classes/NavigationPolygon.xml | 6 ++++++ scene/2d/navigation_polygon.cpp | 1 + 2 files changed, 7 insertions(+) diff --git a/doc/classes/NavigationPolygon.xml b/doc/classes/NavigationPolygon.xml index 9aebc97afaf..a82d8ef6d1b 100644 --- a/doc/classes/NavigationPolygon.xml +++ b/doc/classes/NavigationPolygon.xml @@ -61,6 +61,12 @@ Clears the array of polygons, but it doesn't clear the array of outlines and vertices. + + + + Returns the [NavigationMesh] resulting from this navigation polygon. This navmesh can be used to update the navmesh of a region with the [method NavigationServer.region_set_navmesh] API directly (as 2D uses the 3D server behind the scene). + + diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp index ae505851e54..db3b18dd26d 100644 --- a/scene/2d/navigation_polygon.cpp +++ b/scene/2d/navigation_polygon.cpp @@ -326,6 +326,7 @@ void NavigationPolygon::_bind_methods() { ClassDB::bind_method(D_METHOD("get_polygon_count"), &NavigationPolygon::get_polygon_count); ClassDB::bind_method(D_METHOD("get_polygon", "idx"), &NavigationPolygon::get_polygon); ClassDB::bind_method(D_METHOD("clear_polygons"), &NavigationPolygon::clear_polygons); + ClassDB::bind_method(D_METHOD("get_mesh"), &NavigationPolygon::get_mesh); ClassDB::bind_method(D_METHOD("add_outline", "outline"), &NavigationPolygon::add_outline); ClassDB::bind_method(D_METHOD("add_outline_at_index", "outline", "index"), &NavigationPolygon::add_outline_at_index);