From 95852727f919756356c2fdd07d0dc2ca0c2466a0 Mon Sep 17 00:00:00 2001 From: Joseph Walton-Rivers <joseph@walton-rivers.uk> Date: Tue, 3 May 2022 10:11:22 +0100 Subject: [PATCH] fix variable orderings --- CMakeLists.txt | 6 +++++- fggl/data/model.cpp | 2 +- fggl/data/procedural.cpp | 3 ++- fggl/ecs3/fast/Container.cpp | 2 +- fggl/gfx/input.cpp | 2 +- fggl/math/triangulation.cpp | 2 +- include/fggl/ecs3/fast/Container.h | 10 +++++----- include/fggl/ecs3/prototype/world.h | 2 +- include/fggl/ecs3/types.hpp | 4 ++-- include/fggl/math/types.hpp | 2 +- 10 files changed, 20 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 851e313..a3c43af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,11 +86,15 @@ endif() # end windows support ## - # engine #add_subdirectory(vendor/imgui/) add_subdirectory(fggl) +## G++ enable insane checks +target_compile_options( ${PROJECT_NAME} PRIVATE -Wall -fno-strict-aliasing -fno-strict-overflow ) + + + # extras #add_subdirectory(tests) add_subdirectory(demo) diff --git a/fggl/data/model.cpp b/fggl/data/model.cpp index b57aa33..157c2a5 100644 --- a/fggl/data/model.cpp +++ b/fggl/data/model.cpp @@ -6,7 +6,7 @@ using namespace fggl::data; -Mesh::Mesh() : m_verts(0), m_index(0), restartVertex(Mesh::INVALID_IDX) { +Mesh::Mesh() : restartVertex(Mesh::INVALID_IDX), m_verts(0), m_index(0) { } void Mesh::pushIndex(unsigned int idx) { diff --git a/fggl/data/procedural.cpp b/fggl/data/procedural.cpp index ec408f2..2598f72 100644 --- a/fggl/data/procedural.cpp +++ b/fggl/data/procedural.cpp @@ -1,4 +1,5 @@ +#include <cstddef> #include <fggl/data/procedural.hpp> #include <fggl/data/model.hpp> @@ -53,7 +54,7 @@ static void compute_normals(fggl::data::Mesh& mesh, // we need to calculate the contribution for each vertex // this assumes IDXList describes a raw triangle list (ie, not quads and not a strip) - for ( int i=0; i < idxList.size(); i += 3) { + for ( std::size_t i=0; i < idxList.size(); i += 3) { auto& v1 = mesh.vertex( idxMapping[idxList[i]] ); auto& v2 = mesh.vertex( idxMapping[idxList[i + 1]] ); auto& v3 = mesh.vertex( idxMapping[idxList[i + 2]] ); diff --git a/fggl/ecs3/fast/Container.cpp b/fggl/ecs3/fast/Container.cpp index 1473365..7941260 100644 --- a/fggl/ecs3/fast/Container.cpp +++ b/fggl/ecs3/fast/Container.cpp @@ -8,7 +8,7 @@ namespace fggl::ecs3 { std::ostream& operator<<(std::ostream& out, RecordIdentifier const& curr) { out << "record("; - for (int i=0; i<curr.count; i++) { + for (std::size_t i=0; i<curr.count; i++) { out << i; if ( i != curr.count-1) { out << ","; diff --git a/fggl/gfx/input.cpp b/fggl/gfx/input.cpp index ef7329f..47fc410 100644 --- a/fggl/gfx/input.cpp +++ b/fggl/gfx/input.cpp @@ -6,7 +6,7 @@ using fggl::gfx::Input; -Input::Input() : m_mouse_curr(), m_mouse_last(), m_joydata(), m_joysticks(), m_pad_last(), m_pad_curr() { +Input::Input() : m_mouse_curr(), m_mouse_last(), m_joysticks(), m_joydata(), m_pad_curr(), m_pad_last() { clear(); } diff --git a/fggl/math/triangulation.cpp b/fggl/math/triangulation.cpp index d235b8e..f855734 100644 --- a/fggl/math/triangulation.cpp +++ b/fggl/math/triangulation.cpp @@ -35,7 +35,7 @@ namespace fggl::math { // deal with the indices const auto nTris = polygon.size() - 2; - for (auto i = 0; i < nTris; i++) { + for (auto i = 0u; i < nTris; i++) { mesh.add_index(firstIdx); mesh.add_index(prevIdx); diff --git a/include/fggl/ecs3/fast/Container.h b/include/fggl/ecs3/fast/Container.h index 4b6a529..18b1fa1 100644 --- a/include/fggl/ecs3/fast/Container.h +++ b/include/fggl/ecs3/fast/Container.h @@ -13,17 +13,17 @@ namespace fggl::ecs3 { + class Container { public: const RecordIdentifier m_identifier; Container(const TypeRegistry ®, RecordIdentifier id) : + m_identifier(id), m_types(reg), - m_identifier(id), backingStore(nullptr), - m_capacity(0), - m_size(0) { - }; + m_size(0), + m_capacity(0) {}; ~Container() { delete[] backingStore; @@ -80,7 +80,7 @@ namespace fggl::ecs3 { inline std::size_t idx(entity_t entity) { auto *entityData = data<EntityMeta>(); - for (int i = 0; i < m_size; i++) { + for (std::size_t i = 0; i < m_size; i++) { if (entityData[i].id == entity) { return i; } diff --git a/include/fggl/ecs3/prototype/world.h b/include/fggl/ecs3/prototype/world.h index 7b63348..4cc8a5b 100644 --- a/include/fggl/ecs3/prototype/world.h +++ b/include/fggl/ecs3/prototype/world.h @@ -19,7 +19,7 @@ namespace fggl::ecs3::prototype { public: bool m_abstract; - explicit Entity(entity_t id) : m_id(id), m_abstract(false) {}; + explicit Entity(entity_t id) : m_abstract(false), m_id(id) {}; Entity(const Entity &entity) : m_id(entity.m_id), m_components(entity.m_components) { //spdlog::info("entity created fro copy: {}", m_id); diff --git a/include/fggl/ecs3/types.hpp b/include/fggl/ecs3/types.hpp index 4a7ffc3..6c011d3 100644 --- a/include/fggl/ecs3/types.hpp +++ b/include/fggl/ecs3/types.hpp @@ -101,7 +101,7 @@ namespace fggl::ecs3 { } else if (count > other.count) { return false; } else { - for (int i = 0; i < count; i++) { + for (std::size_t i = 0; i < count; i++) { if (types[i] != other.types[i]) { return types[i] < other.types[i]; } @@ -115,7 +115,7 @@ namespace fggl::ecs3 { return false; } - for (int i = 0; i < count; i++) { + for (std::size_t i = 0; i < count; i++) { if (types[i] != arg.types[i]) { return false; } diff --git a/include/fggl/math/types.hpp b/include/fggl/math/types.hpp index 4639d48..6125c37 100644 --- a/include/fggl/math/types.hpp +++ b/include/fggl/math/types.hpp @@ -90,7 +90,7 @@ namespace fggl::math { struct Transform { constexpr static const char name[] = "Transform"; - Transform() : m_local(1.0f), m_origin(0.0f), m_model(1.0f), m_rotation(1.0f, 0.0f, 0.0f, 0.0f) { + Transform() : m_local(1.0f), m_model(1.0f), m_origin(0.0f), m_rotation(1.0f, 0.0f, 0.0f, 0.0f) { } // local reference vectors -- GitLab