Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
ModelAssetManager.cpp
Go to the documentation of this file.
1#include <utility>
2
4
5namespace EngineCore {
6 ModelAsset::ModelAsset(std::filesystem::path path) : path(std::move(path)) {
7
8 }
9
11 TRACY_ZONE_SCOPED_NAMED( "Registering created asset" );
12 assetsFromPath.push_back(asset);
13 }
14
16 {
17 AssetBase::unload();
18 path = "";
19 assetsFromPath.clear();
20 model.reset();
21 }
22
24 {
25 // If we have no sub-assets registered yet, check if we're in a loading state
26 if (assetsFromPath.empty())
27 {
28 // If loadingState is already REQUESTED_LOAD or LOADING, keep it
29 // Otherwise it's UNLOADED
30 return;
31 }
32
33 // Check if all registered sub-assets are loaded
34 bool allLoaded = true;
35 for (const auto* asset : assetsFromPath)
36 {
37 if (asset == nullptr)
38 {
39 allLoaded = false;
40 break;
41 }
42 // Note: We need to cast away const to call getLoadingState() which may update internal state
43 auto* mutableAsset = const_cast<Asset::AssetBase*>(asset);
44 if (mutableAsset->getLoadingState() != Asset::CpuLoadingState::LOADED)
45 {
46 allLoaded = false;
47 break;
48 }
49 }
50
51 if (allLoaded)
52 {
54 }
56 {
58 }
59 }
60
64}
#define TRACY_ZONE_SCOPED_NAMED(name)
Base class for asset wrappers. The data is stored in the private member variable 'data' in form of en...
Definition Asset.h:50
CpuLoadingState loadingState
Definition Asset.h:95
ModelAsset(std::filesystem::path path)
void registerCreatedAssetWithModel(Asset::AssetBase *asset)
Registers an asset like a texture or 3d model with this gltf model.
std::optional< tinygltf::Model > model
void unload() override
Unload overwrite which empties out the model data.
void updateLoadingState() override
Updates the loading state based on whether all registered sub-assets are loaded.
std::filesystem::path path
std::vector< Asset::AssetBase * > assetsFromPath
@ LOADED
All components of the asset have been loaded, and it is ready to be used.
Definition Asset.h:39
@ LOADING
While the asset is currently being processed in the asset pipeline.
Definition Asset.h:35
@ UNLOADED
When the asset is not loaded yet but the frame is already existing for the heavy data to be loaded in...
Definition Asset.h:26
Log category system implementation.
STL namespace.