Skip to content

Commit e2aa2bb

Browse files
add creation params and geoemtrycreator reference to IAssetLoaderOverride, also ecapsulate better
1 parent e0a23fc commit e2aa2bb

3 files changed

Lines changed: 33 additions & 8 deletions

File tree

include/nbl/asset/IAssetManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class NBL_API2 IAssetManager : public core::IReferenceCounted
122122
explicit IAssetManager(core::smart_refctd_ptr<system::ISystem>&& system, core::smart_refctd_ptr<CCompilerSet>&& compilerSet = nullptr) :
123123
m_system(std::move(system)),
124124
m_compilerSet(std::move(compilerSet)),
125-
m_defaultLoaderOverride(this)
125+
m_defaultLoaderOverride({.manager=this})
126126
{
127127
assert(IPreHashed::INVALID_HASH == static_cast<core::blake3_hash_t>(core::blake3_hasher{}));
128128
initializeMeshTools();

include/nbl/asset/interchange/IAssetLoader.h

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "nbl/system/ILogger.h"
1212

1313
#include "nbl/asset/interchange/SAssetBundle.h"
14+
#include "nbl/asset/utils/CGeometryCreator.h"
1415

1516

1617
namespace nbl::asset
@@ -171,14 +172,35 @@ class NBL_API2 IAssetLoader : public virtual core::IReferenceCounted
171172
protected:
172173
constexpr static inline bool ASSET_MUTABILITY_ON_CACHE_INSERT = true;
173174

174-
IAssetManager* m_manager;
175175
system::ISystem* m_system;
176176

177177
public:
178-
NBL_API2 IAssetLoaderOverride(IAssetManager* _manager);
178+
struct SCreationParams
179+
{
180+
IAssetManager* manager = nullptr;
181+
core::smart_refctd_ptr<CGeometryCreator> geoCreator = nullptr;
182+
//core::smart_refctd_ptr<CPolygonGeometryManipulator> polyGeoManip = nullptr;
183+
};
184+
NBL_API2 IAssetLoaderOverride(SCreationParams&& params);
185+
186+
//
187+
inline IAssetManager* getManager() const {return m_creationParams.manager;}
179188

180189
//
181-
inline IAssetManager* getManager() const {return m_manager;}
190+
inline CGeometryCreator* getGeometryCreator()
191+
{
192+
if (!m_creationParams.geoCreator)
193+
m_creationParams.geoCreator = core::make_smart_refctd_ptr<CGeometryCreator>();
194+
return m_creationParams.geoCreator.get();
195+
}
196+
197+
/*
198+
inline CPolygonGeometryManipulator* getPolygonGeometryManipulator()
199+
{
200+
if (!m_creationParams.geoCreator)
201+
m_creationParams.geoCreator = core::make_smart_refctd_ptr<CPolygonGeometryManipulator>();
202+
return m_creationParams.polyGeoManip.get();
203+
}*/
182204

183205
//!
184206
template<class AssetT>
@@ -274,6 +296,9 @@ class NBL_API2 IAssetLoader : public virtual core::IReferenceCounted
274296
//! After a successful load of an asset or sub-asset
275297
//TODO change name
276298
virtual void insertAssetIntoCache(SAssetBundle& asset, const std::string& supposedKey, const SAssetLoadParams& _params, const uint32_t hierarchyLevel);
299+
300+
private:
301+
SCreationParams m_creationParams;
277302
};
278303

279304
public:

src/nbl/asset/interchange/IAssetLoader.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ using namespace nbl::core;
1010
using namespace nbl::asset;
1111

1212
// todo NEED DOCS
13-
IAssetLoader::IAssetLoaderOverride::IAssetLoaderOverride(IAssetManager* _manager) : m_manager(_manager), m_system(m_manager->getSystem())
13+
IAssetLoader::IAssetLoaderOverride::IAssetLoaderOverride(SCreationParams&& params) : m_creationParams(std::move(params))
1414
{
1515
}
1616

@@ -20,19 +20,19 @@ SAssetBundle IAssetLoader::IAssetLoaderOverride::findCachedAsset(const std::stri
2020
if ((levelFlag & ECF_DUPLICATE_TOP_LEVEL) == ECF_DUPLICATE_TOP_LEVEL)
2121
return {};
2222

23-
auto found = m_manager->findAssets(inSearchKey, inAssetTypes);
23+
auto found = getManager()->findAssets(inSearchKey, inAssetTypes);
2424
if (!found->size())
2525
return handleSearchFail(inSearchKey, ctx, hierarchyLevel);
2626
return chooseRelevantFromFound(found->begin(), found->end(), ctx, hierarchyLevel);
2727
}
2828

2929
void IAssetLoader::IAssetLoaderOverride::insertAssetIntoCache(SAssetBundle& asset, const std::string& supposedKey, const SAssetLoadParams& _params, const uint32_t hierarchyLevel)
3030
{
31-
m_manager->changeAssetKey(asset, supposedKey);
31+
getManager()->changeAssetKey(asset, supposedKey);
3232

3333
auto levelFlag = _params.cacheFlags >> (uint64_t(hierarchyLevel) * 2ull);
3434
if (!(levelFlag&ECF_DONT_CACHE_TOP_LEVEL))
35-
m_manager->insertAssetIntoCache(asset,ASSET_MUTABILITY_ON_CACHE_INSERT);
35+
getManager()->insertAssetIntoCache(asset,ASSET_MUTABILITY_ON_CACHE_INSERT);
3636
}
3737

3838
SAssetBundle IAssetLoader::interm_getAssetInHierarchy(system::IFile* _file, const std::string& _supposedFilename, const IAssetLoader::SAssetLoadParams& _params, uint32_t _hierarchyLevel, IAssetLoader::IAssetLoaderOverride* _override)

0 commit comments

Comments
 (0)