summaryrefslogtreecommitdiff
path: root/assetFactory
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-03-22 11:50:31 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2025-03-22 11:50:31 +0000
commit9fd25e8b10b1291525a18c8b3e34256ca6151dd6 (patch)
treec483b55010f310ed60cb7381130feedd2b3980a9 /assetFactory
parentSupport resizing the main window (diff)
downloadilt-9fd25e8b10b1291525a18c8b3e34256ca6151dd6.tar.bz2
ilt-9fd25e8b10b1291525a18c8b3e34256ca6151dd6.tar.xz
ilt-9fd25e8b10b1291525a18c8b3e34256ca6151dd6.zip
Add ManyPtr which tracks specified subclasses
This removes the need to repeated dynamic_cast the pointer. Provides interface which enforces the fastest option for the required types.
Diffstat (limited to 'assetFactory')
-rw-r--r--assetFactory/asset.h3
-rw-r--r--assetFactory/assetFactory.cpp3
-rw-r--r--assetFactory/assetFactory.h2
3 files changed, 6 insertions, 2 deletions
diff --git a/assetFactory/asset.h b/assetFactory/asset.h
index 5bdd2f2..b5de056 100644
--- a/assetFactory/asset.h
+++ b/assetFactory/asset.h
@@ -2,12 +2,15 @@
#include "factoryMesh.h"
#include "persistence.h"
+#include <manyPtr.h>
#include <stdTypeDefs.h>
class TextureAtlas;
+class Renderable;
class Asset : public Persistence::Persistable, public StdTypeDefs<Asset> {
public:
+ using ManyPtr = ManySharedPtr<Asset, const Renderable>;
using TexturePtr = std::shared_ptr<TextureAtlas>;
std::string id;
diff --git a/assetFactory/assetFactory.cpp b/assetFactory/assetFactory.cpp
index 176e1f5..426fecc 100644
--- a/assetFactory/assetFactory.cpp
+++ b/assetFactory/assetFactory.cpp
@@ -5,6 +5,7 @@
#include "filesystem.h"
#include "gfx/image.h"
#include "gfx/models/texture.h"
+#include "gfx/renderable.h"
#include "object.h"
#include "plane.h"
#include "saxParse-persistence.h"
@@ -146,7 +147,7 @@ bool
AssetFactory::persist(Persistence::PersistenceStore & store)
{
using MapObjects = Persistence::MapByMember<Shapes, std::shared_ptr<Object>>;
- using MapAssets = Persistence::MapByMember<Assets>;
+ using MapAssets = Persistence::MapByMember<Assets, Asset::Ptr>;
using MapTextureFragments = Persistence::MapByMember<TextureFragments>;
using MapAssImp = Persistence::MapByMember<AssImps, std::shared_ptr<AssImp>, &AssImp::path>;
return STORE_TYPE && STORE_NAME_HELPER("object", shapes, MapObjects)
diff --git a/assetFactory/assetFactory.h b/assetFactory/assetFactory.h
index 787f0a4..864e882 100644
--- a/assetFactory/assetFactory.h
+++ b/assetFactory/assetFactory.h
@@ -12,7 +12,7 @@ class Texture;
class AssetFactory : public Persistence::Persistable {
public:
using Shapes = std::map<std::string, Shape::Ptr, std::less<>>;
- using Assets = std::map<std::string, Asset::Ptr, std::less<>>;
+ using Assets = std::map<std::string, Asset::ManyPtr, std::less<>>;
using AssImps = std::map<std::string, AssImp::Ptr, std::less<>>;
using TextureFragments = std::map<std::string, TextureFragment::Ptr, std::less<>>;
using Colour = RGB;