From f7ebce26263ff15db7130f31ebead099cc296212 Mon Sep 17 00:00:00 2001 From: smix8 <52464204+smix8@users.noreply.github.com> Date: Fri, 7 Jul 2023 00:31:33 +0200 Subject: [PATCH] Mark NavigationServer3D.region_bake_navigation_mesh() as deprecated Marks NavigationServer3D.region_bake_navigation_mesh() as deprecated. --- doc/classes/NavigationServer3D.xml | 3 ++- modules/navigation/godot_navigation_server.cpp | 4 ++++ modules/navigation/godot_navigation_server.h | 2 ++ servers/navigation_server_3d.cpp | 2 ++ servers/navigation_server_3d.h | 2 ++ servers/navigation_server_3d_dummy.h | 2 ++ 6 files changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/classes/NavigationServer3D.xml b/doc/classes/NavigationServer3D.xml index aa84c9361f4..4a41730fca7 100644 --- a/doc/classes/NavigationServer3D.xml +++ b/doc/classes/NavigationServer3D.xml @@ -695,12 +695,13 @@ Queries a path in a given navigation map. Start and target position and other parameters are defined through [NavigationPathQueryParameters3D]. Updates the provided [NavigationPathQueryResult3D] result object with the path among other results requested by the query. - + Bakes the [param navigation_mesh] with bake source geometry collected starting from the [param root_node]. + [i]Deprecated.[/i] This function is deprecated due to core threading changes. To upgrade existing code, first create a [NavigationMeshSourceGeometryData3D] resource. Use this resource with [method parse_source_geometry_data] to parse the SceneTree for nodes that should contribute to the navigation mesh baking. The SceneTree parsing needs to happen on the main thread. After the parsing is finished use the resource with [method bake_from_source_geometry_data] to bake a navigation mesh. diff --git a/modules/navigation/godot_navigation_server.cpp b/modules/navigation/godot_navigation_server.cpp index bf34779735a..b73c5ca3e20 100644 --- a/modules/navigation/godot_navigation_server.cpp +++ b/modules/navigation/godot_navigation_server.cpp @@ -446,10 +446,13 @@ COMMAND_2(region_set_navigation_mesh, RID, p_region, Ref, p_navi region->set_mesh(p_navigation_mesh); } +#ifndef DISABLE_DEPRECATED void GodotNavigationServer::region_bake_navigation_mesh(Ref p_navigation_mesh, Node *p_root_node) { ERR_FAIL_COND(p_navigation_mesh.is_null()); ERR_FAIL_COND(p_root_node == nullptr); + WARN_PRINT_ONCE("NavigationServer3D::region_bake_navigation_mesh() is deprecated due to core threading changes. To upgrade existing code, first create a NavigationMeshSourceGeometryData3D resource. Use this resource with method parse_source_geometry_data() to parse the SceneTree for nodes that should contribute to the navigation mesh baking. The SceneTree parsing needs to happen on the main thread. After the parsing is finished use the resource with method bake_from_source_geometry_data() to bake a navigation mesh.."); + #ifndef _3D_DISABLED NavigationMeshGenerator::get_singleton()->clear(p_navigation_mesh); Ref source_geometry_data; @@ -458,6 +461,7 @@ void GodotNavigationServer::region_bake_navigation_mesh(Ref p_na NavigationMeshGenerator::get_singleton()->bake_from_source_geometry_data(p_navigation_mesh, source_geometry_data); #endif } +#endif // DISABLE_DEPRECATED int GodotNavigationServer::region_get_connections_count(RID p_region) const { NavRegion *region = region_owner.get_or_null(p_region); diff --git a/modules/navigation/godot_navigation_server.h b/modules/navigation/godot_navigation_server.h index 6b394157bc7..95aa88194ea 100644 --- a/modules/navigation/godot_navigation_server.h +++ b/modules/navigation/godot_navigation_server.h @@ -154,7 +154,9 @@ public: virtual uint32_t region_get_navigation_layers(RID p_region) const override; COMMAND_2(region_set_transform, RID, p_region, Transform3D, p_transform); COMMAND_2(region_set_navigation_mesh, RID, p_region, Ref, p_navigation_mesh); +#ifndef DISABLE_DEPRECATED virtual void region_bake_navigation_mesh(Ref p_navigation_mesh, Node *p_root_node) override; +#endif // DISABLE_DEPRECATED virtual int region_get_connections_count(RID p_region) const override; virtual Vector3 region_get_connection_pathway_start(RID p_region, int p_connection_id) const override; virtual Vector3 region_get_connection_pathway_end(RID p_region, int p_connection_id) const override; diff --git a/servers/navigation_server_3d.cpp b/servers/navigation_server_3d.cpp index dae8ea6dcd2..3b26945c864 100644 --- a/servers/navigation_server_3d.cpp +++ b/servers/navigation_server_3d.cpp @@ -82,7 +82,9 @@ void NavigationServer3D::_bind_methods() { ClassDB::bind_method(D_METHOD("region_get_navigation_layers", "region"), &NavigationServer3D::region_get_navigation_layers); ClassDB::bind_method(D_METHOD("region_set_transform", "region", "transform"), &NavigationServer3D::region_set_transform); ClassDB::bind_method(D_METHOD("region_set_navigation_mesh", "region", "navigation_mesh"), &NavigationServer3D::region_set_navigation_mesh); +#ifndef DISABLE_DEPRECATED ClassDB::bind_method(D_METHOD("region_bake_navigation_mesh", "navigation_mesh", "root_node"), &NavigationServer3D::region_bake_navigation_mesh); +#endif // DISABLE_DEPRECATED ClassDB::bind_method(D_METHOD("region_get_connections_count", "region"), &NavigationServer3D::region_get_connections_count); ClassDB::bind_method(D_METHOD("region_get_connection_pathway_start", "region", "connection"), &NavigationServer3D::region_get_connection_pathway_start); ClassDB::bind_method(D_METHOD("region_get_connection_pathway_end", "region", "connection"), &NavigationServer3D::region_get_connection_pathway_end); diff --git a/servers/navigation_server_3d.h b/servers/navigation_server_3d.h index cf5552e676a..0764690b813 100644 --- a/servers/navigation_server_3d.h +++ b/servers/navigation_server_3d.h @@ -148,8 +148,10 @@ public: /// Set the navigation mesh of this region. virtual void region_set_navigation_mesh(RID p_region, Ref p_navigation_mesh) = 0; +#ifndef DISABLE_DEPRECATED /// Bake the navigation mesh. virtual void region_bake_navigation_mesh(Ref p_navigation_mesh, Node *p_root_node) = 0; +#endif // DISABLE_DEPRECATED /// Get a list of a region's connection to other regions. virtual int region_get_connections_count(RID p_region) const = 0; diff --git a/servers/navigation_server_3d_dummy.h b/servers/navigation_server_3d_dummy.h index 8e91ec812f4..4a2e9f74393 100644 --- a/servers/navigation_server_3d_dummy.h +++ b/servers/navigation_server_3d_dummy.h @@ -79,7 +79,9 @@ public: uint32_t region_get_navigation_layers(RID p_region) const override { return 0; } void region_set_transform(RID p_region, Transform3D p_transform) override {} void region_set_navigation_mesh(RID p_region, Ref p_navigation_mesh) override {} +#ifndef DISABLE_DEPRECATED void region_bake_navigation_mesh(Ref p_navigation_mesh, Node *p_root_node) override {} +#endif // DISABLE_DEPRECATED int region_get_connections_count(RID p_region) const override { return 0; } Vector3 region_get_connection_pathway_start(RID p_region, int p_connection_id) const override { return Vector3(); } Vector3 region_get_connection_pathway_end(RID p_region, int p_connection_id) const override { return Vector3(); }