chore: load indirectly referenced assets if they are not ignored

This commit is contained in:
Jan
2024-02-06 23:56:05 +01:00
parent ac0d8a83a0
commit 0a13281295
7 changed files with 130 additions and 2 deletions

View File

@ -11,6 +11,24 @@ IndirectAssetReference::IndirectAssetReference(const asset_type_t type, std::str
{
}
bool operator==(const IndirectAssetReference& lhs, const IndirectAssetReference& rhs)
{
return lhs.m_type == rhs.m_type && lhs.m_name == rhs.m_name;
}
bool operator!=(const IndirectAssetReference& lhs, const IndirectAssetReference& rhs)
{
return !(lhs == rhs);
}
std::size_t std::hash<IndirectAssetReference>::operator()(const IndirectAssetReference& v) const noexcept
{
std::size_t seed = 0x01A627D3;
seed ^= (seed << 6) + (seed >> 2) + 0x0BCEF9CE + static_cast<std::size_t>(v.m_type);
seed ^= (seed << 6) + (seed >> 2) + 0x7225148B + std::hash<std::string>()(v.m_name);
return seed;
}
XAssetInfoGeneric::XAssetInfoGeneric()
: m_type(-1),
m_ptr(nullptr),
@ -37,6 +55,22 @@ XAssetInfoGeneric::XAssetInfoGeneric(
{
}
XAssetInfoGeneric::XAssetInfoGeneric(asset_type_t type,
std::string name,
void* ptr,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences)
: m_type(type),
m_name(std::move(name)),
m_ptr(ptr),
m_dependencies(std::move(dependencies)),
m_used_script_strings(std::move(usedScriptStrings)),
m_indirect_asset_references(std::move(indirectAssetReferences)),
m_zone(nullptr)
{
}
XAssetInfoGeneric::XAssetInfoGeneric(const asset_type_t type,
std::string name,
void* ptr,

View File

@ -17,6 +17,14 @@ public:
IndirectAssetReference();
IndirectAssetReference(asset_type_t type, std::string name);
friend bool operator==(const IndirectAssetReference& lhs, const IndirectAssetReference& rhs);
friend bool operator!=(const IndirectAssetReference& lhs, const IndirectAssetReference& rhs);
};
template<> struct std::hash<IndirectAssetReference>
{
std::size_t operator()(const IndirectAssetReference& v) const noexcept;
};
class XAssetInfoGeneric
@ -34,6 +42,12 @@ public:
XAssetInfoGeneric(asset_type_t type, std::string name, void* ptr);
XAssetInfoGeneric(
asset_type_t type, std::string name, void* ptr, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings);
XAssetInfoGeneric(asset_type_t type,
std::string name,
void* ptr,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences);
XAssetInfoGeneric(asset_type_t type,
std::string name,
void* ptr,
@ -64,6 +78,17 @@ public:
{
}
XAssetInfo(const asset_type_t type,
std::string name,
T* ptr,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences)
: XAssetInfoGeneric(
type, std::move(name), static_cast<void*>(ptr), std::move(dependencies), std::move(usedScriptStrings), std::move(indirectAssetReferences))
{
}
XAssetInfo(const asset_type_t type,
std::string name,
T* ptr,