summaryrefslogtreecommitdiff
path: root/assetFactory/use.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-03-09 18:25:39 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-03-09 18:25:39 +0000
commit001be698401ef488cb3d30fb71c1a13c809407c8 (patch)
tree25f2f2634fcd7432092aa07f644dd00d1293f8d9 /assetFactory/use.cpp
parentAdd a generic persistence perf test (diff)
parentRewrite asset factory cylinder generator (diff)
downloadilt-001be698401ef488cb3d30fb71c1a13c809407c8.tar.bz2
ilt-001be698401ef488cb3d30fb71c1a13c809407c8.tar.xz
ilt-001be698401ef488cb3d30fb71c1a13c809407c8.zip
Merge branch 'model-factory-fixup'
Diffstat (limited to 'assetFactory/use.cpp')
-rw-r--r--assetFactory/use.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/assetFactory/use.cpp b/assetFactory/use.cpp
index 708e310..898b736 100644
--- a/assetFactory/use.cpp
+++ b/assetFactory/use.cpp
@@ -1,14 +1,36 @@
#include "use.h"
#include "assetFactory.h"
+#include <glm/ext/matrix_transform.hpp>
+#include <glm/matrix.hpp>
+#include <maths.h>
+#include <set>
+#include <stream_support.hpp>
Shape::CreatedFaces
-Use::createMesh(ModelFactoryMesh & mesh, const Mutation::Matrix & mutation) const
+Use::createMesh(ModelFactoryMesh & mesh, float levelOfDetailFactor) const
{
- auto faces = type->createMesh(mesh, mutation * getMatrix());
+ auto apply = [&mesh](const auto & faces, const Mutation::Matrix & m) {
+ std::set<ModelFactoryMesh::VertexHandle> vs;
+ for (const auto & f : faces) {
+ const auto fvr = mesh.fv_range(f.second);
+ for (const auto & v : fvr) {
+ if (!vs.contains(v)) {
+ glm::vec3 p = mesh.point(v);
+ p = p % m;
+ mesh.set_point(v, ModelFactoryMesh::Point(p.x, p.y, p.z));
+ vs.insert(v);
+ }
+ }
+ }
+ };
+
+ auto faces = type->createMesh(mesh, levelOfDetailFactor * relativeLevelOfDetail());
applyStyle(mesh, {this}, faces);
+ apply(faces, getDeformationMatrix());
for (const auto & [name, faceController] : faceControllers) {
faceController->apply(mesh, {this}, name, faces);
}
+ apply(faces, getLocationMatrix());
return faces;
}