summaryrefslogtreecommitdiff
path: root/assetFactory
diff options
context:
space:
mode:
Diffstat (limited to 'assetFactory')
-rw-r--r--assetFactory/asset.cpp6
-rw-r--r--assetFactory/asset.h8
-rw-r--r--assetFactory/assetFactory.cpp3
-rw-r--r--assetFactory/assetFactory.h2
-rw-r--r--assetFactory/assimp.cpp2
-rw-r--r--assetFactory/cylinder.cpp2
-rw-r--r--assetFactory/factoryMesh.cpp11
-rw-r--r--assetFactory/modelFactoryMesh.cpp8
-rw-r--r--assetFactory/modelFactoryMesh.h11
-rw-r--r--assetFactory/mutation.cpp5
10 files changed, 32 insertions, 26 deletions
diff --git a/assetFactory/asset.cpp b/assetFactory/asset.cpp
index e3f5feb..0254943 100644
--- a/assetFactory/asset.cpp
+++ b/assetFactory/asset.cpp
@@ -7,6 +7,12 @@ Asset::persist(Persistence::PersistenceStore & store)
return STORE_MEMBER(id) && STORE_MEMBER(name);
}
+std::any
+Asset::createAt(const Location &) const
+{
+ return {};
+}
+
Asset::TexturePtr
Asset::getTexture() const
{
diff --git a/assetFactory/asset.h b/assetFactory/asset.h
index 5bdd2f2..061a7c8 100644
--- a/assetFactory/asset.h
+++ b/assetFactory/asset.h
@@ -2,14 +2,22 @@
#include "factoryMesh.h"
#include "persistence.h"
+#include <any>
+#include <manyPtr.h>
#include <stdTypeDefs.h>
class TextureAtlas;
+class Renderable;
+class Location;
class Asset : public Persistence::Persistable, public StdTypeDefs<Asset> {
public:
+ using ManyPtr = ManySharedPtr<Asset, const Renderable>;
using TexturePtr = std::shared_ptr<TextureAtlas>;
+ /// Used only for the asset viewer
+ [[nodiscard]] virtual std::any createAt(const Location &) const;
+
std::string id;
std::string name;
diff --git a/assetFactory/assetFactory.cpp b/assetFactory/assetFactory.cpp
index 176e1f5..426fecc 100644
--- a/assetFactory/assetFactory.cpp
+++ b/assetFactory/assetFactory.cpp
@@ -5,6 +5,7 @@
#include "filesystem.h"
#include "gfx/image.h"
#include "gfx/models/texture.h"
+#include "gfx/renderable.h"
#include "object.h"
#include "plane.h"
#include "saxParse-persistence.h"
@@ -146,7 +147,7 @@ bool
AssetFactory::persist(Persistence::PersistenceStore & store)
{
using MapObjects = Persistence::MapByMember<Shapes, std::shared_ptr<Object>>;
- using MapAssets = Persistence::MapByMember<Assets>;
+ using MapAssets = Persistence::MapByMember<Assets, Asset::Ptr>;
using MapTextureFragments = Persistence::MapByMember<TextureFragments>;
using MapAssImp = Persistence::MapByMember<AssImps, std::shared_ptr<AssImp>, &AssImp::path>;
return STORE_TYPE && STORE_NAME_HELPER("object", shapes, MapObjects)
diff --git a/assetFactory/assetFactory.h b/assetFactory/assetFactory.h
index 787f0a4..864e882 100644
--- a/assetFactory/assetFactory.h
+++ b/assetFactory/assetFactory.h
@@ -12,7 +12,7 @@ class Texture;
class AssetFactory : public Persistence::Persistable {
public:
using Shapes = std::map<std::string, Shape::Ptr, std::less<>>;
- using Assets = std::map<std::string, Asset::Ptr, std::less<>>;
+ using Assets = std::map<std::string, Asset::ManyPtr, std::less<>>;
using AssImps = std::map<std::string, AssImp::Ptr, std::less<>>;
using TextureFragments = std::map<std::string, TextureFragment::Ptr, std::less<>>;
using Colour = RGB;
diff --git a/assetFactory/assimp.cpp b/assetFactory/assimp.cpp
index 1e11eda..e33783a 100644
--- a/assetFactory/assimp.cpp
+++ b/assetFactory/assimp.cpp
@@ -84,8 +84,8 @@ public:
for (auto idx = f.mIndices; const auto fheh : mesh.fh_range(fh)) {
const auto ouv = !amesh->mTextureCoords[0][*idx++];
mesh.set_texcoord2D(fheh, ouv);
- mesh.property(mesh.materialFaceProperty, fh) = material;
}
+ mesh.property(mesh.materialFaceProperty, fh) = material;
}
}
}
diff --git a/assetFactory/cylinder.cpp b/assetFactory/cylinder.cpp
index f41bfd4..432fb16 100644
--- a/assetFactory/cylinder.cpp
+++ b/assetFactory/cylinder.cpp
@@ -12,7 +12,7 @@ Cylinder::createMesh(ModelFactoryMesh & mesh, Scale3D lodf) const
// Generate 2D circumference points
std::vector<RelativePosition2D> circumference(P);
std::generate(circumference.begin(), circumference.end(), [a = 0.F, step]() mutable {
- return sincosf(a += step) * .5F;
+ return sincos(a += step) * .5F;
});
CreatedFaces surface;
diff --git a/assetFactory/factoryMesh.cpp b/assetFactory/factoryMesh.cpp
index bf4706e..eb9d525 100644
--- a/assetFactory/factoryMesh.cpp
+++ b/assetFactory/factoryMesh.cpp
@@ -25,11 +25,12 @@ FactoryMesh::createMesh() const
std::vector<unsigned int> faceIndices;
for (const auto & heh : mesh.fh_range(face)) {
const auto & vertex = mesh.to_vertex_handle(heh);
- const auto & textureUV = mesh.texcoord2D(heh);
- 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 * 1000.F, textureUV, normal, colour, material};
+ Vertex outVertex {.pos = mesh.point(vertex) * 1000.F,
+ .texCoord = mesh.texcoord2D(heh),
+ .normal = useVertexNormals ? mesh.property(mesh.vertex_normals_pph(), vertex)
+ : mesh.property(mesh.face_normals_pph(), face),
+ .colour = colour,
+ .material = 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/modelFactoryMesh.cpp b/assetFactory/modelFactoryMesh.cpp
index 3d4b5f3..3660fb7 100644
--- a/assetFactory/modelFactoryMesh.cpp
+++ b/assetFactory/modelFactoryMesh.cpp
@@ -1,13 +1,5 @@
#include "modelFactoryMesh.h"
-ModelFactoryMesh::ModelFactoryMesh()
-{
- add_property(smoothFaceProperty);
- add_property(materialFaceProperty);
- add_property(nameFaceProperty);
- add_property(nameAdjFaceProperty);
-}
-
void
ModelFactoryMesh::configNamedFace(const std::string & name, OpenMesh::FaceHandle handle)
{
diff --git a/assetFactory/modelFactoryMesh.h b/assetFactory/modelFactoryMesh.h
index 299986e..6a18155 100644
--- a/assetFactory/modelFactoryMesh.h
+++ b/assetFactory/modelFactoryMesh.h
@@ -8,6 +8,7 @@
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <thirdparty/openmesh/glmcompat.h>
+#include <thirdparty/openmesh/helpers.h>
struct ModelFactoryTraits : public OpenMesh::DefaultTraits {
FaceAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Status | OpenMesh::Attributes::Color);
@@ -21,13 +22,11 @@ struct ModelFactoryTraits : public OpenMesh::DefaultTraits {
};
struct ModelFactoryMesh : public OpenMesh::PolyMesh_ArrayKernelT<ModelFactoryTraits> {
- ModelFactoryMesh();
-
bool normalsProvidedProperty {};
- OpenMesh::FPropHandleT<bool> smoothFaceProperty;
- OpenMesh::FPropHandleT<GLuint> materialFaceProperty;
- OpenMesh::FPropHandleT<std::string> nameFaceProperty;
- OpenMesh::HPropHandleT<std::string> nameAdjFaceProperty;
+ const OpenMesh::Helpers::Property<bool, OpenMesh::FPropHandleT> smoothFaceProperty {this};
+ const OpenMesh::Helpers::Property<GLuint, OpenMesh::FPropHandleT> materialFaceProperty {this};
+ const OpenMesh::Helpers::Property<std::string, OpenMesh::FPropHandleT> nameFaceProperty {this};
+ const OpenMesh::Helpers::Property<std::string, OpenMesh::HPropHandleT> nameAdjFaceProperty {this};
template<typename... Vs>
std::pair<std::string, OpenMesh::FaceHandle>
diff --git a/assetFactory/mutation.cpp b/assetFactory/mutation.cpp
index 6695dff..2ab2a76 100644
--- a/assetFactory/mutation.cpp
+++ b/assetFactory/mutation.cpp
@@ -1,12 +1,11 @@
#include "mutation.h"
-#include <algorithm>
#include <glm/gtx/transform.hpp>
#include <maths.h>
Mutation::Matrix
Mutation::getMatrix() const
{
- return glm::translate(glm::identity<Matrix>(), position) * rotate_ypr(rotation)
+ return glm::translate(glm::identity<Matrix>(), position) * rotate_ypr<4>(rotation)
* glm::scale(glm::identity<Matrix>(), scale);
}
@@ -19,7 +18,7 @@ Mutation::getDeformationMatrix() const
Mutation::Matrix
Mutation::getLocationMatrix() const
{
- return glm::translate(glm::identity<Matrix>(), position) * rotate_ypr(rotation);
+ return glm::translate(glm::identity<Matrix>(), position) * rotate_ypr<4>(rotation);
}
bool