From 2f8d7643d03f39fa848576692264d0fe3a37ed91 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 6 Nov 2023 20:48:33 +0000 Subject: Reformat with new clang-format --- assetFactory/assimp.cpp | 1 + assetFactory/faceController.h | 3 +++ assetFactory/mutation.cpp | 1 + assetFactory/object.h | 1 + assetFactory/style.cpp | 1 + assetFactory/texturePacker.h | 2 ++ assetFactory/use.cpp | 1 + assetFactory/use.h | 1 + 8 files changed, 11 insertions(+) (limited to 'assetFactory') diff --git a/assetFactory/assimp.cpp b/assetFactory/assimp.cpp index 9dc7842..bd5467b 100644 --- a/assetFactory/assimp.cpp +++ b/assetFactory/assimp.cpp @@ -30,6 +30,7 @@ operator!(const aiVector3t & v) } using SceneCPtr = std::shared_ptr; + class AssImpNode : public Shape { public: AssImpNode(SceneCPtr scene, const aiNode * node) : scene(std::move(scene)), node(node) { } diff --git a/assetFactory/faceController.h b/assetFactory/faceController.h index 0376241..fb89d25 100644 --- a/assetFactory/faceController.h +++ b/assetFactory/faceController.h @@ -18,12 +18,14 @@ public: private: friend Persistence::SelectionPtrBase>; bool persist(Persistence::PersistenceStore & store) override; + std::string getId() const override { return {}; }; }; + using FaceControllers = std::map>; using Splits = std::map>; @@ -38,6 +40,7 @@ public: private: friend Persistence::SelectionPtrBase>; bool persist(Persistence::PersistenceStore & store) override; + std::string getId() const override { diff --git a/assetFactory/mutation.cpp b/assetFactory/mutation.cpp index 9a6a988..c5c3f5b 100644 --- a/assetFactory/mutation.cpp +++ b/assetFactory/mutation.cpp @@ -27,6 +27,7 @@ Mutation::relativeLevelOfDetail() const { return std::max({scale.x, scale.y, scale.z}); } + bool Mutation::persist(Persistence::PersistenceStore & store) { diff --git a/assetFactory/object.h b/assetFactory/object.h index f47c512..77e1469 100644 --- a/assetFactory/object.h +++ b/assetFactory/object.h @@ -18,6 +18,7 @@ public: private: friend Persistence::SelectionPtrBase>; bool persist(Persistence::PersistenceStore & store) override; + std::string getId() const override { diff --git a/assetFactory/style.cpp b/assetFactory/style.cpp index ea67fc2..81a5441 100644 --- a/assetFactory/style.cpp +++ b/assetFactory/style.cpp @@ -61,6 +61,7 @@ Style::persist(Persistence::PersistenceStore & store) struct ColourParser : public Persistence::SelectionV { using Persistence::SelectionV::SelectionV; using Persistence::SelectionV::setValue; + void setValue(std::string && str) override { diff --git a/assetFactory/texturePacker.h b/assetFactory/texturePacker.h index a1b270b..93413eb 100644 --- a/assetFactory/texturePacker.h +++ b/assetFactory/texturePacker.h @@ -16,12 +16,14 @@ public: Position position; Size size; + bool operator<(const Area & other) const { return area(size) < area(other.size); } }; + using Image = Size; using Space = Area; using Positions = std::vector; diff --git a/assetFactory/use.cpp b/assetFactory/use.cpp index 5314321..0994c8c 100644 --- a/assetFactory/use.cpp +++ b/assetFactory/use.cpp @@ -35,6 +35,7 @@ Use::createMesh(ModelFactoryMesh & mesh, float levelOfDetailFactor) const struct Lookup : public Persistence::SelectionV { using Persistence::SelectionV::SelectionV; using Persistence::SelectionV::setValue; + void setValue(std::string && str) override { diff --git a/assetFactory/use.h b/assetFactory/use.h index a91685b..289bf6e 100644 --- a/assetFactory/use.h +++ b/assetFactory/use.h @@ -19,6 +19,7 @@ public: private: friend Persistence::SelectionPtrBase>; bool persist(Persistence::PersistenceStore & store) override; + std::string getId() const override { -- cgit v1.2.3 From d6e99a696aa582b81018078b68f6600c8030d643 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 7 Nov 2023 02:51:42 +0000 Subject: WIP typedefing all the things - headers --- assetFactory/factoryMesh.h | 3 ++- assetFactory/mutation.h | 7 ++++--- assetFactory/shape.h | 3 ++- assetFactory/texturePacker.cpp | 4 +--- assetFactory/texturePacker.h | 7 ++++--- 5 files changed, 13 insertions(+), 11 deletions(-) (limited to 'assetFactory') diff --git a/assetFactory/factoryMesh.h b/assetFactory/factoryMesh.h index f71c737..b09b54f 100644 --- a/assetFactory/factoryMesh.h +++ b/assetFactory/factoryMesh.h @@ -1,5 +1,6 @@ #pragma once +#include "config/types.h" #include "gfx/models/mesh.h" #include "stdTypeDefs.h" #include "use.h" @@ -9,7 +10,7 @@ public: Mesh::Ptr createMesh() const; std::string id; - glm::vec3 size; + Size3D size; Use::Collection uses; private: diff --git a/assetFactory/mutation.h b/assetFactory/mutation.h index 2432174..b571dea 100644 --- a/assetFactory/mutation.h +++ b/assetFactory/mutation.h @@ -1,5 +1,6 @@ #pragma once +#include "config/types.h" #include "persistence.h" #include #include @@ -13,9 +14,9 @@ struct Mutation { float relativeLevelOfDetail() const; - glm::vec3 position {}; - glm::vec3 rotation {}; - glm::vec3 scale {1}; + Position3D position {}; + Rotation3D rotation {}; + Scale3D scale {1}; protected: bool persist(Persistence::PersistenceStore & store); diff --git a/assetFactory/shape.h b/assetFactory/shape.h index ea3e4e7..136e24f 100644 --- a/assetFactory/shape.h +++ b/assetFactory/shape.h @@ -1,5 +1,6 @@ #pragma once +#include "config/types.h" #include "modelFactoryMesh_fwd.h" #include "stdTypeDefs.h" #include @@ -21,5 +22,5 @@ public: virtual CreatedFaces createMesh(ModelFactoryMesh &, float levelOfDetailFactor) const = 0; static std::vector addToMesh( - ModelFactoryMesh & mesh, const std::span vertices); + ModelFactoryMesh & mesh, const std::span vertices); }; diff --git a/assetFactory/texturePacker.cpp b/assetFactory/texturePacker.cpp index dbafc4b..0d0fdb6 100644 --- a/assetFactory/texturePacker.cpp +++ b/assetFactory/texturePacker.cpp @@ -14,9 +14,7 @@ TexturePacker::TexturePacker(std::span in) : std::sort(sortedIndexes.rbegin(), sortedIndexes.rend(), [this](const auto a, const auto b) { return area(inputImages[a]) < area(inputImages[b]); }); - int mts; - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mts); - maxTextureSize = static_cast(mts); + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); } TexturePacker::Result diff --git a/assetFactory/texturePacker.h b/assetFactory/texturePacker.h index 93413eb..05e3204 100644 --- a/assetFactory/texturePacker.h +++ b/assetFactory/texturePacker.h @@ -1,13 +1,14 @@ #pragma once +#include "config/types.h" #include #include #include class TexturePacker { public: - using Position = glm::uvec2; - using Size = glm::uvec2; + using Position = TextureAbsCoord; + using Size = TextureAbsCoord; struct Area { #ifndef __cpp_aggregate_paren_init @@ -40,5 +41,5 @@ public: private: std::span inputImages; std::vector sortedIndexes; - unsigned int maxTextureSize; + GLsizei maxTextureSize; }; -- cgit v1.2.3 From 9c2c3f71065c94a18c02440111b6ff8ca977b90e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 9 Nov 2023 00:40:40 +0000 Subject: WIP typedefing all the things - sources --- assetFactory/cuboid.cpp | 2 +- assetFactory/cylinder.cpp | 6 +++--- assetFactory/plane.cpp | 2 +- assetFactory/shape.cpp | 4 +--- 4 files changed, 6 insertions(+), 8 deletions(-) (limited to 'assetFactory') diff --git a/assetFactory/cuboid.cpp b/assetFactory/cuboid.cpp index a8ddcd9..cfb6cfb 100644 --- a/assetFactory/cuboid.cpp +++ b/assetFactory/cuboid.cpp @@ -4,7 +4,7 @@ Cuboid::CreatedFaces Cuboid::createMesh(ModelFactoryMesh & mesh, float) const { - static constexpr std::array VERTICES {{ + static constexpr std::array VERTICES {{ // bottom {n, n, z}, {n, y, z}, diff --git a/assetFactory/cylinder.cpp b/assetFactory/cylinder.cpp index 7d22e36..ed034fd 100644 --- a/assetFactory/cylinder.cpp +++ b/assetFactory/cylinder.cpp @@ -9,8 +9,8 @@ Cylinder::createMesh(ModelFactoryMesh & mesh, float lodf) const const auto step = two_pi / static_cast(P); // Generate 2D circumference points - std::vector circumference(P); - std::generate(circumference.begin(), circumference.end(), [a = 0.f, step]() mutable { + std::vector circumference(P); + std::generate(circumference.begin(), circumference.end(), [a = 0.F, step]() mutable { return sincosf(a += step) * .5F; }); @@ -19,7 +19,7 @@ Cylinder::createMesh(ModelFactoryMesh & mesh, float lodf) const // Generate bottom face vertices std::vector bottom(P); std::transform(circumference.begin(), circumference.end(), bottom.begin(), [&mesh](const auto & xy) { - return mesh.add_vertex(xy ^ 0.f); + return mesh.add_vertex(xy ^ 0.F); }); surface.insert(mesh.add_namedFace("bottom", bottom)); } diff --git a/assetFactory/plane.cpp b/assetFactory/plane.cpp index c6e1b5a..28fb690 100644 --- a/assetFactory/plane.cpp +++ b/assetFactory/plane.cpp @@ -4,7 +4,7 @@ Plane::CreatedFaces Plane::createMesh(ModelFactoryMesh & mesh, float) const { - static constexpr std::array VERTICES {{ + static constexpr std::array VERTICES {{ {n, n, z}, {y, n, z}, {y, y, z}, diff --git a/assetFactory/shape.cpp b/assetFactory/shape.cpp index 1bfbdbb..0f83ee5 100644 --- a/assetFactory/shape.cpp +++ b/assetFactory/shape.cpp @@ -1,11 +1,9 @@ #include "shape.h" -#include "gfx/models/vertex.h" -#include "maths.h" #include "modelFactoryMesh.h" #include "shape.h" std::vector -Shape::addToMesh(ModelFactoryMesh & mesh, const std::span vertices) +Shape::addToMesh(ModelFactoryMesh & mesh, const std::span vertices) { std::vector vhs; std::transform(vertices.begin(), vertices.end(), std::back_inserter(vhs), [&mesh](const auto & p) { -- cgit v1.2.3 From d771fbda2c171cfbc36cc0eb3122c1a02ffbb081 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 9 Nov 2023 01:57:27 +0000 Subject: WIP typedefing just about everything else --- assetFactory/assetFactory.h | 5 ++--- assetFactory/modelFactoryMesh.h | 9 +++++---- assetFactory/style.cpp | 14 +++++++------- assetFactory/style.h | 6 ++---- 4 files changed, 16 insertions(+), 18 deletions(-) (limited to 'assetFactory') diff --git a/assetFactory/assetFactory.h b/assetFactory/assetFactory.h index e449ce2..787f0a4 100644 --- a/assetFactory/assetFactory.h +++ b/assetFactory/assetFactory.h @@ -15,10 +15,9 @@ public: using Assets = std::map>; using AssImps = std::map>; using TextureFragments = std::map>; - using Colour = glm::vec3; - using ColourAlpha = glm::vec4; + using Colour = RGB; + using ColourAlpha = RGBA; using Colours = std::map>; - using TextureFragmentCoords = std::array; AssetFactory(); [[nodiscard]] static std::shared_ptr loadXML(const std::filesystem::path &); diff --git a/assetFactory/modelFactoryMesh.h b/assetFactory/modelFactoryMesh.h index 32e7ab5..480bf7f 100644 --- a/assetFactory/modelFactoryMesh.h +++ b/assetFactory/modelFactoryMesh.h @@ -1,5 +1,6 @@ #pragma once +#include "config/types.h" #include "modelFactoryMesh_fwd.h" #include #include @@ -38,10 +39,10 @@ struct ModelFactoryTraits : public OpenMesh::DefaultTraits { EdgeAttributes(OpenMesh::Attributes::Status); VertexAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Status); HalfedgeAttributes(OpenMesh::Attributes::TexCoord2D); - using Point = glm::vec3; - using Normal = glm::vec3; - using Color = glm::vec4; - using TexCoord2D = glm::vec2; + using Point = Position3D; + using Normal = Normal3D; + using Color = RGBA; + using TexCoord2D = TextureRelCoord; }; struct ModelFactoryMesh : public OpenMesh::PolyMesh_ArrayKernelT { diff --git a/assetFactory/style.cpp b/assetFactory/style.cpp index 81a5441..265becb 100644 --- a/assetFactory/style.cpp +++ b/assetFactory/style.cpp @@ -33,10 +33,10 @@ Style::applyStyle( const auto material = mf->getMaterialIndex(texture); mesh.property(mesh.materialFaceProperty, face) = material; static constexpr std::array coords {{ - {0.f, 0.f}, - {1.f, 0.f}, - {1.f, 1.f}, - {0.f, 1.f}, + {0.F, 0.F}, + {1.F, 0.F}, + {1.F, 1.F}, + {0.F, 1.F}, }}; auto coord = coords.begin(); // Wild assumption that face is a quad and the texture should apply linearly @@ -58,9 +58,9 @@ Style::getColour(const StyleStack & parents) bool Style::persist(Persistence::PersistenceStore & store) { - struct ColourParser : public Persistence::SelectionV { - using Persistence::SelectionV::SelectionV; - using Persistence::SelectionV::setValue; + struct ColourParser : public Persistence::SelectionV { + using Persistence::SelectionV::SelectionV; + using Persistence::SelectionV::setValue; void setValue(std::string && str) override diff --git a/assetFactory/style.h b/assetFactory/style.h index d931f98..2a437aa 100644 --- a/assetFactory/style.h +++ b/assetFactory/style.h @@ -10,9 +10,7 @@ class Style { public: using StyleStack = std::vector; - using Colour = glm::vec3; - using ColourAlpha = glm::vec4; - using EffectiveColour = std::optional>; + using EffectiveColour = std::optional>; void applyStyle(ModelFactoryMesh &, const StyleStack & parents, const Shape::CreatedFaces &) const; void applyStyle(ModelFactoryMesh &, const StyleStack & parents, const ModelFactoryMesh::FaceHandle &) const; @@ -30,7 +28,7 @@ public: static EffectiveColour getColour(const StyleStack & parents); - ColourAlpha colour {}; + RGBA colour {}; std::optional smooth; std::string texture; std::string textureRotation; // Multiples of 90deg, no int/enum support -- cgit v1.2.3 From 685b33980cc7a346574b24732464f0cbe3115a1f Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 15 Nov 2023 01:29:24 +0000 Subject: Switch to millimeters for spatial units Mostly a case of changing far too many magic numbers, something else to fix I guess. I probably missed something. Also there's some hackery when loading 3D models, which are still assumed to be in metres. --- assetFactory/factoryMesh.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'assetFactory') diff --git a/assetFactory/factoryMesh.cpp b/assetFactory/factoryMesh.cpp index 46bcf6f..3caf5e8 100644 --- a/assetFactory/factoryMesh.cpp +++ b/assetFactory/factoryMesh.cpp @@ -30,7 +30,7 @@ FactoryMesh::createMesh() const const auto & point = mesh.point(vertex); const auto & normal = useVertexNormals ? mesh.property(mesh.vertex_normals_pph(), vertex) : mesh.property(mesh.face_normals_pph(), face); - Vertex outVertex {point, textureUV, normal, colour, material}; + Vertex outVertex {point * 1000.F, textureUV, normal, colour, material}; if (const auto existingItr = std::find(vertices.rbegin(), vertices.rend(), outVertex); existingItr != vertices.rend()) { faceIndices.push_back(static_cast(std::distance(existingItr, vertices.rend()) - 1)); -- cgit v1.2.3