From 34e7628f5f1b419bfed1acd915209347e615bedf Mon Sep 17 00:00:00 2001 From: smix8 <52464204+smix8@users.noreply.github.com> Date: Sun, 11 Dec 2022 18:02:35 +0100 Subject: Fix Navigation API abbreviations inconsistency Schema for navigation to name user facing API with "navigation" without abbreviation and e.g. NavigationServer internals with abbr "nav". --- modules/navigation/godot_navigation_server.cpp | 14 ++-- modules/navigation/godot_navigation_server.h | 4 +- modules/navigation/navigation_mesh_generator.cpp | 102 +++++++++++------------ modules/navigation/navigation_mesh_generator.h | 8 +- 4 files changed, 64 insertions(+), 64 deletions(-) (limited to 'modules/navigation') diff --git a/modules/navigation/godot_navigation_server.cpp b/modules/navigation/godot_navigation_server.cpp index e5949c935b..c5c1912621 100644 --- a/modules/navigation/godot_navigation_server.cpp +++ b/modules/navigation/godot_navigation_server.cpp @@ -421,20 +421,20 @@ uint32_t GodotNavigationServer::region_get_navigation_layers(RID p_region) const return region->get_navigation_layers(); } -COMMAND_2(region_set_navmesh, RID, p_region, Ref, p_nav_mesh) { +COMMAND_2(region_set_navigation_mesh, RID, p_region, Ref, p_navigation_mesh) { NavRegion *region = region_owner.get_or_null(p_region); ERR_FAIL_COND(region == nullptr); - region->set_mesh(p_nav_mesh); + region->set_mesh(p_navigation_mesh); } -void GodotNavigationServer::region_bake_navmesh(Ref r_mesh, Node *p_node) const { - ERR_FAIL_COND(r_mesh.is_null()); - ERR_FAIL_COND(p_node == nullptr); +void GodotNavigationServer::region_bake_navigation_mesh(Ref p_navigation_mesh, Node *p_root_node) const { + ERR_FAIL_COND(p_navigation_mesh.is_null()); + ERR_FAIL_COND(p_root_node == nullptr); #ifndef _3D_DISABLED - NavigationMeshGenerator::get_singleton()->clear(r_mesh); - NavigationMeshGenerator::get_singleton()->bake(r_mesh, p_node); + NavigationMeshGenerator::get_singleton()->clear(p_navigation_mesh); + NavigationMeshGenerator::get_singleton()->bake(p_navigation_mesh, p_root_node); #endif } diff --git a/modules/navigation/godot_navigation_server.h b/modules/navigation/godot_navigation_server.h index 18431e39b8..6f39420c67 100644 --- a/modules/navigation/godot_navigation_server.h +++ b/modules/navigation/godot_navigation_server.h @@ -135,8 +135,8 @@ public: COMMAND_2(region_set_navigation_layers, RID, p_region, uint32_t, p_navigation_layers); 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_navmesh, RID, p_region, Ref, p_nav_mesh); - virtual void region_bake_navmesh(Ref r_mesh, Node *p_node) const override; + COMMAND_2(region_set_navigation_mesh, RID, p_region, Ref, p_navigation_mesh); + virtual void region_bake_navigation_mesh(Ref p_navigation_mesh, Node *p_root_node) const override; 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/modules/navigation/navigation_mesh_generator.cpp b/modules/navigation/navigation_mesh_generator.cpp index f0d3e329ce..74727648cb 100644 --- a/modules/navigation/navigation_mesh_generator.cpp +++ b/modules/navigation/navigation_mesh_generator.cpp @@ -470,14 +470,14 @@ void NavigationMeshGenerator::_parse_geometry(const Transform3D &p_navmesh_trans } } -void NavigationMeshGenerator::_convert_detail_mesh_to_native_navigation_mesh(const rcPolyMeshDetail *p_detail_mesh, Ref p_nav_mesh) { +void NavigationMeshGenerator::_convert_detail_mesh_to_native_navigation_mesh(const rcPolyMeshDetail *p_detail_mesh, Ref p_navigation_mesh) { Vector nav_vertices; for (int i = 0; i < p_detail_mesh->nverts; i++) { const float *v = &p_detail_mesh->verts[i * 3]; nav_vertices.push_back(Vector3(v[0], v[1], v[2])); } - p_nav_mesh->set_vertices(nav_vertices); + p_navigation_mesh->set_vertices(nav_vertices); for (int i = 0; i < p_detail_mesh->nmeshes; i++) { const unsigned int *m = &p_detail_mesh->meshes[i * 4]; @@ -492,13 +492,13 @@ void NavigationMeshGenerator::_convert_detail_mesh_to_native_navigation_mesh(con nav_indices.write[0] = ((int)(bverts + tris[j * 4 + 0])); nav_indices.write[1] = ((int)(bverts + tris[j * 4 + 2])); nav_indices.write[2] = ((int)(bverts + tris[j * 4 + 1])); - p_nav_mesh->add_polygon(nav_indices); + p_navigation_mesh->add_polygon(nav_indices); } } } void NavigationMeshGenerator::_build_recast_navigation_mesh( - Ref p_nav_mesh, + Ref p_navigation_mesh, #ifdef TOOLS_ENABLED EditorProgress *ep, #endif @@ -528,42 +528,42 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh( rcConfig cfg; memset(&cfg, 0, sizeof(cfg)); - cfg.cs = p_nav_mesh->get_cell_size(); - cfg.ch = p_nav_mesh->get_cell_height(); - cfg.walkableSlopeAngle = p_nav_mesh->get_agent_max_slope(); - cfg.walkableHeight = (int)Math::ceil(p_nav_mesh->get_agent_height() / cfg.ch); - cfg.walkableClimb = (int)Math::floor(p_nav_mesh->get_agent_max_climb() / cfg.ch); - cfg.walkableRadius = (int)Math::ceil(p_nav_mesh->get_agent_radius() / cfg.cs); - cfg.maxEdgeLen = (int)(p_nav_mesh->get_edge_max_length() / p_nav_mesh->get_cell_size()); - cfg.maxSimplificationError = p_nav_mesh->get_edge_max_error(); - cfg.minRegionArea = (int)(p_nav_mesh->get_region_min_size() * p_nav_mesh->get_region_min_size()); - cfg.mergeRegionArea = (int)(p_nav_mesh->get_region_merge_size() * p_nav_mesh->get_region_merge_size()); - cfg.maxVertsPerPoly = (int)p_nav_mesh->get_verts_per_poly(); - cfg.detailSampleDist = MAX(p_nav_mesh->get_cell_size() * p_nav_mesh->get_detail_sample_distance(), 0.1f); - cfg.detailSampleMaxError = p_nav_mesh->get_cell_height() * p_nav_mesh->get_detail_sample_max_error(); - - if (!Math::is_equal_approx((float)cfg.walkableHeight * cfg.ch, p_nav_mesh->get_agent_height())) { + cfg.cs = p_navigation_mesh->get_cell_size(); + cfg.ch = p_navigation_mesh->get_cell_height(); + cfg.walkableSlopeAngle = p_navigation_mesh->get_agent_max_slope(); + cfg.walkableHeight = (int)Math::ceil(p_navigation_mesh->get_agent_height() / cfg.ch); + cfg.walkableClimb = (int)Math::floor(p_navigation_mesh->get_agent_max_climb() / cfg.ch); + cfg.walkableRadius = (int)Math::ceil(p_navigation_mesh->get_agent_radius() / cfg.cs); + cfg.maxEdgeLen = (int)(p_navigation_mesh->get_edge_max_length() / p_navigation_mesh->get_cell_size()); + cfg.maxSimplificationError = p_navigation_mesh->get_edge_max_error(); + cfg.minRegionArea = (int)(p_navigation_mesh->get_region_min_size() * p_navigation_mesh->get_region_min_size()); + cfg.mergeRegionArea = (int)(p_navigation_mesh->get_region_merge_size() * p_navigation_mesh->get_region_merge_size()); + cfg.maxVertsPerPoly = (int)p_navigation_mesh->get_vertices_per_polyon(); + cfg.detailSampleDist = MAX(p_navigation_mesh->get_cell_size() * p_navigation_mesh->get_detail_sample_distance(), 0.1f); + cfg.detailSampleMaxError = p_navigation_mesh->get_cell_height() * p_navigation_mesh->get_detail_sample_max_error(); + + if (!Math::is_equal_approx((float)cfg.walkableHeight * cfg.ch, p_navigation_mesh->get_agent_height())) { WARN_PRINT("Property agent_height is ceiled to cell_height voxel units and loses precision."); } - if (!Math::is_equal_approx((float)cfg.walkableClimb * cfg.ch, p_nav_mesh->get_agent_max_climb())) { + if (!Math::is_equal_approx((float)cfg.walkableClimb * cfg.ch, p_navigation_mesh->get_agent_max_climb())) { WARN_PRINT("Property agent_max_climb is floored to cell_height voxel units and loses precision."); } - if (!Math::is_equal_approx((float)cfg.walkableRadius * cfg.cs, p_nav_mesh->get_agent_radius())) { + if (!Math::is_equal_approx((float)cfg.walkableRadius * cfg.cs, p_navigation_mesh->get_agent_radius())) { WARN_PRINT("Property agent_radius is ceiled to cell_size voxel units and loses precision."); } - if (!Math::is_equal_approx((float)cfg.maxEdgeLen * cfg.cs, p_nav_mesh->get_edge_max_length())) { + if (!Math::is_equal_approx((float)cfg.maxEdgeLen * cfg.cs, p_navigation_mesh->get_edge_max_length())) { WARN_PRINT("Property edge_max_length is rounded to cell_size voxel units and loses precision."); } - if (!Math::is_equal_approx((float)cfg.minRegionArea, p_nav_mesh->get_region_min_size() * p_nav_mesh->get_region_min_size())) { + if (!Math::is_equal_approx((float)cfg.minRegionArea, p_navigation_mesh->get_region_min_size() * p_navigation_mesh->get_region_min_size())) { WARN_PRINT("Property region_min_size is converted to int and loses precision."); } - if (!Math::is_equal_approx((float)cfg.mergeRegionArea, p_nav_mesh->get_region_merge_size() * p_nav_mesh->get_region_merge_size())) { + if (!Math::is_equal_approx((float)cfg.mergeRegionArea, p_navigation_mesh->get_region_merge_size() * p_navigation_mesh->get_region_merge_size())) { WARN_PRINT("Property region_merge_size is converted to int and loses precision."); } - if (!Math::is_equal_approx((float)cfg.maxVertsPerPoly, p_nav_mesh->get_verts_per_poly())) { - WARN_PRINT("Property verts_per_poly is converted to int and loses precision."); + if (!Math::is_equal_approx((float)cfg.maxVertsPerPoly, p_navigation_mesh->get_vertices_per_polyon())) { + WARN_PRINT("Property vertices_per_polyon is converted to int and loses precision."); } - if (p_nav_mesh->get_cell_size() * p_nav_mesh->get_detail_sample_distance() < 0.1f) { + if (p_navigation_mesh->get_cell_size() * p_navigation_mesh->get_detail_sample_distance() < 0.1f) { WARN_PRINT("Property detail_sample_distance is clamped to 0.1 world units as the resulting value from multiplying with cell_size is too low."); } @@ -574,9 +574,9 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh( cfg.bmax[1] = bmax[1]; cfg.bmax[2] = bmax[2]; - AABB baking_aabb = p_nav_mesh->get_filter_baking_aabb(); + AABB baking_aabb = p_navigation_mesh->get_filter_baking_aabb(); if (baking_aabb.has_volume()) { - Vector3 baking_aabb_offset = p_nav_mesh->get_filter_baking_aabb_offset(); + Vector3 baking_aabb_offset = p_navigation_mesh->get_filter_baking_aabb_offset(); cfg.bmin[0] = baking_aabb.position[0] + baking_aabb_offset.x; cfg.bmin[1] = baking_aabb.position[1] + baking_aabb_offset.y; cfg.bmin[2] = baking_aabb.position[2] + baking_aabb_offset.z; @@ -627,13 +627,13 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh( ERR_FAIL_COND(!rcRasterizeTriangles(&ctx, verts, nverts, tris, tri_areas.ptr(), ntris, *hf, cfg.walkableClimb)); } - if (p_nav_mesh->get_filter_low_hanging_obstacles()) { + if (p_navigation_mesh->get_filter_low_hanging_obstacles()) { rcFilterLowHangingWalkableObstacles(&ctx, cfg.walkableClimb, *hf); } - if (p_nav_mesh->get_filter_ledge_spans()) { + if (p_navigation_mesh->get_filter_ledge_spans()) { rcFilterLedgeSpans(&ctx, cfg.walkableHeight, cfg.walkableClimb, *hf); } - if (p_nav_mesh->get_filter_walkable_low_height_spans()) { + if (p_navigation_mesh->get_filter_walkable_low_height_spans()) { rcFilterWalkableLowHeightSpans(&ctx, cfg.walkableHeight, *hf); } @@ -665,10 +665,10 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh( } #endif - if (p_nav_mesh->get_sample_partition_type() == NavigationMesh::SAMPLE_PARTITION_WATERSHED) { + if (p_navigation_mesh->get_sample_partition_type() == NavigationMesh::SAMPLE_PARTITION_WATERSHED) { ERR_FAIL_COND(!rcBuildDistanceField(&ctx, *chf)); ERR_FAIL_COND(!rcBuildRegions(&ctx, *chf, 0, cfg.minRegionArea, cfg.mergeRegionArea)); - } else if (p_nav_mesh->get_sample_partition_type() == NavigationMesh::SAMPLE_PARTITION_MONOTONE) { + } else if (p_navigation_mesh->get_sample_partition_type() == NavigationMesh::SAMPLE_PARTITION_MONOTONE) { ERR_FAIL_COND(!rcBuildRegionsMonotone(&ctx, *chf, 0, cfg.minRegionArea, cfg.mergeRegionArea)); } else { ERR_FAIL_COND(!rcBuildLayerRegions(&ctx, *chf, 0, cfg.minRegionArea)); @@ -710,7 +710,7 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh( } #endif - _convert_detail_mesh_to_native_navigation_mesh(detail_mesh, p_nav_mesh); + _convert_detail_mesh_to_native_navigation_mesh(detail_mesh, p_navigation_mesh); rcFreePolyMesh(poly_mesh); poly_mesh = nullptr; @@ -729,8 +729,8 @@ NavigationMeshGenerator::NavigationMeshGenerator() { NavigationMeshGenerator::~NavigationMeshGenerator() { } -void NavigationMeshGenerator::bake(Ref p_nav_mesh, Node *p_node) { - ERR_FAIL_COND_MSG(!p_nav_mesh.is_valid(), "Invalid navigation mesh."); +void NavigationMeshGenerator::bake(Ref p_navigation_mesh, Node *p_root_node) { + ERR_FAIL_COND_MSG(!p_navigation_mesh.is_valid(), "Invalid navigation mesh."); #ifdef TOOLS_ENABLED EditorProgress *ep(nullptr); @@ -755,17 +755,17 @@ void NavigationMeshGenerator::bake(Ref p_nav_mesh, Node *p_node) List parse_nodes; - if (p_nav_mesh->get_source_geometry_mode() == NavigationMesh::SOURCE_GEOMETRY_NAVMESH_CHILDREN) { - parse_nodes.push_back(p_node); + if (p_navigation_mesh->get_source_geometry_mode() == NavigationMesh::SOURCE_GEOMETRY_ROOT_NODE_CHILDREN) { + parse_nodes.push_back(p_root_node); } else { - p_node->get_tree()->get_nodes_in_group(p_nav_mesh->get_source_group_name(), &parse_nodes); + p_root_node->get_tree()->get_nodes_in_group(p_navigation_mesh->get_source_group_name(), &parse_nodes); } - Transform3D navmesh_xform = Object::cast_to(p_node)->get_global_transform().affine_inverse(); + Transform3D navmesh_xform = Object::cast_to(p_root_node)->get_global_transform().affine_inverse(); for (Node *E : parse_nodes) { - NavigationMesh::ParsedGeometryType geometry_type = p_nav_mesh->get_parsed_geometry_type(); - uint32_t collision_mask = p_nav_mesh->get_collision_mask(); - bool recurse_children = p_nav_mesh->get_source_geometry_mode() != NavigationMesh::SOURCE_GEOMETRY_GROUPS_EXPLICIT; + NavigationMesh::ParsedGeometryType geometry_type = p_navigation_mesh->get_parsed_geometry_type(); + uint32_t collision_mask = p_navigation_mesh->get_collision_mask(); + bool recurse_children = p_navigation_mesh->get_source_geometry_mode() != NavigationMesh::SOURCE_GEOMETRY_GROUPS_EXPLICIT; _parse_geometry(navmesh_xform, E, vertices, indices, geometry_type, collision_mask, recurse_children); } @@ -777,7 +777,7 @@ void NavigationMeshGenerator::bake(Ref p_nav_mesh, Node *p_node) rcPolyMeshDetail *detail_mesh = nullptr; _build_recast_navigation_mesh( - p_nav_mesh, + p_navigation_mesh, #ifdef TOOLS_ENABLED ep, #endif @@ -816,16 +816,16 @@ void NavigationMeshGenerator::bake(Ref p_nav_mesh, Node *p_node) #endif } -void NavigationMeshGenerator::clear(Ref p_nav_mesh) { - if (p_nav_mesh.is_valid()) { - p_nav_mesh->clear_polygons(); - p_nav_mesh->set_vertices(Vector()); +void NavigationMeshGenerator::clear(Ref p_navigation_mesh) { + if (p_navigation_mesh.is_valid()) { + p_navigation_mesh->clear_polygons(); + p_navigation_mesh->set_vertices(Vector()); } } void NavigationMeshGenerator::_bind_methods() { - ClassDB::bind_method(D_METHOD("bake", "nav_mesh", "root_node"), &NavigationMeshGenerator::bake); - ClassDB::bind_method(D_METHOD("clear", "nav_mesh"), &NavigationMeshGenerator::clear); + ClassDB::bind_method(D_METHOD("bake", "navigation_mesh", "root_node"), &NavigationMeshGenerator::bake); + ClassDB::bind_method(D_METHOD("clear", "navigation_mesh"), &NavigationMeshGenerator::clear); } #endif diff --git a/modules/navigation/navigation_mesh_generator.h b/modules/navigation/navigation_mesh_generator.h index 8cc1531b53..f6bf39d714 100644 --- a/modules/navigation/navigation_mesh_generator.h +++ b/modules/navigation/navigation_mesh_generator.h @@ -55,9 +55,9 @@ protected: static void _add_faces(const PackedVector3Array &p_faces, const Transform3D &p_xform, Vector &p_vertices, Vector &p_indices); static void _parse_geometry(const Transform3D &p_navmesh_transform, Node *p_node, Vector &p_vertices, Vector &p_indices, NavigationMesh::ParsedGeometryType p_generate_from, uint32_t p_collision_mask, bool p_recurse_children); - static void _convert_detail_mesh_to_native_navigation_mesh(const rcPolyMeshDetail *p_detail_mesh, Ref p_nav_mesh); + static void _convert_detail_mesh_to_native_navigation_mesh(const rcPolyMeshDetail *p_detail_mesh, Ref p_navigation_mesh); static void _build_recast_navigation_mesh( - Ref p_nav_mesh, + Ref p_navigation_mesh, #ifdef TOOLS_ENABLED EditorProgress *ep, #endif @@ -75,8 +75,8 @@ public: NavigationMeshGenerator(); ~NavigationMeshGenerator(); - void bake(Ref p_nav_mesh, Node *p_node); - void clear(Ref p_nav_mesh); + void bake(Ref p_navigation_mesh, Node *p_root_node); + void clear(Ref p_navigation_mesh); }; #endif -- cgit v1.2.3