summaryrefslogtreecommitdiff
path: root/assetFactory/asset.cpp
blob: 659a9500c6ad7ed10556a5737cffd323d34ca1aa (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
32
33
34
35
#include "asset.h"

bool
Asset::persist(Persistence::PersistenceStore & store)
{
	return STORE_MEMBER(id) && STORE_MEMBER(name)
			&& STORE_NAME_HELPER("mesh", meshes, Persistence::Appender<FactoryMesh::Collection>);
}

Asset::MeshConstruct::MeshConstruct(Mesh::Ptr & m) :
	Persistence::SelectionPtrBase<FactoryMesh::Ptr> {fmesh}, out {m} { }

void
Asset::MeshConstruct::endObject(Persistence::Stack & stk)
{
	out = fmesh->createMesh();
	Persistence::SelectionPtrBase<FactoryMesh::Ptr>::endObject(stk);
}

Asset::MeshArrayConstruct::MeshArrayConstruct(std::span<Mesh::Ptr> m) :
	Persistence::SelectionPtrBase<FactoryMesh::Ptr> {fmesh}, out {m}
{
}

void
Asset::MeshArrayConstruct::endObject(Persistence::Stack & stk)
{
	for (auto & outMesh : out) {
		if (!outMesh) {
			outMesh = fmesh->createMesh();
			break;
		}
	}
	Persistence::SelectionPtrBase<FactoryMesh::Ptr>::endObject(stk);
}