From 94094318a900b3dd2b64d5da0ec2f3de2d07d1a8 Mon Sep 17 00:00:00 2001 From: adam-ce <5292991+adam-ce@users.noreply.github.com> Date: Thu, 16 Jul 2026 17:17:27 +0200 Subject: [PATCH 1/2] Clean up unused variable warnings --- src/browser/core/Application.cpp | 8 ++++---- src/browser/core/Application.h | 4 ++-- .../core/rendering/OctreeRenderManager.cpp | 4 +--- src/browser/core/shader/GLUniformAbstractions.h | 4 ++-- src/browser/core/window/Window.cpp | 4 ++-- src/dag_builder/TextureSet.h | 2 +- src/dag_builder/atlas/rect/atlas.cpp | 2 ++ src/dag_builder/build.cpp | 2 ++ src/dag_builder/merge/clusters.h | 2 ++ src/dag_builder/vertex_lock.h | 2 ++ src/mesh_simplify/uv_map.cpp | 2 ++ src/sf_merger/mask.h | 8 ++++---- src/terrainlib/HybridIndexPairMap.h | 7 +++++-- src/terrainlib/build_config.h | 2 ++ src/terrainlib/mesh/clip.cpp | 2 ++ src/terrainlib/mesh/igl/cut_to_disk.inl | 5 +++++ src/terrainlib/mesh/merge.h | 2 +- src/terrainlib/mesh/merging/VertexMapping.h | 6 ++++++ src/terrainlib/mesh/merging/mapping.cpp | 2 ++ src/terrainlib/mesh/split.inl | 6 ++++++ src/terrainlib/mesh/texture_trim.h | 2 ++ src/terrainlib/mesh/topology.cpp | 2 ++ src/terrainlib/mesh/validate.cpp | 16 ++++++++++++++++ src/terrainlib/uv/unwrap.cpp | 2 ++ src/tile_builder/DatasetReader.h | 2 +- src/tile_builder/alpine_raster.cpp | 2 +- .../tilebuilder/depth_first_tile_traverser.cpp | 2 +- 27 files changed, 80 insertions(+), 24 deletions(-) diff --git a/src/browser/core/Application.cpp b/src/browser/core/Application.cpp index a2142191..1811170c 100644 --- a/src/browser/core/Application.cpp +++ b/src/browser/core/Application.cpp @@ -221,7 +221,7 @@ void Application::run() { draw_settings_window(); - update_camera(frame_delta_time, U_view); + update_camera(frame_delta_time); octree::OctreeRenderIntent rendering_intent = octree_render_manager.generate_octree_render_intent(octree::Id::root(), m_camera->get_position(), false, m_refining_factor); @@ -256,7 +256,7 @@ void Application::run() { } } -void Application::update_camera(float frame_delta_time, Uniform U_view) { +void Application::update_camera(float frame_delta_time) { if (!m_camera) { LOG_WARN("Trying to update non-initialized camera!"); return; @@ -580,9 +580,9 @@ void Application::draw_octree_settings_section() { void Application::gl_debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, - GLsizei length, + GLsizei, const GLchar *message, - const GLvoid *userParam) { + const GLvoid *) { std::stringstream stringStream; std::string sourceString; std::string typeString; diff --git a/src/browser/core/Application.h b/src/browser/core/Application.h index 9ec3b554..ca10a6c0 100644 --- a/src/browser/core/Application.h +++ b/src/browser/core/Application.h @@ -14,7 +14,7 @@ class Application { Application(std::string title, int width, int height); void run(); - void update_camera(float frame_delta_time, Uniform U_view); + void update_camera(float frame_delta_time); ~Application(); @@ -46,4 +46,4 @@ class Application { GLenum severity, GLsizei length, const GLchar *message, const GLvoid *userParam); -}; \ No newline at end of file +}; diff --git a/src/browser/core/rendering/OctreeRenderManager.cpp b/src/browser/core/rendering/OctreeRenderManager.cpp index 0e04ead5..4e18c7a3 100644 --- a/src/browser/core/rendering/OctreeRenderManager.cpp +++ b/src/browser/core/rendering/OctreeRenderManager.cpp @@ -49,7 +49,6 @@ namespace octree { // Don't split. Check whether to render this node bool is_current_closest = false; - bool is_current_farthest = false; if (current_distance < closest_distance) { @@ -60,7 +59,6 @@ namespace octree if (current_distance > farthest_distance) { farthest_distance = current_distance; - is_current_farthest = true; farthest = current; } @@ -169,4 +167,4 @@ namespace octree return rendering_intent; } -} \ No newline at end of file +} diff --git a/src/browser/core/shader/GLUniformAbstractions.h b/src/browser/core/shader/GLUniformAbstractions.h index 6697748e..10863652 100644 --- a/src/browser/core/shader/GLUniformAbstractions.h +++ b/src/browser/core/shader/GLUniformAbstractions.h @@ -53,11 +53,11 @@ namespace { glUniform2uiv(location, count, data); } template <> - void glUniformv(const GLint location, const GLsizei count, const unsigned int* data) { + [[maybe_unused]] void glUniformv(const GLint location, const GLsizei count, const unsigned int* data) { glUniform3uiv(location, count, data); } template <> - void glUniformv(const GLint location, const GLsizei count, const unsigned int* data) { + [[maybe_unused]] void glUniformv(const GLint location, const GLsizei count, const unsigned int* data) { glUniform4uiv(location, count, data); } diff --git a/src/browser/core/window/Window.cpp b/src/browser/core/window/Window.cpp index ef4a6967..72f29567 100644 --- a/src/browser/core/window/Window.cpp +++ b/src/browser/core/window/Window.cpp @@ -170,7 +170,7 @@ void Window::glfw_error_callback(int error, const char* description) { LOG_ERROR("[{}] {}", error, description); } -void Window::key_callback(GLFWwindow* window, int key, int scancode, int action, int mode) { +void Window::key_callback(GLFWwindow* window, int key, int /*scancode*/, int action, int /*mode*/) { Window* w = (Window*)glfwGetWindowUserPointer(window); if (!w->m_key_states.contains(key)) { @@ -194,7 +194,7 @@ void Window::key_callback(GLFWwindow* window, int key, int scancode, int action, } } -void Window::mouse_button_callback(GLFWwindow* window, int button, int action, int mods) { +void Window::mouse_button_callback(GLFWwindow* window, int button, int action, int /*mods*/) { Window* w = (Window*)glfwGetWindowUserPointer(window); if (!w->m_mouse_button_states.contains(button)) { diff --git a/src/dag_builder/TextureSet.h b/src/dag_builder/TextureSet.h index 990d2f38..5f4361d4 100644 --- a/src/dag_builder/TextureSet.h +++ b/src/dag_builder/TextureSet.h @@ -46,7 +46,7 @@ class TextureSet { const auto it = std::find_if( this->_textures.begin(), this->_textures.end(), - [this, key](const Texture &t) { + [key](const Texture &t) { return key == ImageKey(t); }); diff --git a/src/dag_builder/atlas/rect/atlas.cpp b/src/dag_builder/atlas/rect/atlas.cpp index 6e72b7ab..7cbf2788 100644 --- a/src/dag_builder/atlas/rect/atlas.cpp +++ b/src/dag_builder/atlas/rect/atlas.cpp @@ -10,6 +10,7 @@ #include "atlas/rect/atlas.h" #include "atlas/rect/PackingPlanner.h" +#include "build_config.h" namespace atlas { @@ -75,6 +76,7 @@ namespace { void check_uv(const glm::uvec2 &uv) { DEBUG_ASSERT(uv.x >= 0.0 && uv.x <= 1.0); DEBUG_ASSERT(uv.y >= 0.0 && uv.y <= 1.0); + ALP_UNUSED(uv); } } diff --git a/src/dag_builder/build.cpp b/src/dag_builder/build.cpp index 6f280a29..bcb833b6 100644 --- a/src/dag_builder/build.cpp +++ b/src/dag_builder/build.cpp @@ -9,6 +9,7 @@ #include #include "build.h" +#include "build_config.h" #include "centroids.h" #include "cluster.h" #include "clusterize.h" @@ -479,6 +480,7 @@ std::unordered_set build_level( if (result) { const auto save_result = ctx.output_storage.save(target, *result); DEBUG_ASSERT(save_result.has_value()); + ALP_UNUSED(save_result); if (debug_storage) { debug_storage->save(target, clustering_to_mesh(result->clustering)); } diff --git a/src/dag_builder/merge/clusters.h b/src/dag_builder/merge/clusters.h index 2d5a9ecf..07e8ce5b 100644 --- a/src/dag_builder/merge/clusters.h +++ b/src/dag_builder/merge/clusters.h @@ -125,6 +125,7 @@ inline Cluster merge_clusters_simple( DEBUG_ASSERT(vertex_remap.size() == clustering.vertex_count()); for (const uint32_t vertex_index : vertex_remap) { DEBUG_ASSERT(vertex_index == no_vertex_remap); + ALP_UNUSED(vertex_index); } DEBUG_ASSERT(check_consistent_uvs(clustering, cluster_indices)); } @@ -188,6 +189,7 @@ inline mesh::merging::VertexMapping construct_merge_mapping( DEBUG_ASSERT(vertex_remap.size() == clustering.vertex_count()); for (const uint32_t vertex_index : vertex_remap) { DEBUG_ASSERT(vertex_index == no_vertex_remap); + ALP_UNUSED(vertex_index); } } diff --git a/src/dag_builder/vertex_lock.h b/src/dag_builder/vertex_lock.h index d8b65587..6c52cf4e 100644 --- a/src/dag_builder/vertex_lock.h +++ b/src/dag_builder/vertex_lock.h @@ -89,12 +89,14 @@ inline std::vector find_vertices_to_lock(const Clustering &clustering) // Get global vertex const Cluster &first_cluster = clustering.clusters[membership[0].cluster_index]; const uint32_t global_vertex_index = first_cluster.vertex_indices[membership[0].local_vertex_index]; +#ifndef NDEBUG for (uint32_t i = 1; i < num_clusters; i++) { const auto [cluster_index, local_vertex_index] = membership[i]; const Cluster &cluster = clustering.clusters[cluster_index]; const uint32_t other_global_vertex_index = cluster.vertex_indices[local_vertex_index]; DEBUG_ASSERT(global_vertex_index == other_global_vertex_index); } +#endif // Check if on the boundary if (!boundary_vertices.contains(global_vertex_index)) { diff --git a/src/mesh_simplify/uv_map.cpp b/src/mesh_simplify/uv_map.cpp index aedad705..1b1a22fb 100644 --- a/src/mesh_simplify/uv_map.cpp +++ b/src/mesh_simplify/uv_map.cpp @@ -165,9 +165,11 @@ Texture uv_map::merge_textures( const mesh::merging::VertexMapping &mapping, const UvMap &uv_map, const glm::uvec2 merged_texture_size) { +#ifndef NDEBUG for (const SimpleMesh& mesh : original_meshes) { DEBUG_ASSERT(mesh.has_texture()); } +#endif cv::Mat merged_atlas = cv::Mat::zeros(merged_texture_size.y, merged_texture_size.x, CV_32FC3); diff --git a/src/sf_merger/mask.h b/src/sf_merger/mask.h index 74589ee0..6ca6ccd3 100644 --- a/src/sf_merger/mask.h +++ b/src/sf_merger/mask.h @@ -217,7 +217,7 @@ auto length2(const Vec &v) -> decltype(glm::dot(v, v)) { return glm::dot(v, v); } -glm::dvec2 calculate_radius_squared_range(const SimpleMesh3d &mesh) { +[[maybe_unused]] glm::dvec2 calculate_radius_squared_range(const SimpleMesh3d &mesh) { const double infinity = std::numeric_limits::infinity(); double min_radius_sq = +infinity; double max_radius_sq = -infinity; @@ -230,11 +230,11 @@ glm::dvec2 calculate_radius_squared_range(const SimpleMesh3d &mesh) { return glm::dvec2(min_radius_sq, max_radius_sq); } -glm::dvec2 calculate_radius_range(const SimpleMesh3d &mesh) { +[[maybe_unused]] glm::dvec2 calculate_radius_range(const SimpleMesh3d &mesh) { return glm::sqrt(calculate_radius_squared_range(mesh)); } -glm::dvec2 calculate_radius_squared_range(const std::span meshes) { +[[maybe_unused]] glm::dvec2 calculate_radius_squared_range(const std::span meshes) { const double infinity = std::numeric_limits::infinity(); double min_radius_sq = +infinity; double max_radius_sq = -infinity; @@ -247,7 +247,7 @@ glm::dvec2 calculate_radius_squared_range(const std::span me return glm::dvec2(min_radius_sq, max_radius_sq); } -glm::dvec2 calculate_radius_range(const std::span meshes) { +[[maybe_unused]] glm::dvec2 calculate_radius_range(const std::span meshes) { return glm::sqrt(calculate_radius_squared_range(meshes)); } diff --git a/src/terrainlib/HybridIndexPairMap.h b/src/terrainlib/HybridIndexPairMap.h index 832dddbf..0c2db6f9 100644 --- a/src/terrainlib/HybridIndexPairMap.h +++ b/src/terrainlib/HybridIndexPairMap.h @@ -15,6 +15,7 @@ #include #include +#include "build_config.h" #include "hash_utils.h" template @@ -171,6 +172,7 @@ class HybridIndexPairMap { static void check_safe_index(const Index primary_key) { DEBUG_ASSERT(primary_key <= LAST_SAFE_INDEX); + ALP_UNUSED(primary_key); } struct Slot { @@ -237,10 +239,11 @@ class HybridIndexPairMap { const std::vector &direct_values) { DEBUG_ASSERT(this->is_direct()); - const auto [_, inserted] = overflow.emplace( + const bool inserted = overflow.emplace( Key{primary_key, this->secondary_key}, - this->direct_value(direct_values)); + this->direct_value(direct_values)).second; DEBUG_ASSERT(inserted); + ALP_UNUSED(inserted); this->value = OVERFLOW_SLOT; DEBUG_ASSERT(this->is_overflow()); diff --git a/src/terrainlib/build_config.h b/src/terrainlib/build_config.h index adecd803..43d8f282 100644 --- a/src/terrainlib/build_config.h +++ b/src/terrainlib/build_config.h @@ -1,5 +1,7 @@ #pragma once +#define ALP_UNUSED(value) static_cast(value) + #ifdef NDEBUG constexpr bool IS_DEBUG_BUILD = false; #else diff --git a/src/terrainlib/mesh/clip.cpp b/src/terrainlib/mesh/clip.cpp index 9ad57e47..decb4661 100644 --- a/src/terrainlib/mesh/clip.cpp +++ b/src/terrainlib/mesh/clip.cpp @@ -16,6 +16,7 @@ #include #include +#include "build_config.h" #include "hash_utils.h" #include "log.h" #include "mesh/cgal.h" @@ -738,6 +739,7 @@ struct UvInterpolatorVisitor : public CGAL::Polygon_mesh_processing::Corefinemen HalfedgeDescriptor h_e, HalfedgeDescriptor h_f, const TriangleMesh& tm_e, const TriangleMesh& tm_f, bool /*is_target_coplanar*/, bool /*is_source_coplanar*/) { DEBUG_ASSERT(i_id == intersections.size()); + ALP_UNUSED(i_id); if (&mesh == &tm_e) { // The edge belongs to the mesh being clipped const auto source_vertex = mesh.source(h_e); diff --git a/src/terrainlib/mesh/igl/cut_to_disk.inl b/src/terrainlib/mesh/igl/cut_to_disk.inl index ae6a6c89..894ded92 100644 --- a/src/terrainlib/mesh/igl/cut_to_disk.inl +++ b/src/terrainlib/mesh/igl/cut_to_disk.inl @@ -5,6 +5,7 @@ #include +#include "build_config.h" #include "mesh/SimpleMesh.h" #include "mesh/View.h" #include "mesh/igl/cut.h" @@ -46,11 +47,15 @@ inline std::vector identity_map(const std::span tria return identity_map(max_vertex_index + 1); } inline void assert_disks(const std::span triangles) { +#ifndef NDEBUG const Topology topology = compute_topology(triangles); for (const auto &component : topology.components()) { DEBUG_ASSERT(component.is_disk(true)); } DEBUG_ASSERT(topology.is_disks(true)); +#else + ALP_UNUSED(triangles); +#endif } } diff --git a/src/terrainlib/mesh/merge.h b/src/terrainlib/mesh/merge.h index 5db78f6d..5d984185 100644 --- a/src/terrainlib/mesh/merge.h +++ b/src/terrainlib/mesh/merge.h @@ -53,7 +53,7 @@ concept SimpleMeshRefConcept = std::is_same_v>; template -SimpleMesh merge(Mesh&& mesh1, Args &&...args) { +SimpleMesh merge(Mesh&& mesh1, Args &&... /*args*/) { return mesh1; } template diff --git a/src/terrainlib/mesh/merging/VertexMapping.h b/src/terrainlib/mesh/merging/VertexMapping.h index 62a8daca..89bc9385 100644 --- a/src/terrainlib/mesh/merging/VertexMapping.h +++ b/src/terrainlib/mesh/merging/VertexMapping.h @@ -171,6 +171,7 @@ class VertexMapping { const std::optional inv_mapped = this->map_backward(i, mapped); DEBUG_ASSERT(inv_mapped.has_value()); DEBUG_ASSERT(inv_mapped.value() == j); + ALP_UNUSED(inv_mapped); } } @@ -179,6 +180,9 @@ class VertexMapping { DEBUG_ASSERT(source_mesh_index < this->mesh_count()); DEBUG_ASSERT(source_vertex_index < this->mesh_vertex_count(source_mesh_index)); DEBUG_ASSERT(this->map_forward(VertexId{.mesh_index = source_mesh_index, .vertex_index = source_vertex_index}) == merged_vertex_index); + ALP_UNUSED(merged_vertex_index); + ALP_UNUSED(source_mesh_index); + ALP_UNUSED(source_vertex_index); } // Check forward(x) != forward(y) @@ -189,7 +193,9 @@ class VertexMapping { for (uint32_t k = j + 1; k < vertex_count; k++) { const uint32_t mapped_k = this->map_forward(VertexId{.mesh_index = i, .vertex_index = k}); DEBUG_ASSERT(mapped_j != mapped_k); + ALP_UNUSED(mapped_k); } + ALP_UNUSED(mapped_j); } } diff --git a/src/terrainlib/mesh/merging/mapping.cpp b/src/terrainlib/mesh/merging/mapping.cpp index f66b3a27..d5934b4f 100644 --- a/src/terrainlib/mesh/merging/mapping.cpp +++ b/src/terrainlib/mesh/merging/mapping.cpp @@ -57,9 +57,11 @@ void validate_epsilon_mapping( const glm::dvec3 &pj = meshes[originals[j].mesh_index].get().positions[originals[j].vertex_index]; const double dist2 = glm::distance2(pi, pj); DEBUG_ASSERT(dist2 <= epsilon2); + ALP_UNUSED(dist2); } } } + ALP_UNUSED(epsilon2); } } diff --git a/src/terrainlib/mesh/split.inl b/src/terrainlib/mesh/split.inl index da0da3b6..5715a9f4 100644 --- a/src/terrainlib/mesh/split.inl +++ b/src/terrainlib/mesh/split.inl @@ -8,6 +8,7 @@ #include #include +#include "build_config.h" #include "SegmentedBuffer.h" #include "enumerate.h" #include "mesh/SimpleMesh.h" @@ -113,8 +114,12 @@ std::vector calculate_vertex_counts(const uint32_t vertex_count, const template std::vector calculate_triangle_counts(const std::span triangles, const uint32_t group_count, Mapping &&vertex_to_group, const bool allow_mixed_triangles) { std::vector triangle_counts(group_count, 0); +#ifdef NDEBUG + ALP_UNUSED(allow_mixed_triangles); +#endif for (const glm::uvec3 &triangle : triangles) { const uint32_t g0 = vertex_to_group(triangle[0]); +#ifndef NDEBUG const uint32_t g1 = vertex_to_group(triangle[1]); const uint32_t g2 = vertex_to_group(triangle[2]); @@ -126,6 +131,7 @@ std::vector calculate_triangle_counts(const std::span #include +#include "build_config.h" #include "mesh/SimpleMesh.h" #include "mesh/View.h" #include "range_utils.h" @@ -51,6 +52,7 @@ namespace detail { inline void check_uv(const glm::dvec2 &uv) { DEBUG_ASSERT(uv.x >= 0.0 && uv.x <= 1.0); DEBUG_ASSERT(uv.y >= 0.0 && uv.y <= 1.0); + ALP_UNUSED(uv); } } diff --git a/src/terrainlib/mesh/topology.cpp b/src/terrainlib/mesh/topology.cpp index 574bfc2b..47068cec 100644 --- a/src/terrainlib/mesh/topology.cpp +++ b/src/terrainlib/mesh/topology.cpp @@ -46,6 +46,8 @@ create_edge_to_triangle_mapping_impl(const std::span triangles (triangle[0] == edge.y || triangle[1] == edge.y || triangle[2] == edge.y); DEBUG_ASSERT(first_vertex_found_in_triangle && second_vertex_found_in_triangle, "Both vertices of the edge exist in the triangle"); + ALP_UNUSED(first_vertex_found_in_triangle); + ALP_UNUSED(second_vertex_found_in_triangle); } } } diff --git a/src/terrainlib/mesh/validate.cpp b/src/terrainlib/mesh/validate.cpp index 18591634..b4e8fa1d 100644 --- a/src/terrainlib/mesh/validate.cpp +++ b/src/terrainlib/mesh/validate.cpp @@ -8,6 +8,7 @@ #include #include +#include "build_config.h" #include "log.h" #include "mesh/cleanup.h" #include "mesh/connected_components.h" @@ -46,12 +47,15 @@ inline bool has_duplicate_faces(const std::span triangles, con template void validate_impl_basic(const mesh::View_ &mesh) { +#ifndef NDEBUG using Mesh = mesh::View_; using Triangle = typename Mesh::Triangle; using Uv = typename Mesh::Uv; +#endif static_assert(n_dims == 2 || n_dims == 3, "Mesh must be 2D or 3D"); +#ifndef NDEBUG if (mesh.has_uvs()) { DEBUG_ASSERT(mesh.positions.size() == mesh.uvs.size()); } @@ -74,10 +78,14 @@ void validate_impl_basic(const mesh::View_ &mesh) { for (const Triangle &triangle : mesh.triangles) { DEBUG_ASSERT(!is_degenerate(triangle)); } +#else + ALP_UNUSED(mesh); +#endif } template void validate_impl_topology(const mesh::View_ &mesh, const ValidationFlags flags) { +#ifndef NDEBUG if (has_flag(flags, ValidationFlags::SingleComponent)) { DEBUG_ASSERT(is_single_component(mesh)); } @@ -85,12 +93,17 @@ void validate_impl_topology(const mesh::View_ &mesh, const Validation if (has_flag(flags, ValidationFlags::Manifold)) { DEBUG_ASSERT(is_manifold(mesh)); } +#else + ALP_UNUSED(mesh); + ALP_UNUSED(flags); +#endif } template void validate_impl_geometry(const mesh::View_ &mesh) { static_assert(n_dims >= 2, "Geometry checks require n_dims >= 2"); +#ifndef NDEBUG DEBUG_ASSERT(find_isolated_vertices(mesh).empty()); /* @@ -105,6 +118,9 @@ void validate_impl_geometry(const mesh::View_ &mesh) { } } */ +#else + ALP_UNUSED(mesh); +#endif } } diff --git a/src/terrainlib/uv/unwrap.cpp b/src/terrainlib/uv/unwrap.cpp index f528d13d..5e61092b 100644 --- a/src/terrainlib/uv/unwrap.cpp +++ b/src/terrainlib/uv/unwrap.cpp @@ -18,6 +18,7 @@ #include "mesh/cgal.h" #include "mesh/convert.h" #include "mesh/validate.h" +#include "build_config.h" #include "unwrap.h" #include "fit.h" #include "mesh/compute_topology.h" @@ -78,6 +79,7 @@ inline cgal::Point2 min(const cgal::Point2 &a, const cgal::Point2 &b) { inline void check_uv(const glm::dvec2 &uv) { DEBUG_ASSERT(uv.x >= 0.0 && uv.x <= 1.0); DEBUG_ASSERT(uv.y >= 0.0 && uv.y <= 1.0); + ALP_UNUSED(uv); } template diff --git a/src/tile_builder/DatasetReader.h b/src/tile_builder/DatasetReader.h index 6684db8d..e75b1ff8 100644 --- a/src/tile_builder/DatasetReader.h +++ b/src/tile_builder/DatasetReader.h @@ -49,7 +49,7 @@ class DatasetReader { std::string m_dataset_srs_wkt; std::string m_target_srs_wkt; bool m_requires_reprojection; - bool m_warn_on_missing_overviews; + [[maybe_unused]] bool m_warn_on_missing_overviews; unsigned m_band; }; diff --git a/src/tile_builder/alpine_raster.cpp b/src/tile_builder/alpine_raster.cpp index dfa075d2..b9ce5353 100644 --- a/src/tile_builder/alpine_raster.cpp +++ b/src/tile_builder/alpine_raster.cpp @@ -35,7 +35,7 @@ ParallelTileGenerator alpine_raster::make_generator(const std::string& input_dat return ParallelTileGenerator::make(input_data_path, srs, tiling_scheme, std::make_unique(border), output_data_path, grid_resolution); } -void alpine_raster::TileWriter::write(const std::string& file_path, const radix::tile::Descriptor& tile, const HeightData& heights) const +void alpine_raster::TileWriter::write(const std::string& file_path, const radix::tile::Descriptor&, const HeightData& heights) const { image::saveImageAsPng(image::transformImage(heights, radix::height_encoding::to_rgb), file_path); diff --git a/unittests/tilebuilder/depth_first_tile_traverser.cpp b/unittests/tilebuilder/depth_first_tile_traverser.cpp index 3f49e05a..ef753a3a 100644 --- a/unittests/tilebuilder/depth_first_tile_traverser.cpp +++ b/unittests/tilebuilder/depth_first_tile_traverser.cpp @@ -41,7 +41,7 @@ TEST_CASE("depth_first_tile_traverser interface") const radix::tile::Id root_id = { 0, { 0, 0 }, tiler.scheme() }; const unsigned max_zoom_level = 3; - ReadType result = traverse_depth_first_and_aggregate(tiler, read_function, aggregate_function, root_id, max_zoom_level); + traverse_depth_first_and_aggregate(tiler, read_function, aggregate_function, root_id, max_zoom_level); } TEST_CASE("depth_first_tile_traverser basics") From 9fff04ba7dc2d59f81d599e8ba9e1a3f9dad64f3 Mon Sep 17 00:00:00 2001 From: adam-ce <5292991+adam-ce@users.noreply.github.com> Date: Thu, 16 Jul 2026 17:56:50 +0200 Subject: [PATCH 2/2] Fix first-party compiler warnings --- src/browser/core/Application.cpp | 4 +-- src/browser/core/Camera.cpp | 4 +-- .../core/rendering/OctreeRenderManager.cpp | 5 ++-- .../core/rendering/OctreeRenderManager.h | 10 +++---- src/browser/core/shader/ShaderProgram.cpp | 21 ++++++++++--- src/browser/core/window/Window.cpp | 26 +++++++++------- src/mesh_simplify/simplify.cpp | 7 ++--- src/terrainlib/mesh/clip.cpp | 30 +++++++------------ 8 files changed, 58 insertions(+), 49 deletions(-) diff --git a/src/browser/core/Application.cpp b/src/browser/core/Application.cpp index 1811170c..9da1afce 100644 --- a/src/browser/core/Application.cpp +++ b/src/browser/core/Application.cpp @@ -536,7 +536,7 @@ void Application::draw_octree_settings_section() { ImGui::SetNextItemOpen(true, ImGuiCond_FirstUseEver); if (ImGui::TreeNode("Stats")) { - ImGui::Text("Nodes Rendered: %d", m_last_draw_amount); + ImGui::Text("Nodes Rendered: %zu", m_last_draw_amount); ImGui::TreePop(); } @@ -553,7 +553,7 @@ void Application::draw_octree_settings_section() { size_t selected_idx = 0; if (ImGui::BeginCombo("Metric", metrics[selected_idx].c_str())) { - for (int i = 0; i < metrics.size(); i++) { + for (size_t i = 0; i < metrics.size(); i++) { bool selected = selected_idx == i; if (ImGui::Selectable(metrics[i].c_str(), selected)) { diff --git a/src/browser/core/Camera.cpp b/src/browser/core/Camera.cpp index 7483f753..d78b0367 100644 --- a/src/browser/core/Camera.cpp +++ b/src/browser/core/Camera.cpp @@ -6,8 +6,8 @@ Camera::Camera(CameraConfig config) : m_aspect_ratio(config.aspect_ratio), m_near_plane(config.near_plane), m_far_plane(config.far_plane), - m_position(config.position), - m_up(glm::normalize(config.up)){ + m_up(glm::normalize(config.up)), + m_position(config.position){ glm::dvec3 forward = glm::normalize(config.target - m_position); m_rotation = glm::quatLookAt(forward, m_up); diff --git a/src/browser/core/rendering/OctreeRenderManager.cpp b/src/browser/core/rendering/OctreeRenderManager.cpp index 4e18c7a3..5d7aea83 100644 --- a/src/browser/core/rendering/OctreeRenderManager.cpp +++ b/src/browser/core/rendering/OctreeRenderManager.cpp @@ -37,10 +37,11 @@ namespace octree // LOG_DEBUG("DIST: {}, RATIO: {}", distance, current_ratio); - if (current_ratio <= refining_ratio && current.has_children()) + const auto children = current.children(); + if (current_ratio <= refining_ratio && children.has_value()) { // Split node into 8 children, and add them to the refining list - for (Id child : current.children().value()) + for (Id child : children.value()) { refining_ids.push_back(child); } diff --git a/src/browser/core/rendering/OctreeRenderManager.h b/src/browser/core/rendering/OctreeRenderManager.h index 06829244..67400d28 100644 --- a/src/browser/core/rendering/OctreeRenderManager.h +++ b/src/browser/core/rendering/OctreeRenderManager.h @@ -11,12 +11,12 @@ namespace octree { std::vector instances_active; std::vector instances_model_mats; - size_t instance_count; + size_t instance_count = 0; - std::optional min_scene_distance; - std::optional max_scene_distance; + std::optional min_scene_distance = std::nullopt; + std::optional max_scene_distance = std::nullopt; - std::optional closest_node; + std::optional closest_node = std::nullopt; }; enum OctreeFilterParamType @@ -50,4 +50,4 @@ namespace octree octree::Space m_space; }; -} \ No newline at end of file +} diff --git a/src/browser/core/shader/ShaderProgram.cpp b/src/browser/core/shader/ShaderProgram.cpp index a815d368..10148212 100644 --- a/src/browser/core/shader/ShaderProgram.cpp +++ b/src/browser/core/shader/ShaderProgram.cpp @@ -1,6 +1,7 @@ #include "ShaderProgram.h" #include #include +#include ShaderProgram::ShaderProgram() { m_handle = glCreateProgram(); @@ -48,9 +49,21 @@ void ShaderProgram::link() { std::string name; name.resize(16); // name buffer for (GLint i = 0; i < uniformCount; i++) { + size_t name_length = 0; while (true) { - glGetActiveUniform(m_handle, (GLuint)i, (GLsizei)name.length(), &length, &size, &type, name.data()); - if (name.length() - 1 > length) { + if (!std::in_range(name.size())) { + LOG_ERROR_AND_EXIT("Uniform-name buffer is too large for GLsizei"); + } + + const GLsizei buffer_size = static_cast(name.size()); + glGetActiveUniform(m_handle, static_cast(i), buffer_size, &length, &size, &type, name.data()); + + if (length < 0 || length >= buffer_size) { + LOG_ERROR_AND_EXIT("glGetActiveUniform returned invalid length {} for buffer size {}", length, buffer_size); + } + + name_length = static_cast(length); + if (name_length < name.size() - 1) { break; } else { name.resize(name.length() * 2); @@ -58,8 +71,8 @@ void ShaderProgram::link() { } const auto location = glGetUniformLocation(m_handle, name.c_str()); - m_uniform_locations.insert(std::make_pair(name.substr(0, length), location)); - LOG_DEBUG("Uniform #{} Name: {}", i, name.substr(0, length)); + m_uniform_locations.insert(std::make_pair(name.substr(0, name_length), location)); + LOG_DEBUG("Uniform #{} Name: {}", i, name.substr(0, name_length)); } // load all attribute locations diff --git a/src/browser/core/window/Window.cpp b/src/browser/core/window/Window.cpp index 72f29567..f3d04f2b 100644 --- a/src/browser/core/window/Window.cpp +++ b/src/browser/core/window/Window.cpp @@ -1,5 +1,6 @@ #include "Window.h" #include +#include std::atomic Window::glfw_initialized(false); std::atomic Window::window_instances(0); @@ -235,24 +236,30 @@ void Window::framebuffer_size_callback(GLFWwindow* window, int width, int height } void Window::update_window_count(int delta) { - if (delta == 0) { - return; - } - auto w_instances = Window::window_instances.load(std::memory_order_acquire); auto g_initialized = Window::glfw_initialized.load(std::memory_order_acquire); - if (w_instances + delta < 0) { - LOG_ERROR_AND_EXIT("Illegal window count change from {} >> {} by {}!", w_instances, w_instances + delta, delta); + if (delta != 1 && delta != -1) { + LOG_ERROR_AND_EXIT("Illegal window-count delta: {}", delta); + } + + if (delta == -1 && w_instances == 0) { + LOG_ERROR_AND_EXIT("Cannot decrement window count below zero"); } - LOG_INFO("Window count changed from {} >> {} by {}!", w_instances, w_instances + delta, delta); + if (delta == 1 && w_instances == std::numeric_limits::max()) { + LOG_ERROR_AND_EXIT("Cannot increment window count beyond size_t maximum"); + } + + const size_t new_count = delta == 1 ? w_instances + 1 : w_instances - 1; + + LOG_INFO("Window count changed from {} >> {} by {}!", w_instances, new_count, delta); // If the previous window count was 0 AND glfw is not initialized, initialize GLFW bool needs_glfw_init = w_instances == 0 && !Window::glfw_initialized; // If the current window count is 0, AND glfw is initialized, destruct GLFW - bool needs_glfw_destruction = w_instances + delta == 0 && Window::glfw_initialized; + bool needs_glfw_destruction = new_count == 0 && Window::glfw_initialized; if (needs_glfw_init) { LOG_INFO("Initializing GLFW"); @@ -272,6 +279,5 @@ void Window::update_window_count(int delta) { Window::glfw_initialized.store(g_initialized, std::memory_order_release); } - w_instances += delta; - Window::window_instances.store(w_instances, std::memory_order_release); + Window::window_instances.store(new_count, std::memory_order_release); } diff --git a/src/mesh_simplify/simplify.cpp b/src/mesh_simplify/simplify.cpp index db3acedb..ed9748a8 100644 --- a/src/mesh_simplify/simplify.cpp +++ b/src/mesh_simplify/simplify.cpp @@ -8,8 +8,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -447,7 +446,7 @@ inline size_t _simplify_mesh( switch (algorithm) { case Algorithm::GarlandHeckbert: - typedef CGAL::Surface_mesh_simplification::GarlandHeckbert_policies GH_policies; + typedef CGAL::Surface_mesh_simplification::GarlandHeckbert_plane_policies GH_policies; return _simplify_mesh_with_policies(mesh, uv_map, GH_policies(mesh), args); case Algorithm::LindstromTurk: typedef CGAL::Surface_mesh_simplification::LindstromTurk_cost LT_cost; @@ -518,4 +517,4 @@ void simplify_mesh_texture(mesh::Simple &mesh, glm::uvec2 target_resolution) { } } -} \ No newline at end of file +} diff --git a/src/terrainlib/mesh/clip.cpp b/src/terrainlib/mesh/clip.cpp index decb4661..e81bb516 100644 --- a/src/terrainlib/mesh/clip.cpp +++ b/src/terrainlib/mesh/clip.cpp @@ -451,16 +451,11 @@ Cow clip_on_bounds(const SimpleMesh &mesh, const radix::geomet } else if (inside_count == 1) { // A single vertex is inside the plane, cut the other two off. - // First identify the vertices - uint32_t inside_tri_index, outside1_tri_index, outside2_tri_index; - for (uint8_t k = 0; k < 3; k++) { - if (vertex_inside[k]) { - inside_tri_index = k; - outside1_tri_index = (k + 1) % 3; - outside2_tri_index = (k + 2) % 3; - break; - } - } + // inside_count guarantees exactly one entry is true. + const uint32_t inside_tri_index = + vertex_inside[0] ? 0u : vertex_inside[1] ? 1u : 2u; + const uint32_t outside1_tri_index = (inside_tri_index + 1) % 3; + const uint32_t outside2_tri_index = (inside_tri_index + 2) % 3; // Skip the triangle if it only touches the plane if (distance_to_plane[inside_tri_index] == 0) { @@ -506,16 +501,11 @@ Cow clip_on_bounds(const SimpleMesh &mesh, const radix::geomet } else if (inside_count == 2) { // Two vertices is inside the plane, cut the last one off and split the triangle. - // First identify the vertices - uint32_t outside_tri_index, inside1_tri_index, inside2_tri_index; - for (uint8_t k = 0; k < 3; k++) { - if (!vertex_inside[k]) { - outside_tri_index = k; - inside1_tri_index = (k + 1) % 3; - inside2_tri_index = (k + 2) % 3; - break; - } - } + // inside_count guarantees exactly one entry is false. + const uint32_t outside_tri_index = + !vertex_inside[0] ? 0u : !vertex_inside[1] ? 1u : 2u; + const uint32_t inside1_tri_index = (outside_tri_index + 1) % 3; + const uint32_t inside2_tri_index = (outside_tri_index + 2) % 3; // Then compute the intersections const glm::dvec3 outside_vertex = vertices[outside_tri_index];