summaryrefslogtreecommitdiff
path: root/assetFactory/use.cpp
blob: 21e26f3d4a3c343c08c461ffa103ab18260e26c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "use.h"
#include "modelFactory.h"

Shape::CreatedFaces
Use::createMesh(ModelFactoryMesh & mesh, const Mutation::Matrix & mutation) const
{
	auto faces = type->createMesh(mesh, mutation * getMatrix());
	for (const auto & [name, faceController] : faceControllers) {
		faceController.apply(mesh, 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 = std::dynamic_pointer_cast<const ModelFactory>(Persistence::sharedObjects.at("modelFactory"))) {
			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);
}