From 5e693b6d84e62b352690a203cc3e46d481b18083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 10 May 2022 12:05:52 +0200 Subject: [PATCH] Fix warnings found by Emscripten 3.1.10 Fix `-Wunused-but-set-variable`, `-Wunqualified-std-cast-call`, and `-Wliteral-range` warnings. (cherry picked from commit d8935b27a9af8a6484d271a5b4ebc967a9d0a36f) --- core/math/bsp_tree.cpp | 4 ++-- core/math/quick_hull.cpp | 2 -- modules/csg/csg.cpp | 7 +++---- modules/gdscript/gdscript_compiler.cpp | 4 ---- scene/3d/voxel_light_baker.cpp | 3 --- scene/resources/polygon_path_finder.cpp | 8 ++++---- servers/visual/portals/portal_rooms_bsp.cpp | 3 --- servers/visual/visual_server_scene.cpp | 12 ------------ servers/visual/visual_server_viewport.cpp | 7 ------- thirdparty/bullet/BulletSoftBody/btSparseSDF.h | 6 +++--- .../patches/fix-unused-but-set-warning.patch | 17 +++++++++++++++++ 11 files changed, 29 insertions(+), 44 deletions(-) create mode 100644 thirdparty/bullet/patches/fix-unused-but-set-warning.patch diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp index ff3eaea667d..9a60a0805fc 100644 --- a/core/math/bsp_tree.cpp +++ b/core/math/bsp_tree.cpp @@ -271,7 +271,7 @@ static int _bsp_find_best_half_plane(const Face3 *p_faces, const Vector &p_ const Face3 &f = p_faces[indices[i]]; Plane p = f.get_plane(); - int num_over = 0, num_under = 0, num_spanning = 0; + int num_over = 0, num_under = 0; //num_spanning = 0; for (int j = 0; j < ic; j++) { if (i == j) { @@ -294,7 +294,7 @@ static int _bsp_find_best_half_plane(const Face3 *p_faces, const Vector &p_ } if (over && under) { - num_spanning++; + //num_spanning++; } else if (over) { num_over++; } else { diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp index 17e43abcebc..8bbba3262b3 100644 --- a/core/math/quick_hull.cpp +++ b/core/math/quick_hull.cpp @@ -394,7 +394,6 @@ Error QuickHull::build(const Vector &p_points, Geometry::MeshData &r_me if (O->get().plane.is_equal_approx(f.plane)) { //merge and delete edge and contiguous face, while repointing edges (uuugh!) int ois = O->get().indices.size(); - int merged = 0; for (int j = 0; j < ois; j++) { //search a @@ -409,7 +408,6 @@ Error QuickHull::build(const Vector &p_points, Geometry::MeshData &r_me if (idx != a) { f.indices.insert(i + 1, idx); i++; - merged++; } Edge e2(idx, idxn); diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index 25ae92eb045..16fa0ac3794 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -1387,13 +1387,13 @@ void CSGBrushOperation::update_faces(const CSGBrush &p_brush_a, const int p_face } // Ensure B has points either side of or in the plane of A. - int in_plane_count = 0, over_count = 0, under_count = 0; + int over_count = 0, under_count = 0; Plane plane_a(vertices_a[0], vertices_a[1], vertices_a[2]); ERR_FAIL_COND_MSG(plane_a.normal == Vector3(), "Couldn't form plane from Brush A face."); for (int i = 0; i < 3; i++) { if (plane_a.has_point(vertices_b[i])) { - in_plane_count++; + // In plane. } else if (plane_a.is_point_over(vertices_b[i])) { over_count++; } else { @@ -1406,7 +1406,6 @@ void CSGBrushOperation::update_faces(const CSGBrush &p_brush_a, const int p_face } // Ensure A has points either side of or in the plane of B. - in_plane_count = 0; over_count = 0; under_count = 0; Plane plane_b(vertices_b[0], vertices_b[1], vertices_b[2]); @@ -1414,7 +1413,7 @@ void CSGBrushOperation::update_faces(const CSGBrush &p_brush_a, const int p_face for (int i = 0; i < 3; i++) { if (plane_b.has_point(vertices_a[i])) { - in_plane_count++; + // In plane. } else if (plane_b.is_point_over(vertices_a[i])) { over_count++; } else { diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index fe2ea5478de..8b152699b36 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -1316,7 +1316,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser:: Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::BlockNode *p_block, int p_stack_level, int p_break_addr, int p_continue_addr) { codegen.push_stack_identifiers(); - int new_identifiers = 0; codegen.current_line = p_block->line; for (int i = 0; i < p_block->statements.size(); i++) { @@ -1347,7 +1346,6 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo // copied because there is no _parse_statement :( codegen.add_stack_identifier(id->name, p_stack_level++); codegen.alloc_stack(p_stack_level); - new_identifiers++; GDScriptParser::OperatorNode *op = memnew(GDScriptParser::OperatorNode); op->op = GDScriptParser::OperatorNode::OP_ASSIGN; @@ -1605,8 +1603,6 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Blo codegen.add_stack_identifier(lv->name, p_stack_level++); codegen.alloc_stack(p_stack_level); - new_identifiers++; - } break; default: { //expression diff --git a/scene/3d/voxel_light_baker.cpp b/scene/3d/voxel_light_baker.cpp index 676ca5d9bb3..35510da99ca 100644 --- a/scene/3d/voxel_light_baker.cpp +++ b/scene/3d/voxel_light_baker.cpp @@ -854,8 +854,6 @@ void VoxelLightBaker::plot_light_directional(const Vector3 &p_direction, const C float distance_adv = _get_normal_advance(light_axis); - int success_count = 0; - Vector3 light_energy = Vector3(p_color.r, p_color.g, p_color.b) * p_energy * p_indirect_energy; int idx = first_leaf; @@ -916,7 +914,6 @@ void VoxelLightBaker::plot_light_directional(const Vector3 &p_direction, const C light->direct_accum[i][2] += light_energy.z * s; } } - success_count++; } idx = light_data[idx].next_leaf; diff --git a/scene/resources/polygon_path_finder.cpp b/scene/resources/polygon_path_finder.cpp index 435a19b5d53..f714a5f46e8 100644 --- a/scene/resources/polygon_path_finder.cpp +++ b/scene/resources/polygon_path_finder.cpp @@ -137,7 +137,7 @@ Vector PolygonPathFinder::find_path(const Vector2 &p_from, const Vector Edge ignore_to_edge(-1, -1); if (!_is_point_inside(from)) { - float closest_dist = 1e20; + float closest_dist = 1e20f; Vector2 closest_point; for (Set::Element *E = edges.front(); E; E = E->next()) { @@ -161,7 +161,7 @@ Vector PolygonPathFinder::find_path(const Vector2 &p_from, const Vector }; if (!_is_point_inside(to)) { - float closest_dist = 1e20; + float closest_dist = 1e20f; Vector2 closest_point; for (Set::Element *E = edges.front(); E; E = E->next()) { @@ -489,7 +489,7 @@ bool PolygonPathFinder::is_point_inside(const Vector2 &p_point) const { } Vector2 PolygonPathFinder::get_closest_point(const Vector2 &p_point) const { - float closest_dist = 1e20; + float closest_dist = 1e20f; Vector2 closest_point; for (Set::Element *E = edges.front(); E; E = E->next()) { @@ -508,7 +508,7 @@ Vector2 PolygonPathFinder::get_closest_point(const Vector2 &p_point) const { } } - ERR_FAIL_COND_V(closest_dist == 1e20, Vector2()); + ERR_FAIL_COND_V(Math::is_equal_approx(closest_dist, 1e20f), Vector2()); return closest_point; } diff --git a/servers/visual/portals/portal_rooms_bsp.cpp b/servers/visual/portals/portal_rooms_bsp.cpp index 3746980a75e..3966d9729e9 100644 --- a/servers/visual/portals/portal_rooms_bsp.cpp +++ b/servers/visual/portals/portal_rooms_bsp.cpp @@ -526,7 +526,6 @@ int PortalRoomsBSP::evaluate_room_split_plane(int p_room_a_id, int p_room_b_id, int PortalRoomsBSP::evaluate_plane(const VSPortal *p_portal, const Plane &p_plane, const LocalVector &p_room_ids, LocalVector *r_room_ids_back, LocalVector *r_room_ids_front) { int rooms_front = 0; int rooms_back = 0; - int rooms_split = 0; if (r_room_ids_back) { DEV_ASSERT(!r_room_ids_back->size()); @@ -622,8 +621,6 @@ int PortalRoomsBSP::evaluate_plane(const VSPortal *p_portal, const Plane &p_plan if (r_room_ids_back) { r_room_ids_back->push_back(rid); } - - rooms_split++; } #undef GODOT_BSP_PUSH_BACK diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index 810d5a709a5..969b2fa81ea 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -3750,10 +3750,6 @@ void VisualServerScene::_bake_gi_probe_light(const GIProbeDataHeader *header, co float distance_adv = _get_normal_advance(light_axis); - int success_count = 0; - - // uint64_t us = OS::get_singleton()->get_ticks_usec(); - for (int i = 0; i < p_leaf_count; i++) { uint32_t idx = leaves[i]; @@ -3802,18 +3798,11 @@ void VisualServerScene::_bake_gi_probe_light(const GIProbeDataHeader *header, co light->energy[0] += int32_t(light_r * att * ((cell->albedo >> 16) & 0xFF) / 255.0); light->energy[1] += int32_t(light_g * att * ((cell->albedo >> 8) & 0xFF) / 255.0); light->energy[2] += int32_t(light_b * att * ((cell->albedo) & 0xFF) / 255.0); - success_count++; } } - - // print_line("BAKE TIME: " + rtos((OS::get_singleton()->get_ticks_usec() - us) / 1000000.0)); - // print_line("valid cells: " + itos(success_count)); - } break; case VS::LIGHT_OMNI: case VS::LIGHT_SPOT: { - // uint64_t us = OS::get_singleton()->get_ticks_usec(); - Vector3 light_pos = light_cache.transform.origin; Vector3 spot_axis = -light_cache.transform.basis.get_axis(2).normalized(); @@ -3911,7 +3900,6 @@ void VisualServerScene::_bake_gi_probe_light(const GIProbeDataHeader *header, co light->energy[2] += int32_t(light_b * att * ((cell->albedo) & 0xFF) / 255.0); } } - //print_line("BAKE TIME: " + rtos((OS::get_singleton()->get_ticks_usec() - us) / 1000000.0)); } break; } } diff --git a/servers/visual/visual_server_viewport.cpp b/servers/visual/visual_server_viewport.cpp index 02cd4488976..2474fdbdfad 100644 --- a/servers/visual/visual_server_viewport.cpp +++ b/servers/visual/visual_server_viewport.cpp @@ -107,8 +107,6 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E } if (!p_viewport->hide_canvas) { - int i = 0; - Map canvas_map; Rect2 clip_rect(0, 0, p_viewport->size.x, p_viewport->size.y); @@ -117,8 +115,6 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E RasterizerCanvas::Light *lights_with_mask = nullptr; Rect2 shadow_rect; - int light_count = 0; - for (Map::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) { VisualServerCanvas::Canvas *canvas = static_cast(E->get().canvas); @@ -164,8 +160,6 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E cl->mask_next_ptr = lights_with_mask; lights_with_mask = cl; } - - light_count++; } VSG::canvas_render->light_internal_update(cl->light_internal, cl); @@ -235,7 +229,6 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E } VSG::canvas->render_canvas(canvas, xform, canvas_lights, lights_with_mask, clip_rect, canvas_layer_id); - i++; if (scenario_draw_canvas_bg && E->key().get_layer() >= scenario_canvas_max_layer) { if (!can_draw_3d) { diff --git a/thirdparty/bullet/BulletSoftBody/btSparseSDF.h b/thirdparty/bullet/BulletSoftBody/btSparseSDF.h index ae1288d9e6d..243b80f8ae5 100644 --- a/thirdparty/bullet/BulletSoftBody/btSparseSDF.h +++ b/thirdparty/bullet/BulletSoftBody/btSparseSDF.h @@ -233,9 +233,9 @@ struct btSparseSdf //int sz = sizeof(Cell); if (ncells > m_clampCells) { - static int numResets = 0; - numResets++; - // printf("numResets=%d\n",numResets); + //static int numResets = 0; + //numResets++; + //printf("numResets=%d\n",numResets); Reset(); } diff --git a/thirdparty/bullet/patches/fix-unused-but-set-warning.patch b/thirdparty/bullet/patches/fix-unused-but-set-warning.patch new file mode 100644 index 00000000000..b0b38676f33 --- /dev/null +++ b/thirdparty/bullet/patches/fix-unused-but-set-warning.patch @@ -0,0 +1,17 @@ +diff --git a/thirdparty/bullet/BulletSoftBody/btSparseSDF.h b/thirdparty/bullet/BulletSoftBody/btSparseSDF.h +index ae1288d9e6..243b80f8ae 100644 +--- a/thirdparty/bullet/BulletSoftBody/btSparseSDF.h ++++ b/thirdparty/bullet/BulletSoftBody/btSparseSDF.h +@@ -233,9 +233,9 @@ struct btSparseSdf + //int sz = sizeof(Cell); + if (ncells > m_clampCells) + { +- static int numResets = 0; +- numResets++; +- // printf("numResets=%d\n",numResets); ++ //static int numResets = 0; ++ //numResets++; ++ //printf("numResets=%d\n",numResets); + Reset(); + } +