From 5b7f5f2de723d30d3461f653e90fa4ae95941786 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 3 Mar 2023 19:52:55 +0000 Subject: Split Asset into its own file --- assetFactory/asset.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 assetFactory/asset.cpp (limited to 'assetFactory/asset.cpp') diff --git a/assetFactory/asset.cpp b/assetFactory/asset.cpp new file mode 100644 index 0000000..fa30a78 --- /dev/null +++ b/assetFactory/asset.cpp @@ -0,0 +1,8 @@ +#include "asset.h" + +bool +Asset::persist(Persistence::PersistenceStore & store) +{ + return STORE_TYPE && STORE_MEMBER(id) && STORE_MEMBER(name) + && STORE_NAME_HELPER("mesh", meshes, Persistence::Appender); +} -- cgit v1.2.3 From 29ce7770c3e8373d2efea0b47fe50a13a81e75a2 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 4 Mar 2023 14:17:00 +0000 Subject: Add Asset helpers to construct OpenGL ready meshes from Asset Factory meshes during load --- assetFactory/asset.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'assetFactory/asset.cpp') diff --git a/assetFactory/asset.cpp b/assetFactory/asset.cpp index fa30a78..659a950 100644 --- a/assetFactory/asset.cpp +++ b/assetFactory/asset.cpp @@ -3,6 +3,33 @@ bool Asset::persist(Persistence::PersistenceStore & store) { - return STORE_TYPE && STORE_MEMBER(id) && STORE_MEMBER(name) + return STORE_MEMBER(id) && STORE_MEMBER(name) && STORE_NAME_HELPER("mesh", meshes, Persistence::Appender); } + +Asset::MeshConstruct::MeshConstruct(Mesh::Ptr & m) : + Persistence::SelectionPtrBase {fmesh}, out {m} { } + +void +Asset::MeshConstruct::endObject(Persistence::Stack & stk) +{ + out = fmesh->createMesh(); + Persistence::SelectionPtrBase::endObject(stk); +} + +Asset::MeshArrayConstruct::MeshArrayConstruct(std::span m) : + Persistence::SelectionPtrBase {fmesh}, out {m} +{ +} + +void +Asset::MeshArrayConstruct::endObject(Persistence::Stack & stk) +{ + for (auto & outMesh : out) { + if (!outMesh) { + outMesh = fmesh->createMesh(); + break; + } + } + Persistence::SelectionPtrBase::endObject(stk); +} -- cgit v1.2.3 From 54ddcd3da0916b6a46f5fcf3f33ff0fbffe375ce Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 4 Mar 2023 14:27:23 +0000 Subject: Support and load factory asset directly into a RailVehicleClass instance --- assetFactory/asset.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'assetFactory/asset.cpp') diff --git a/assetFactory/asset.cpp b/assetFactory/asset.cpp index 659a950..3ab2f1c 100644 --- a/assetFactory/asset.cpp +++ b/assetFactory/asset.cpp @@ -3,8 +3,7 @@ bool Asset::persist(Persistence::PersistenceStore & store) { - return STORE_MEMBER(id) && STORE_MEMBER(name) - && STORE_NAME_HELPER("mesh", meshes, Persistence::Appender); + return STORE_MEMBER(id) && STORE_MEMBER(name); } Asset::MeshConstruct::MeshConstruct(Mesh::Ptr & m) : -- cgit v1.2.3