diff options
Diffstat (limited to 'assetFactory/use.cpp')
-rw-r--r-- | assetFactory/use.cpp | 33 |
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>); +} |