Refactor AssetsContainer

This commit is contained in:
Wojtek Figat
2021-02-26 15:40:44 +01:00
parent e1497bcfe2
commit 327fa6718e
9 changed files with 11 additions and 15 deletions

View File

@@ -193,7 +193,7 @@ public:
FORCE_INLINE AssetReference& operator=(const Guid& id) FORCE_INLINE AssetReference& operator=(const Guid& id)
{ {
OnSet((T*)LoadAsset(id, T::TypeInitializer)); OnSet((T*)::LoadAsset(id, T::TypeInitializer));
return *this; return *this;
} }

View File

@@ -3,6 +3,7 @@
#include "VisualScript.h" #include "VisualScript.h"
#include "Engine/Core/Log.h" #include "Engine/Core/Log.h"
#include "Engine/Core/Types/DataContainer.h" #include "Engine/Core/Types/DataContainer.h"
#include "Engine/Content/Content.h"
#include "Engine/Content/Factories/BinaryAssetFactory.h" #include "Engine/Content/Factories/BinaryAssetFactory.h"
#include "Engine/Scripting/MException.h" #include "Engine/Scripting/MException.h"
#include "Engine/Scripting/Scripting.h" #include "Engine/Scripting/Scripting.h"

View File

@@ -2,10 +2,9 @@
#pragma once #pragma once
#include "Engine/Content/Content.h"
#include "Engine/Core/Collections/Array.h" #include "Engine/Core/Collections/Array.h"
#include "Engine/Content/AssetReference.h" #include "Engine/Content/AssetReference.h"
#include "../Asset.h" #include "Asset.h"
/// <summary> /// <summary>
/// Assets Container allows to load collection of assets and keep references to them. /// Assets Container allows to load collection of assets and keep references to them.
@@ -27,13 +26,9 @@ public:
if (e.GetID() == id) if (e.GetID() == id)
return (T*)e.Get(); return (T*)e.Get();
} }
auto asset = (T*)::LoadAsset(id, T::TypeInitializer);
auto asset = Content::LoadAsync<T>(id);
if (asset) if (asset)
{
Add(asset); Add(asset);
}
return asset; return asset;
} }

View File

@@ -158,7 +158,7 @@ public:
FORCE_INLINE WeakAssetReference& operator=(const Guid& id) FORCE_INLINE WeakAssetReference& operator=(const Guid& id)
{ {
OnSet((T*)LoadAsset(id, T::TypeInitializer)); OnSet((T*)::LoadAsset(id, T::TypeInitializer));
return *this; return *this;
} }

View File

@@ -271,7 +271,7 @@ void MaterialGenerator::prepareLayer(MaterialLayer* layer, bool allowVisiblePara
mp.Type = MaterialParameterType::Texture; mp.Type = MaterialParameterType::Texture;
// Special case for Normal Maps // Special case for Normal Maps
auto asset = Content::LoadAsync<Texture>((Guid)param->Value); auto asset = (Texture*)::LoadAsset((Guid)param->Value, Texture::TypeInitializer);
if (asset && !asset->WaitForLoaded() && asset->IsNormalMap()) if (asset && !asset->WaitForLoaded() && asset->IsNormalMap())
mp.Type = MaterialParameterType::NormalMap; mp.Type = MaterialParameterType::NormalMap;
} }

View File

@@ -6,7 +6,7 @@
#include "Engine/Graphics/Materials/MaterialInfo.h" #include "Engine/Graphics/Materials/MaterialInfo.h"
#include "Engine/Graphics/Materials/MaterialParams.h" #include "Engine/Graphics/Materials/MaterialParams.h"
#include "Engine/Content/Utilities/AssetsContainer.h" #include "Engine/Content/AssetsContainer.h"
#include "MaterialLayer.h" #include "MaterialLayer.h"
#include "Types.h" #include "Types.h"

View File

@@ -10,7 +10,7 @@
#include "Engine/Core/Collections/HashSet.h" #include "Engine/Core/Collections/HashSet.h"
#include "Engine/Utilities/TextWriter.h" #include "Engine/Utilities/TextWriter.h"
#include "Engine/Graphics/Materials/MaterialParams.h" #include "Engine/Graphics/Materials/MaterialParams.h"
#include "Engine/Content/Utilities/AssetsContainer.h" #include "Engine/Content/AssetsContainer.h"
#include "Engine/Animations/Curve.h" #include "Engine/Animations/Curve.h"
#define SHADER_GRAPH_MAX_CALL_STACK 100 #define SHADER_GRAPH_MAX_CALL_STACK 100

View File

@@ -723,7 +723,7 @@ void VisjectExecutor::ProcessGroupTools(Box* box, Node* node, Value& value)
// Asset Reference // Asset Reference
case 18: case 18:
{ {
value = Content::LoadAsync<Asset>((Guid)node->Values[0]); value = ::LoadAsset((Guid)node->Values[0], Asset::TypeInitializer);
break; break;
} }
// To String // To String

View File

@@ -8,7 +8,7 @@
#include "Engine/Core/Math/Vector4.h" #include "Engine/Core/Math/Vector4.h"
#include "Engine/Content/Asset.h" #include "Engine/Content/Asset.h"
#include "Engine/Content/AssetReference.h" #include "Engine/Content/AssetReference.h"
#include "Engine/Content/Utilities/AssetsContainer.h" #include "Engine/Content/AssetsContainer.h"
#include "Engine/Animations/Curve.h" #include "Engine/Animations/Curve.h"
#define VISJECT_GRAPH_NODE_MAX_ASSETS 14 #define VISJECT_GRAPH_NODE_MAX_ASSETS 14
@@ -204,7 +204,7 @@ public:
// Get Gameplay Global // Get Gameplay Global
case 16: case 16:
{ {
n->Assets[0] = Content::LoadAsync<Asset>((Guid)n->Values[0]); n->Assets[0] = ::LoadAsset((Guid)n->Values[0], Asset::TypeInitializer);
break; break;
} }
} }