chore: make marker reusable with visitor pattern

This commit is contained in:
Jan Laupetin
2025-12-23 15:40:51 +01:00
parent c73b2ed838
commit 0ef4979873
7 changed files with 188 additions and 131 deletions
@@ -146,6 +146,8 @@ namespace
LINEF("#include \"{0}_load_db.h\"", Lower(m_env.m_asset->m_definition->m_name))
LINE("")
LINEF("#include \"{0}_mark_db.h\"", Lower(m_env.m_asset->m_definition->m_name))
LINE("")
LINE("#include \"Loading/AssetInfoCollector.h\"")
if (!m_env.m_referenced_assets.empty())
{
@@ -2155,14 +2157,16 @@ namespace
LINE("assert(pAsset != nullptr);")
LINE("")
LINEF("{0} marker(m_zone);", MarkerClassName(m_env.m_asset))
LINE("AssetInfoCollector assetInfo(m_zone);")
LINEF("{0} marker(assetInfo);", MarkerClassName(m_env.m_asset))
LINE("marker.Mark(*pAsset);")
LINE("")
LINEF("auto* reallocatedAsset = m_zone.Memory().Alloc<{0}>();", info->m_definition->GetFullName())
LINEF("std::memcpy(reallocatedAsset, *pAsset, sizeof({0}));", info->m_definition->GetFullName())
LINE("")
LINEF("m_asset_info = reinterpret_cast<XAssetInfo<{0}>*>(LinkAsset(AssetNameAccessor<{1}>()(**pAsset), reallocatedAsset, marker.GetDependencies(), "
"marker.GetUsedScriptStrings(), marker.GetIndirectAssetReferences()));",
LINEF("m_asset_info = reinterpret_cast<XAssetInfo<{0}>*>(LinkAsset(AssetNameAccessor<{1}>()(**pAsset), reallocatedAsset, "
"assetInfo.GetDependencies(), "
"assetInfo.GetUsedScriptStrings(), assetInfo.GetIndirectAssetReferences()));",
info->m_definition->GetFullName(),
info->m_asset_name)
LINE("*pAsset = m_asset_info->Asset();")