diff options
Diffstat (limited to 'modules/navigation/nav_mesh_generator_3d.cpp')
-rw-r--r-- | modules/navigation/nav_mesh_generator_3d.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/modules/navigation/nav_mesh_generator_3d.cpp b/modules/navigation/nav_mesh_generator_3d.cpp index 8719801c72..df93edaaea 100644 --- a/modules/navigation/nav_mesh_generator_3d.cpp +++ b/modules/navigation/nav_mesh_generator_3d.cpp @@ -625,6 +625,9 @@ void NavMeshGenerator3D::generator_bake_from_source_geometry_data(Ref<Navigation cfg.cs = p_navigation_mesh->get_cell_size(); cfg.ch = p_navigation_mesh->get_cell_height(); + if (p_navigation_mesh->get_border_size() > 0.0) { + cfg.borderSize = (int)Math::ceil(p_navigation_mesh->get_border_size() / cfg.cs); + } 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); @@ -637,6 +640,9 @@ void NavMeshGenerator3D::generator_bake_from_source_geometry_data(Ref<Navigation 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 (p_navigation_mesh->get_border_size() > 0.0 && !Math::is_equal_approx(p_navigation_mesh->get_cell_size(), p_navigation_mesh->get_border_size())) { + WARN_PRINT("Property border_size is ceiled to cell_size voxel units and loses precision."); + } 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."); } @@ -738,11 +744,11 @@ void NavMeshGenerator3D::generator_bake_from_source_geometry_data(Ref<Navigation 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)); + ERR_FAIL_COND(!rcBuildRegions(&ctx, *chf, cfg.borderSize, cfg.minRegionArea, cfg.mergeRegionArea)); } else if (p_navigation_mesh->get_sample_partition_type() == NavigationMesh::SAMPLE_PARTITION_MONOTONE) { - ERR_FAIL_COND(!rcBuildRegionsMonotone(&ctx, *chf, 0, cfg.minRegionArea, cfg.mergeRegionArea)); + ERR_FAIL_COND(!rcBuildRegionsMonotone(&ctx, *chf, cfg.borderSize, cfg.minRegionArea, cfg.mergeRegionArea)); } else { - ERR_FAIL_COND(!rcBuildLayerRegions(&ctx, *chf, 0, cfg.minRegionArea)); + ERR_FAIL_COND(!rcBuildLayerRegions(&ctx, *chf, cfg.borderSize, cfg.minRegionArea)); } bake_state = "Creating contours..."; // step #8 |