summaryrefslogtreecommitdiff
path: root/assetFactory
diff options
context:
space:
mode:
Diffstat (limited to 'assetFactory')
-rw-r--r--assetFactory/assetFactory.h5
-rw-r--r--assetFactory/assimp.cpp1
-rw-r--r--assetFactory/cuboid.cpp2
-rw-r--r--assetFactory/cylinder.cpp6
-rw-r--r--assetFactory/faceController.h3
-rw-r--r--assetFactory/factoryMesh.cpp2
-rw-r--r--assetFactory/factoryMesh.h3
-rw-r--r--assetFactory/modelFactoryMesh.h9
-rw-r--r--assetFactory/mutation.cpp1
-rw-r--r--assetFactory/mutation.h7
-rw-r--r--assetFactory/object.h1
-rw-r--r--assetFactory/plane.cpp2
-rw-r--r--assetFactory/shape.cpp4
-rw-r--r--assetFactory/shape.h3
-rw-r--r--assetFactory/style.cpp15
-rw-r--r--assetFactory/style.h6
-rw-r--r--assetFactory/texturePacker.cpp4
-rw-r--r--assetFactory/texturePacker.h9
-rw-r--r--assetFactory/use.cpp1
-rw-r--r--assetFactory/use.h1
20 files changed, 47 insertions, 38 deletions
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<std::string, Asset::Ptr, std::less<>>;
using AssImps = std::map<std::string, AssImp::Ptr, std::less<>>;
using TextureFragments = std::map<std::string, TextureFragment::Ptr, std::less<>>;
- using Colour = glm::vec3;
- using ColourAlpha = glm::vec4;
+ using Colour = RGB;
+ using ColourAlpha = RGBA;
using Colours = std::map<std::string, Colour, std::less<>>;
- using TextureFragmentCoords = std::array<glm::vec2, 4>;
AssetFactory();
[[nodiscard]] static std::shared_ptr<AssetFactory> loadXML(const std::filesystem::path &);
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<T> & v)
}
using SceneCPtr = std::shared_ptr<const aiScene>;
+
class AssImpNode : public Shape {
public:
AssImpNode(SceneCPtr scene, const aiNode * node) : scene(std::move(scene)), node(node) { }
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<glm::vec3, 8> VERTICES {{
+ static constexpr std::array<Position3D, 8> 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<float>(P);
// Generate 2D circumference points
- std::vector<glm::vec2> circumference(P);
- std::generate(circumference.begin(), circumference.end(), [a = 0.f, step]() mutable {
+ std::vector<Position2D> 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<OpenMesh::VertexHandle> 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/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<std::unique_ptr<Split>>;
bool persist(Persistence::PersistenceStore & store) override;
+
std::string
getId() const override
{
return {};
};
};
+
using FaceControllers = std::map<std::string, std::unique_ptr<FaceController>>;
using Splits = std::map<std::string, std::unique_ptr<Split>>;
@@ -38,6 +40,7 @@ public:
private:
friend Persistence::SelectionPtrBase<std::unique_ptr<FaceController>>;
bool persist(Persistence::PersistenceStore & store) override;
+
std::string
getId() const override
{
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<unsigned int>(std::distance(existingItr, vertices.rend()) - 1));
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/modelFactoryMesh.h b/assetFactory/modelFactoryMesh.h
index 2129fb5..06fd7b8 100644
--- a/assetFactory/modelFactoryMesh.h
+++ b/assetFactory/modelFactoryMesh.h
@@ -1,5 +1,6 @@
#pragma once
+#include "config/types.h"
#include "modelFactoryMesh_fwd.h"
#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
#include <glad/gl.h>
@@ -13,10 +14,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<ModelFactoryTraits> {
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/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 <glm/mat4x4.hpp>
#include <glm/vec3.hpp>
@@ -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/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<std::shared_ptr<Object>>;
bool persist(Persistence::PersistenceStore & store) override;
+
std::string
getId() const override
{
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<glm::vec3, 4> VERTICES {{
+ static constexpr std::array<Position3D, 4> 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<OpenMesh::VertexHandle>
-Shape::addToMesh(ModelFactoryMesh & mesh, const std::span<const glm::vec3> vertices)
+Shape::addToMesh(ModelFactoryMesh & mesh, const std::span<const Position3D> vertices)
{
std::vector<OpenMesh::VertexHandle> vhs;
std::transform(vertices.begin(), vertices.end(), std::back_inserter(vhs), [&mesh](const auto & p) {
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 <OpenMesh/Core/Mesh/Handles.hh>
@@ -21,5 +22,5 @@ public:
virtual CreatedFaces createMesh(ModelFactoryMesh &, float levelOfDetailFactor) const = 0;
static std::vector<OpenMesh::VertexHandle> addToMesh(
- ModelFactoryMesh & mesh, const std::span<const glm::vec3> vertices);
+ ModelFactoryMesh & mesh, const std::span<const Position3D> vertices);
};
diff --git a/assetFactory/style.cpp b/assetFactory/style.cpp
index ea67fc2..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<ModelFactoryTraits::TexCoord2D, 4> 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,10 @@ Style::getColour(const StyleStack & parents)
bool
Style::persist(Persistence::PersistenceStore & store)
{
- struct ColourParser : public Persistence::SelectionV<ColourAlpha> {
- using Persistence::SelectionV<ColourAlpha>::SelectionV;
- using Persistence::SelectionV<ColourAlpha>::setValue;
+ struct ColourParser : public Persistence::SelectionV<RGBA> {
+ using Persistence::SelectionV<RGBA>::SelectionV;
+ using Persistence::SelectionV<RGBA>::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<const Style *>;
- using Colour = glm::vec3;
- using ColourAlpha = glm::vec4;
- using EffectiveColour = std::optional<std::reference_wrapper<const ColourAlpha>>;
+ using EffectiveColour = std::optional<std::reference_wrapper<const RGBA>>;
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<bool> smooth;
std::string texture;
std::string textureRotation; // Multiples of 90deg, no int/enum support
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<const Image> 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<unsigned int>(mts);
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
}
TexturePacker::Result
diff --git a/assetFactory/texturePacker.h b/assetFactory/texturePacker.h
index a1b270b..05e3204 100644
--- a/assetFactory/texturePacker.h
+++ b/assetFactory/texturePacker.h
@@ -1,13 +1,14 @@
#pragma once
+#include "config/types.h"
#include <glm/vec2.hpp>
#include <span>
#include <vector>
class TexturePacker {
public:
- using Position = glm::uvec2;
- using Size = glm::uvec2;
+ using Position = TextureAbsCoord;
+ using Size = TextureAbsCoord;
struct Area {
#ifndef __cpp_aggregate_paren_init
@@ -16,12 +17,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<Position>;
@@ -38,5 +41,5 @@ public:
private:
std::span<const Image> inputImages;
std::vector<size_t> sortedIndexes;
- unsigned int maxTextureSize;
+ GLsizei maxTextureSize;
};
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<Shape::CPtr> {
using Persistence::SelectionV<Shape::CPtr>::SelectionV;
using Persistence::SelectionV<Shape::CPtr>::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<std::shared_ptr<Use>>;
bool persist(Persistence::PersistenceStore & store) override;
+
std::string
getId() const override
{