diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 16:41:43 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 21:57:34 +0200 |
commit | 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 (patch) | |
tree | 198d4ff7665d89307f6ca2469fa38620a9eb1672 /modules/gdnavigation | |
parent | 07bc4e2f96f8f47991339654ff4ab16acc19d44f (diff) |
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
Diffstat (limited to 'modules/gdnavigation')
-rw-r--r-- | modules/gdnavigation/gd_navigation_server.cpp | 6 | ||||
-rw-r--r-- | modules/gdnavigation/nav_map.cpp | 20 | ||||
-rw-r--r-- | modules/gdnavigation/nav_region.cpp | 6 | ||||
-rw-r--r-- | modules/gdnavigation/navigation_mesh_editor_plugin.cpp | 3 | ||||
-rw-r--r-- | modules/gdnavigation/navigation_mesh_generator.cpp | 51 |
5 files changed, 57 insertions, 29 deletions
diff --git a/modules/gdnavigation/gd_navigation_server.cpp b/modules/gdnavigation/gd_navigation_server.cpp index 5aea9f8b9f..c80cdcfeab 100644 --- a/modules/gdnavigation/gd_navigation_server.cpp +++ b/modules/gdnavigation/gd_navigation_server.cpp @@ -249,8 +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); @@ -303,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 e55a3deb8f..c7df6dc1fb 100644 --- a/modules/gdnavigation/nav_map.cpp +++ b/modules/gdnavigation/nav_map.cpp @@ -145,8 +145,9 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p 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] = { @@ -343,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(); @@ -711,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); } @@ -746,12 +750,14 @@ 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); diff --git a/modules/gdnavigation/nav_region.cpp b/modules/gdnavigation/nav_region.cpp index 3dff19cd65..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(); diff --git a/modules/gdnavigation/navigation_mesh_editor_plugin.cpp b/modules/gdnavigation/navigation_mesh_editor_plugin.cpp index 379131864e..5fe1060aae 100644 --- a/modules/gdnavigation/navigation_mesh_editor_plugin.cpp +++ b/modules/gdnavigation/navigation_mesh_editor_plugin.cpp @@ -69,8 +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(""); diff --git a/modules/gdnavigation/navigation_mesh_generator.cpp b/modules/gdnavigation/navigation_mesh_generator.cpp index 78818fd990..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) { @@ -314,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(); @@ -351,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(); @@ -366,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; @@ -381,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(); @@ -402,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) { @@ -423,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(); @@ -433,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(); @@ -451,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); @@ -483,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; @@ -543,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 } |