Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dag_builder/TextureSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down
2 changes: 2 additions & 0 deletions src/dag_builder/atlas/rect/atlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "atlas/rect/atlas.h"
#include "atlas/rect/PackingPlanner.h"
#include "build_config.h"

namespace atlas {

Expand Down Expand Up @@ -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);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/dag_builder/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <tbb/concurrent_vector.h>

#include "build.h"
#include "build_config.h"
#include "centroids.h"
#include "cluster.h"
#include "clusterize.h"
Expand Down Expand Up @@ -479,6 +480,7 @@ std::unordered_set<octree::Id> 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));
}
Expand Down
2 changes: 2 additions & 0 deletions src/dag_builder/merge/clusters.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/dag_builder/vertex_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ inline std::vector<uint8_t> 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)) {
Expand Down
12 changes: 6 additions & 6 deletions src/sf_browser/core/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -256,7 +256,7 @@ void Application::run() {
}
}

void Application::update_camera(float frame_delta_time, Uniform<glm::mat4> U_view) {
void Application::update_camera(float frame_delta_time) {
if (!m_camera) {
LOG_WARN("Trying to update non-initialized camera!");
return;
Expand Down Expand Up @@ -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();
}
Expand All @@ -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)) {
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/sf_browser/core/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Application {
Application(std::string title, int width, int height);

void run();
void update_camera(float frame_delta_time, Uniform<glm::mat4> U_view);
void update_camera(float frame_delta_time);

~Application();

Expand Down Expand Up @@ -46,4 +46,4 @@ class Application {
GLenum severity, GLsizei length,
const GLchar *message,
const GLvoid *userParam);
};
};
4 changes: 2 additions & 2 deletions src/sf_browser/core/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 4 additions & 5 deletions src/sf_browser/core/rendering/OctreeRenderManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -49,7 +50,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)
{
Expand All @@ -60,7 +60,6 @@ namespace octree
if (current_distance > farthest_distance)
{
farthest_distance = current_distance;
is_current_farthest = true;
farthest = current;
}

Expand Down Expand Up @@ -169,4 +168,4 @@ namespace octree

return rendering_intent;
}
}
}
10 changes: 5 additions & 5 deletions src/sf_browser/core/rendering/OctreeRenderManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ namespace octree
{
std::vector<float> instances_active;
std::vector<glm::mat4> instances_model_mats;
size_t instance_count;
size_t instance_count = 0;

std::optional<double> min_scene_distance;
std::optional<double> max_scene_distance;
std::optional<double> min_scene_distance = std::nullopt;
std::optional<double> max_scene_distance = std::nullopt;

std::optional<Id> closest_node;
std::optional<Id> closest_node = std::nullopt;
};

enum OctreeFilterParamType
Expand Down Expand Up @@ -50,4 +50,4 @@ namespace octree
octree::Space m_space;
};

}
}
4 changes: 2 additions & 2 deletions src/sf_browser/core/shader/GLUniformAbstractions.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ namespace {
glUniform2uiv(location, count, data);
}
template <>
void glUniformv<unsigned int, 3>(const GLint location, const GLsizei count, const unsigned int* data) {
[[maybe_unused]] void glUniformv<unsigned int, 3>(const GLint location, const GLsizei count, const unsigned int* data) {
glUniform3uiv(location, count, data);
}
template <>
void glUniformv<unsigned int, 4>(const GLint location, const GLsizei count, const unsigned int* data) {
[[maybe_unused]] void glUniformv<unsigned int, 4>(const GLint location, const GLsizei count, const unsigned int* data) {
glUniform4uiv(location, count, data);
}

Expand Down
21 changes: 17 additions & 4 deletions src/sf_browser/core/shader/ShaderProgram.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "ShaderProgram.h"
#include <glad/gl.h>
#include <log.h>
#include <utility>

ShaderProgram::ShaderProgram() {
m_handle = glCreateProgram();
Expand Down Expand Up @@ -48,18 +49,30 @@ 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<GLsizei>(name.size())) {
LOG_ERROR_AND_EXIT("Uniform-name buffer is too large for GLsizei");
}

const GLsizei buffer_size = static_cast<GLsizei>(name.size());
glGetActiveUniform(m_handle, static_cast<GLuint>(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<size_t>(length);
if (name_length < name.size() - 1) {
break;
} else {
name.resize(name.length() * 2);
}
}

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
Expand Down
30 changes: 18 additions & 12 deletions src/sf_browser/core/window/Window.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "Window.h"
#include <log.h>
#include <limits>

std::atomic<bool> Window::glfw_initialized(false);
std::atomic<size_t> Window::window_instances(0);
Expand Down Expand Up @@ -170,7 +171,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)) {
Expand All @@ -194,7 +195,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)) {
Expand Down Expand Up @@ -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<size_t>::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");
Expand All @@ -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);
}
8 changes: 4 additions & 4 deletions src/sf_merger/mask.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>::infinity();
double min_radius_sq = +infinity;
double max_radius_sq = -infinity;
Expand All @@ -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<const SimpleMesh3d> meshes) {
[[maybe_unused]] glm::dvec2 calculate_radius_squared_range(const std::span<const SimpleMesh3d> meshes) {
const double infinity = std::numeric_limits<double>::infinity();
double min_radius_sq = +infinity;
double max_radius_sq = -infinity;
Expand All @@ -247,7 +247,7 @@ glm::dvec2 calculate_radius_squared_range(const std::span<const SimpleMesh3d> me

return glm::dvec2(min_radius_sq, max_radius_sq);
}
glm::dvec2 calculate_radius_range(const std::span<const SimpleMesh3d> meshes) {
[[maybe_unused]] glm::dvec2 calculate_radius_range(const std::span<const SimpleMesh3d> meshes) {
return glm::sqrt(calculate_radius_squared_range(meshes));
}

Expand Down
7 changes: 5 additions & 2 deletions src/terrainlib/HybridIndexPairMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <boost/range/join.hpp>
#include <libassert/assert.hpp>

#include "build_config.h"
#include "hash_utils.h"

template <typename Index, typename Value>
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -237,10 +239,11 @@ class HybridIndexPairMap {
const std::vector<Value> &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());
Expand Down
Loading
Loading