summaryrefslogtreecommitdiff
path: root/assetFactory/use.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-03-05 01:59:16 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-03-05 01:59:16 +0000
commitd4c073a18adaed73973f34c6c39fc15664d9211d (patch)
tree44536af3af0284ab75eae79ef81a5e4452019269 /assetFactory/use.cpp
parentAdd helper operator to perform vec3*mat4 and perspective divide (diff)
parentRemove old hard coded asset factory test, run entirely from XML load and rend... (diff)
downloadilt-d4c073a18adaed73973f34c6c39fc15664d9211d.tar.bz2
ilt-d4c073a18adaed73973f34c6c39fc15664d9211d.tar.xz
ilt-d4c073a18adaed73973f34c6c39fc15664d9211d.zip
Merge branch 'model-factory'
Diffstat (limited to 'assetFactory/use.cpp')
-rw-r--r--assetFactory/use.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/assetFactory/use.cpp b/assetFactory/use.cpp
new file mode 100644
index 0000000..708e310
--- /dev/null
+++ b/assetFactory/use.cpp
@@ -0,0 +1,33 @@
+#include "use.h"
+#include "assetFactory.h"
+
+Shape::CreatedFaces
+Use::createMesh(ModelFactoryMesh & mesh, const Mutation::Matrix & mutation) const
+{
+ auto faces = type->createMesh(mesh, mutation * getMatrix());
+ applyStyle(mesh, {this}, faces);
+ for (const auto & [name, faceController] : faceControllers) {
+ faceController->apply(mesh, {this}, name, faces);
+ }
+ return faces;
+}
+
+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
+ {
+ if (auto mf = Persistence::ParseBase::getShared<const AssetFactory>("assetFactory")) {
+ v = mf->shapes.at(str);
+ }
+ }
+};
+
+bool
+Use::persist(Persistence::PersistenceStore & store)
+{
+ return STORE_TYPE && STORE_HELPER(type, Lookup) && STORE_MEMBER(position) && STORE_MEMBER(scale)
+ && STORE_MEMBER(rotation) && Style::persist(store)
+ && STORE_NAME_HELPER("face", faceControllers, Persistence::MapByMember<FaceControllers>);
+}