summaryrefslogtreecommitdiff
path: root/assetFactory/asset.cpp
blob: e3f5feb14f0eb4a5b560153793fd1887b3f2e300 (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
36
37
38
39
40
41
42
43
44
#include "asset.h"
#include "assetFactory.h"

bool
Asset::persist(Persistence::PersistenceStore & store)
{
	return STORE_MEMBER(id) && STORE_MEMBER(name);
}

Asset::TexturePtr
Asset::getTexture() const
{
	if (auto mf = Persistence::ParseBase::getShared<const AssetFactory>("assetFactory")) {
		return mf->getTexture();
	}
	return nullptr;
}

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);
}