summaryrefslogtreecommitdiff
path: root/modules/gdnavigation
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-05-14 23:09:03 +0200
committerGitHub <noreply@github.com>2020-05-14 23:09:03 +0200
commit00949f0c5fcc6a4f8382a4a97d5591fd9ec380f8 (patch)
tree2b1c31f45add24085b64425ce440f577424c16a1 /modules/gdnavigation
parent5046f666a1181675b39f156c38346525dc1c444e (diff)
parent0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 (diff)
Merge pull request #38738 from akien-mga/cause-we-never-go-out-of-style
Style: Remove new line at block start, enforce line between functions, enforce braces in if and loop blocks
Diffstat (limited to 'modules/gdnavigation')
-rw-r--r--modules/gdnavigation/gd_navigation_server.cpp7
-rw-r--r--modules/gdnavigation/nav_map.cpp43
-rw-r--r--modules/gdnavigation/nav_map.h1
-rw-r--r--modules/gdnavigation/nav_region.cpp8
-rw-r--r--modules/gdnavigation/nav_utils.h3
-rw-r--r--modules/gdnavigation/navigation_mesh_editor_plugin.cpp14
-rw-r--r--modules/gdnavigation/navigation_mesh_editor_plugin.h1
-rw-r--r--modules/gdnavigation/navigation_mesh_generator.cpp59
8 files changed, 57 insertions, 79 deletions
diff --git a/modules/gdnavigation/gd_navigation_server.cpp b/modules/gdnavigation/gd_navigation_server.cpp
index 3792098af4..c80cdcfeab 100644
--- a/modules/gdnavigation/gd_navigation_server.cpp
+++ b/modules/gdnavigation/gd_navigation_server.cpp
@@ -249,9 +249,9 @@ COMMAND_2(region_set_map, RID, p_region, RID, p_map) {
ERR_FAIL_COND(region == nullptr);
if (region->get_map() != nullptr) {
-
- if (region->get_map()->get_self() == p_map)
+ if (region->get_map()->get_self() == p_map) {
return; // Pointless
+ }
region->get_map()->remove_region(region);
region->set_map(nullptr);
@@ -304,8 +304,9 @@ COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) {
ERR_FAIL_COND(agent == nullptr);
if (agent->get_map()) {
- if (agent->get_map()->get_self() == p_map)
+ if (agent->get_map()->get_self() == p_map) {
return; // Pointless
+ }
agent->get_map()->remove_agent(agent);
}
diff --git a/modules/gdnavigation/nav_map.cpp b/modules/gdnavigation/nav_map.cpp
index d6dd95d6e7..c7df6dc1fb 100644
--- a/modules/gdnavigation/nav_map.cpp
+++ b/modules/gdnavigation/nav_map.cpp
@@ -71,7 +71,6 @@ gd::PointKey NavMap::get_point_key(const Vector3 &p_pos) const {
}
Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p_optimize) const {
-
const gd::Polygon *begin_poly = nullptr;
const gd::Polygon *end_poly = nullptr;
Vector3 begin_point;
@@ -85,7 +84,6 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
// For each point cast a face and check the distance between the origin/destination
for (size_t point_id = 2; point_id < p.points.size(); point_id++) {
-
Face3 f(p.points[point_id - 2].pos, p.points[point_id - 1].pos, p.points[point_id].pos);
Vector3 spoint = f.get_closest_point_to(p_origin);
float dpoint = spoint.distance_to(p_origin);
@@ -111,7 +109,6 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
}
if (begin_poly == end_poly) {
-
Vector<Vector3> path;
path.resize(2);
path.write[0] = begin_point;
@@ -142,15 +139,15 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
bool is_reachable = true;
while (found_route == false) {
-
{
// Takes the current least_cost_poly neighbors and compute the traveled_distance of each
for (size_t i = 0; i < navigation_polys[least_cost_id].poly->edges.size(); i++) {
gd::NavigationPoly *least_cost_poly = &navigation_polys[least_cost_id];
const gd::Edge &edge = least_cost_poly->poly->edges[i];
- if (!edge.other_polygon)
+ if (!edge.other_polygon) {
continue;
+ }
#ifdef USE_ENTRY_POINT
Vector3 edge_line[2] = {
@@ -172,7 +169,6 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
if (it != navigation_polys.end()) {
// Oh this was visited already, can we win the cost?
if (it->traveled_distance > new_distance) {
-
it->prev_navigation_poly_id = least_cost_id;
it->back_navigation_edge = edge.other_edge;
it->traveled_distance = new_distance;
@@ -274,10 +270,8 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
}
if (found_route) {
-
Vector<Vector3> path;
if (p_optimize) {
-
// String pulling
gd::NavigationPoly *apex_poly = &navigation_polys[least_cost_id];
@@ -291,7 +285,6 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
path.push_back(end_point);
while (p) {
-
Vector3 left;
Vector3 right;
@@ -320,7 +313,6 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
left_poly = p;
portal_left = left;
} else {
-
clip_path(navigation_polys, path, apex_poly, portal_right, right_poly);
apex_point = portal_right;
@@ -340,7 +332,6 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
right_poly = p;
portal_right = right;
} else {
-
clip_path(navigation_polys, path, apex_poly, portal_left, left_poly);
apex_point = portal_left;
@@ -353,15 +344,17 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
}
}
- if (p->prev_navigation_poly_id != -1)
+ if (p->prev_navigation_poly_id != -1) {
p = &navigation_polys[p->prev_navigation_poly_id];
- else
+ } else {
// The end
p = nullptr;
+ }
}
- if (path[path.size() - 1] != begin_point)
+ if (path[path.size() - 1] != begin_point) {
path.push_back(begin_point);
+ }
path.invert();
@@ -371,7 +364,6 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
// Add mid points
int np_id = least_cost_id;
while (np_id != -1) {
-
#ifdef USE_ENTRY_POINT
Vector3 point = navigation_polys[np_id].entry;
#else
@@ -393,7 +385,6 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
}
Vector3 NavMap::get_closest_point_to_segment(const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision) const {
-
bool use_collision = p_use_collision;
Vector3 closest_point;
real_t closest_point_d = 1e20;
@@ -404,7 +395,6 @@ Vector3 NavMap::get_closest_point_to_segment(const Vector3 &p_from, const Vector
// For each point cast a face and check the distance to the segment
for (size_t point_id = 2; point_id < p.points.size(); point_id += 1) {
-
const Face3 f(p.points[point_id - 2].pos, p.points[point_id - 1].pos, p.points[point_id].pos);
Vector3 inters;
if (f.intersects_segment(p_from, p_to, &inters)) {
@@ -414,7 +404,6 @@ Vector3 NavMap::get_closest_point_to_segment(const Vector3 &p_from, const Vector
use_collision = true;
closest_point_d = d;
} else if (closest_point_d > d) {
-
closest_point = inters;
closest_point_d = d;
}
@@ -422,9 +411,7 @@ Vector3 NavMap::get_closest_point_to_segment(const Vector3 &p_from, const Vector
}
if (use_collision == false) {
-
for (size_t point_id = 0; point_id < p.points.size(); point_id += 1) {
-
Vector3 a, b;
Geometry::get_closest_points_between_segments(
@@ -437,7 +424,6 @@ Vector3 NavMap::get_closest_point_to_segment(const Vector3 &p_from, const Vector
const real_t d = a.distance_to(b);
if (d < closest_point_d) {
-
closest_point_d = d;
closest_point = b;
}
@@ -460,7 +446,6 @@ Vector3 NavMap::get_closest_point(const Vector3 &p_point) const {
// For each point cast a face and check the distance to the point
for (size_t point_id = 2; point_id < p.points.size(); point_id += 1) {
-
const Face3 f(p.points[point_id - 2].pos, p.points[point_id - 1].pos, p.points[point_id].pos);
const Vector3 inters = f.get_closest_point_to(p_point);
const real_t d = inters.distance_to(p_point);
@@ -487,7 +472,6 @@ Vector3 NavMap::get_closest_point_normal(const Vector3 &p_point) const {
// For each point cast a face and check the distance to the point
for (size_t point_id = 2; point_id < p.points.size(); point_id += 1) {
-
const Face3 f(p.points[point_id - 2].pos, p.points[point_id - 1].pos, p.points[point_id].pos);
const Vector3 inters = f.get_closest_point_to(p_point);
const real_t d = inters.distance_to(p_point);
@@ -515,7 +499,6 @@ RID NavMap::get_closest_point_owner(const Vector3 &p_point) const {
// For each point cast a face and check the distance to the point
for (size_t point_id = 2; point_id < p.points.size(); point_id += 1) {
-
const Face3 f(p.points[point_id - 2].pos, p.points[point_id - 1].pos, p.points[point_id].pos);
const Vector3 inters = f.get_closest_point_to(p_point);
const real_t d = inters.distance_to(p_point);
@@ -579,7 +562,6 @@ void NavMap::remove_agent_as_controlled(RvoAgent *agent) {
}
void NavMap::sync() {
-
if (regenerate_polygons) {
for (size_t r(0); r < regions.size(); r++) {
regions[r]->scratch_polygons();
@@ -732,8 +714,9 @@ void NavMap::sync() {
if (agents_dirty) {
std::vector<RVO::Agent *> raw_agents;
raw_agents.reserve(agents.size());
- for (size_t i(0); i < agents.size(); i++)
+ for (size_t i(0); i < agents.size(); i++) {
raw_agents.push_back(agents[i]->get_agent());
+ }
rvo.buildAgentTree(raw_agents);
}
@@ -767,17 +750,18 @@ void NavMap::dispatch_callbacks() {
void NavMap::clip_path(const std::vector<gd::NavigationPoly> &p_navigation_polys, Vector<Vector3> &path, const gd::NavigationPoly *from_poly, const Vector3 &p_to_point, const gd::NavigationPoly *p_to_poly) const {
Vector3 from = path[path.size() - 1];
- if (from.distance_to(p_to_point) < CMP_EPSILON)
+ if (from.distance_to(p_to_point) < CMP_EPSILON) {
return;
+ }
Plane cut_plane;
cut_plane.normal = (from - p_to_point).cross(up);
- if (cut_plane.normal == Vector3())
+ if (cut_plane.normal == Vector3()) {
return;
+ }
cut_plane.normal.normalize();
cut_plane.d = cut_plane.normal.dot(from);
while (from_poly != p_to_poly) {
-
int back_nav_edge = from_poly->back_navigation_edge;
Vector3 a = from_poly->poly->points[back_nav_edge].pos;
Vector3 b = from_poly->poly->points[(back_nav_edge + 1) % from_poly->poly->points.size()].pos;
@@ -786,7 +770,6 @@ void NavMap::clip_path(const std::vector<gd::NavigationPoly> &p_navigation_polys
from_poly = &p_navigation_polys[from_poly->prev_navigation_poly_id];
if (a.distance_to(b) > CMP_EPSILON) {
-
Vector3 inters;
if (cut_plane.intersects_segment(a, b, &inters)) {
if (inters.distance_to(p_to_point) > CMP_EPSILON && inters.distance_to(path[path.size() - 1]) > CMP_EPSILON) {
diff --git a/modules/gdnavigation/nav_map.h b/modules/gdnavigation/nav_map.h
index d39e301511..892755f3f9 100644
--- a/modules/gdnavigation/nav_map.h
+++ b/modules/gdnavigation/nav_map.h
@@ -46,7 +46,6 @@ class RvoAgent;
class NavRegion;
class NavMap : public NavRid {
-
/// Map Up
Vector3 up = Vector3(0, 1, 0);
diff --git a/modules/gdnavigation/nav_region.cpp b/modules/gdnavigation/nav_region.cpp
index 2bd42ba980..51fba67cc3 100644
--- a/modules/gdnavigation/nav_region.cpp
+++ b/modules/gdnavigation/nav_region.cpp
@@ -70,13 +70,15 @@ void NavRegion::update_polygons() {
return;
}
- if (mesh.is_null())
+ if (mesh.is_null()) {
return;
+ }
Vector<Vector3> vertices = mesh->get_vertices();
int len = vertices.size();
- if (len == 0)
+ if (len == 0) {
return;
+ }
const Vector3 *vertices_r = vertices.ptr();
@@ -84,7 +86,6 @@ void NavRegion::update_polygons() {
// Build
for (size_t i(0); i < polygons.size(); i++) {
-
gd::Polygon &p = polygons[i];
p.owner = this;
@@ -98,7 +99,6 @@ void NavRegion::update_polygons() {
float sum(0);
for (int j(0); j < mesh_poly.size(); j++) {
-
int idx = indices[j];
if (idx < 0 || idx >= len) {
valid = false;
diff --git a/modules/gdnavigation/nav_utils.h b/modules/gdnavigation/nav_utils.h
index 388e53a66a..40e54df553 100644
--- a/modules/gdnavigation/nav_utils.h
+++ b/modules/gdnavigation/nav_utils.h
@@ -45,7 +45,6 @@ namespace gd {
struct Polygon;
union PointKey {
-
struct {
int64_t x : 21;
int64_t y : 22;
@@ -57,7 +56,6 @@ union PointKey {
};
struct EdgeKey {
-
PointKey a;
PointKey b;
@@ -109,7 +107,6 @@ struct Polygon {
};
struct Connection {
-
Polygon *A = nullptr;
int A_edge = -1;
Polygon *B = nullptr;
diff --git a/modules/gdnavigation/navigation_mesh_editor_plugin.cpp b/modules/gdnavigation/navigation_mesh_editor_plugin.cpp
index abaf73ba6a..5fe1060aae 100644
--- a/modules/gdnavigation/navigation_mesh_editor_plugin.cpp
+++ b/modules/gdnavigation/navigation_mesh_editor_plugin.cpp
@@ -38,7 +38,6 @@
#include "scene/gui/box_container.h"
void NavigationMeshEditor::_node_removed(Node *p_node) {
-
if (p_node == node) {
node = nullptr;
@@ -47,9 +46,7 @@ void NavigationMeshEditor::_node_removed(Node *p_node) {
}
void NavigationMeshEditor::_notification(int p_option) {
-
if (p_option == NOTIFICATION_ENTER_TREE) {
-
button_bake->set_icon(get_theme_icon("Bake", "EditorIcons"));
button_reset->set_icon(get_theme_icon("Reload", "EditorIcons"));
}
@@ -72,9 +69,9 @@ void NavigationMeshEditor::_bake_pressed() {
}
void NavigationMeshEditor::_clear_pressed() {
-
- if (node)
+ if (node) {
NavigationMeshGenerator::get_singleton()->clear(node->get_navigation_mesh());
+ }
button_bake->set_pressed(false);
bake_info->set_text("");
@@ -85,7 +82,6 @@ void NavigationMeshEditor::_clear_pressed() {
}
void NavigationMeshEditor::edit(NavigationRegion3D *p_nav_region) {
-
if (p_nav_region == nullptr || node == p_nav_region) {
return;
}
@@ -97,7 +93,6 @@ void NavigationMeshEditor::_bind_methods() {
}
NavigationMeshEditor::NavigationMeshEditor() {
-
bake_hbox = memnew(HBoxContainer);
button_bake = memnew(ToolButton);
@@ -124,22 +119,18 @@ NavigationMeshEditor::~NavigationMeshEditor() {
}
void NavigationMeshEditorPlugin::edit(Object *p_object) {
-
navigation_mesh_editor->edit(Object::cast_to<NavigationRegion3D>(p_object));
}
bool NavigationMeshEditorPlugin::handles(Object *p_object) const {
-
return p_object->is_class("NavigationRegion3D");
}
void NavigationMeshEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
navigation_mesh_editor->show();
navigation_mesh_editor->bake_hbox->show();
} else {
-
navigation_mesh_editor->hide();
navigation_mesh_editor->bake_hbox->hide();
navigation_mesh_editor->edit(nullptr);
@@ -147,7 +138,6 @@ void NavigationMeshEditorPlugin::make_visible(bool p_visible) {
}
NavigationMeshEditorPlugin::NavigationMeshEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
navigation_mesh_editor = memnew(NavigationMeshEditor);
editor->get_viewport()->add_child(navigation_mesh_editor);
diff --git a/modules/gdnavigation/navigation_mesh_editor_plugin.h b/modules/gdnavigation/navigation_mesh_editor_plugin.h
index 434981c9e0..da3a981f8c 100644
--- a/modules/gdnavigation/navigation_mesh_editor_plugin.h
+++ b/modules/gdnavigation/navigation_mesh_editor_plugin.h
@@ -67,7 +67,6 @@ public:
};
class NavigationMeshEditorPlugin : public EditorPlugin {
-
GDCLASS(NavigationMeshEditorPlugin, EditorPlugin);
NavigationMeshEditor *navigation_mesh_editor;
diff --git a/modules/gdnavigation/navigation_mesh_generator.cpp b/modules/gdnavigation/navigation_mesh_generator.cpp
index acb4f0461f..7dc08fbf29 100644
--- a/modules/gdnavigation/navigation_mesh_generator.cpp
+++ b/modules/gdnavigation/navigation_mesh_generator.cpp
@@ -74,8 +74,9 @@ void NavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Transform
for (int i = 0; i < p_mesh->get_surface_count(); i++) {
current_vertex_count = p_verticies.size() / 3;
- if (p_mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES)
+ if (p_mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) {
continue;
+ }
int index_count = 0;
if (p_mesh->surface_get_format(i) & Mesh::ARRAY_FORMAT_INDEX) {
@@ -94,7 +95,6 @@ void NavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Transform
const Vector3 *vr = mesh_vertices.ptr();
if (p_mesh->surface_get_format(i) & Mesh::ARRAY_FORMAT_INDEX) {
-
Vector<int> mesh_indices = a[Mesh::ARRAY_INDEX];
const int *ir = mesh_indices.ptr();
@@ -139,9 +139,7 @@ void NavigationMeshGenerator::_add_faces(const PackedVector3Array &p_faces, cons
}
void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform, Node *p_node, Vector<float> &p_verticies, Vector<int> &p_indices, int p_generate_from, uint32_t p_collision_mask, bool p_recurse_children) {
-
if (Object::cast_to<MeshInstance3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
-
MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(p_node);
Ref<Mesh> mesh = mesh_instance->get_mesh();
if (mesh.is_valid()) {
@@ -151,7 +149,6 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
#ifdef MODULE_CSG_ENABLED
if (Object::cast_to<CSGShape3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) {
-
CSGShape3D *csg_shape = Object::cast_to<CSGShape3D>(p_node);
Array meshes = csg_shape->get_meshes();
if (!meshes.empty()) {
@@ -167,7 +164,6 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
StaticBody3D *static_body = Object::cast_to<StaticBody3D>(p_node);
if (static_body->get_collision_layer() & p_collision_mask) {
-
for (int i = 0; i < p_node->get_child_count(); ++i) {
Node *child = p_node->get_child(i);
if (Object::cast_to<CollisionShape3D>(child)) {
@@ -278,7 +274,6 @@ void NavigationMeshGenerator::_parse_geometry(Transform p_accumulated_transform,
}
void NavigationMeshGenerator::_convert_detail_mesh_to_native_navigation_mesh(const rcPolyMeshDetail *p_detail_mesh, Ref<NavigationMesh> p_nav_mesh) {
-
Vector<Vector3> nav_vertices;
for (int i = 0; i < p_detail_mesh->nverts; i++) {
@@ -320,8 +315,9 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
rcContext ctx;
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Setting up Configuration..."), 1);
+ }
#endif
const float *verts = vertices.ptr();
@@ -357,14 +353,16 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
cfg.bmax[2] = bmax[2];
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Calculating grid size..."), 2);
+ }
#endif
rcCalcGridSize(cfg.bmin, cfg.bmax, cfg.cs, &cfg.width, &cfg.height);
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Creating heightfield..."), 3);
+ }
#endif
hf = rcAllocHeightfield();
@@ -372,8 +370,9 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
ERR_FAIL_COND(!rcCreateHeightfield(&ctx, *hf, cfg.width, cfg.height, cfg.bmin, cfg.bmax, cfg.cs, cfg.ch));
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Marking walkable triangles..."), 4);
+ }
#endif
{
Vector<unsigned char> tri_areas;
@@ -387,16 +386,20 @@ 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_nav_mesh->get_filter_low_hanging_obstacles()) {
rcFilterLowHangingWalkableObstacles(&ctx, cfg.walkableClimb, *hf);
- if (p_nav_mesh->get_filter_ledge_spans())
+ }
+ if (p_nav_mesh->get_filter_ledge_spans()) {
rcFilterLedgeSpans(&ctx, cfg.walkableHeight, cfg.walkableClimb, *hf);
- if (p_nav_mesh->get_filter_walkable_low_height_spans())
+ }
+ if (p_nav_mesh->get_filter_walkable_low_height_spans()) {
rcFilterWalkableLowHeightSpans(&ctx, cfg.walkableHeight, *hf);
+ }
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Constructing compact heightfield..."), 5);
+ }
#endif
chf = rcAllocCompactHeightfield();
@@ -408,15 +411,17 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
hf = nullptr;
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Eroding walkable area..."), 6);
+ }
#endif
ERR_FAIL_COND(!rcErodeWalkableArea(&ctx, cfg.walkableRadius, *chf));
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Partitioning..."), 7);
+ }
#endif
if (p_nav_mesh->get_sample_partition_type() == NavigationMesh::SAMPLE_PARTITION_WATERSHED) {
@@ -429,8 +434,9 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
}
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Creating contours..."), 8);
+ }
#endif
cset = rcAllocContourSet();
@@ -439,8 +445,9 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
ERR_FAIL_COND(!rcBuildContours(&ctx, *chf, cfg.maxSimplificationError, cfg.maxEdgeLen, *cset));
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Creating polymesh..."), 9);
+ }
#endif
poly_mesh = rcAllocPolyMesh();
@@ -457,8 +464,9 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(
cset = nullptr;
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Converting to native navigation mesh..."), 10);
+ }
#endif
_convert_detail_mesh_to_native_navigation_mesh(detail_mesh, p_nav_mesh);
@@ -481,7 +489,6 @@ NavigationMeshGenerator::~NavigationMeshGenerator() {
}
void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node) {
-
ERR_FAIL_COND(!p_nav_mesh.is_valid());
#ifdef TOOLS_ENABLED
@@ -490,8 +497,9 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node)
ep = memnew(EditorProgress("bake", TTR("Navigation Mesh Generator Setup:"), 11));
}
- if (ep)
+ if (ep) {
ep->step(TTR("Parsing Geometry..."), 0);
+ }
#endif
Vector<float> vertices;
@@ -514,7 +522,6 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node)
}
if (vertices.size() > 0 && indices.size() > 0) {
-
rcHeightfield *hf = nullptr;
rcCompactHeightfield *chf = nullptr;
rcContourSet *cset = nullptr;
@@ -551,11 +558,13 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node)
}
#ifdef TOOLS_ENABLED
- if (ep)
+ if (ep) {
ep->step(TTR("Done!"), 11);
+ }
- if (ep)
+ if (ep) {
memdelete(ep);
+ }
#endif
}