refactor: image and obj data loading

This commit is contained in:
Jan
2024-09-24 12:01:42 +01:00
parent 5fee875495
commit 5cc52c42cd
97 changed files with 1784 additions and 1878 deletions

View File

@ -79,7 +79,7 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
context.m_ignored_assets.m_entries.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name, assetEntry.m_is_reference);
}
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(zone.get(), context.m_asset_search_path, CreateGdtList(context));
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(*zone, *context.m_asset_search_path, CreateGdtList(context));
if (!CreateIgnoredAssetMap(context, assetLoadingContext->m_ignored_asset_map))
return nullptr;
@ -92,11 +92,11 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
return nullptr;
}
if (!ObjLoading::LoadAssetForZone(assetLoadingContext.get(), foundAssetTypeEntry->second, assetEntry.m_asset_name))
if (!ObjLoading::LoadAssetForZone(*assetLoadingContext, foundAssetTypeEntry->second, assetEntry.m_asset_name))
return nullptr;
}
ObjLoading::FinalizeAssetsForZone(assetLoadingContext.get());
ObjLoading::FinalizeAssetsForZone(*assetLoadingContext);
return zone;
}

View File

@ -78,7 +78,7 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
context.m_ignored_assets.m_entries.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name, assetEntry.m_is_reference);
}
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(zone.get(), context.m_asset_search_path, CreateGdtList(context));
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(*zone, *context.m_asset_search_path, CreateGdtList(context));
if (!CreateIgnoredAssetMap(context, assetLoadingContext->m_ignored_asset_map))
return nullptr;
@ -91,11 +91,11 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
return nullptr;
}
if (!ObjLoading::LoadAssetForZone(assetLoadingContext.get(), foundAssetTypeEntry->second, assetEntry.m_asset_name))
if (!ObjLoading::LoadAssetForZone(*assetLoadingContext, foundAssetTypeEntry->second, assetEntry.m_asset_name))
return nullptr;
}
ObjLoading::FinalizeAssetsForZone(assetLoadingContext.get());
ObjLoading::FinalizeAssetsForZone(*assetLoadingContext);
return zone;
}

View File

@ -78,7 +78,7 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
context.m_ignored_assets.m_entries.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name, assetEntry.m_is_reference);
}
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(zone.get(), context.m_asset_search_path, CreateGdtList(context));
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(*zone, *context.m_asset_search_path, CreateGdtList(context));
if (!CreateIgnoredAssetMap(context, assetLoadingContext->m_ignored_asset_map))
return nullptr;
@ -91,11 +91,11 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
return nullptr;
}
if (!ObjLoading::LoadAssetForZone(assetLoadingContext.get(), foundAssetTypeEntry->second, assetEntry.m_asset_name))
if (!ObjLoading::LoadAssetForZone(*assetLoadingContext, foundAssetTypeEntry->second, assetEntry.m_asset_name))
return nullptr;
}
ObjLoading::FinalizeAssetsForZone(assetLoadingContext.get());
ObjLoading::FinalizeAssetsForZone(*assetLoadingContext);
return zone;
}

View File

@ -79,7 +79,7 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
context.m_ignored_assets.m_entries.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name, assetEntry.m_is_reference);
}
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(zone.get(), context.m_asset_search_path, CreateGdtList(context));
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(*zone, *context.m_asset_search_path, CreateGdtList(context));
if (!CreateIgnoredAssetMap(context, assetLoadingContext->m_ignored_asset_map))
return nullptr;
@ -92,11 +92,11 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
return nullptr;
}
if (!ObjLoading::LoadAssetForZone(assetLoadingContext.get(), foundAssetTypeEntry->second, assetEntry.m_asset_name))
if (!ObjLoading::LoadAssetForZone(*assetLoadingContext, foundAssetTypeEntry->second, assetEntry.m_asset_name))
return nullptr;
}
ObjLoading::FinalizeAssetsForZone(assetLoadingContext.get());
ObjLoading::FinalizeAssetsForZone(*assetLoadingContext);
return zone;
}

View File

@ -128,7 +128,7 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
context.m_ignored_assets.m_entries.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name, assetEntry.m_is_reference);
}
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(zone.get(), context.m_asset_search_path, CreateGdtList(context));
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(*zone, *context.m_asset_search_path, CreateGdtList(context));
if (!CreateIgnoredAssetMap(context, assetLoadingContext->m_ignored_asset_map))
return nullptr;
@ -143,11 +143,11 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
return nullptr;
}
if (!ObjLoading::LoadAssetForZone(assetLoadingContext.get(), foundAssetTypeEntry->second, assetEntry.m_asset_name))
if (!ObjLoading::LoadAssetForZone(*assetLoadingContext, foundAssetTypeEntry->second, assetEntry.m_asset_name))
return nullptr;
}
ObjLoading::FinalizeAssetsForZone(assetLoadingContext.get());
ObjLoading::FinalizeAssetsForZone(*assetLoadingContext);
return zone;
}

View File

@ -5,6 +5,7 @@
#include "SearchPath/SearchPathFilesystem.h"
#include <filesystem>
#include <format>
#include <iostream>
namespace fs = std::filesystem;
@ -14,21 +15,21 @@ LinkerSearchPaths::LinkerSearchPaths(const LinkerArgs& args)
{
}
void LinkerSearchPaths::LoadSearchPath(ISearchPath* searchPath) const
void LinkerSearchPaths::LoadSearchPath(ISearchPath& searchPath) const
{
if (m_args.m_verbose)
{
printf("Loading search path: \"%s\"\n", searchPath->GetPath().c_str());
std::cout << std::format("Loading search path: \"{}\"\n", searchPath.GetPath());
}
ObjLoading::LoadIWDsInSearchPath(searchPath);
}
void LinkerSearchPaths::UnloadSearchPath(ISearchPath* searchPath) const
void LinkerSearchPaths::UnloadSearchPath(ISearchPath& searchPath) const
{
if (m_args.m_verbose)
{
printf("Unloading search path: \"%s\"\n", searchPath->GetPath().c_str());
std::cout << std::format("Unloading search path: \"{}\"\n", searchPath.GetPath());
}
ObjLoading::UnloadIWDsInSearchPath(searchPath);
@ -45,15 +46,15 @@ SearchPaths LinkerSearchPaths::GetAssetSearchPathsForProject(const std::string&
if (!fs::is_directory(absolutePath))
{
if (m_args.m_verbose)
std::cout << "Adding asset search path (Not found): " << absolutePath.string() << "\n";
std::cout << std::format("Adding asset search path (Not found): {}\n", absolutePath.string());
continue;
}
if (m_args.m_verbose)
std::cout << "Adding asset search path: " << absolutePath.string() << "\n";
std::cout << std::format("Adding asset search path: {}\n", absolutePath.string());
auto searchPath = std::make_unique<SearchPathFilesystem>(searchPathStr);
LoadSearchPath(searchPath.get());
LoadSearchPath(*searchPath);
searchPathsForProject.IncludeSearchPath(searchPath.get());
m_loaded_project_search_paths.emplace_back(std::move(searchPath));
}
@ -79,12 +80,12 @@ SearchPaths LinkerSearchPaths::GetGdtSearchPathsForProject(const std::string& ga
if (!fs::is_directory(absolutePath))
{
if (m_args.m_verbose)
std::cout << "Adding gdt search path (Not found): " << absolutePath.string() << "\n";
std::cout << std::format("Adding gdt search path (Not found): {}\n", absolutePath.string());
continue;
}
if (m_args.m_verbose)
std::cout << "Adding gdt search path: " << absolutePath.string() << "\n";
std::cout << std::format("Adding gdt search path: {}\n", absolutePath.string());
searchPathsForProject.CommitSearchPath(std::make_unique<SearchPathFilesystem>(searchPathStr));
}
@ -105,12 +106,12 @@ SearchPaths LinkerSearchPaths::GetSourceSearchPathsForProject(const std::string&
if (!fs::is_directory(absolutePath))
{
if (m_args.m_verbose)
std::cout << "Adding source search path (Not found): " << absolutePath.string() << "\n";
std::cout << std::format("Adding source search path (Not found): {}\n", absolutePath.string());
continue;
}
if (m_args.m_verbose)
std::cout << "Adding source search path: " << absolutePath.string() << "\n";
std::cout << std::format("Adding source search path: {}\n", absolutePath.string());
searchPathsForProject.CommitSearchPath(std::make_unique<SearchPathFilesystem>(searchPathStr));
}
@ -129,15 +130,15 @@ bool LinkerSearchPaths::BuildProjectIndependentSearchPaths()
if (!fs::is_directory(absolutePath))
{
if (m_args.m_verbose)
std::cout << "Adding asset search path (Not found): " << absolutePath.string() << "\n";
std::cout << std::format("Adding asset search path (Not found): {}\n", absolutePath.string());
continue;
}
if (m_args.m_verbose)
std::cout << "Adding asset search path: " << absolutePath.string() << "\n";
std::cout << std::format("Adding asset search path: {}\n", absolutePath.string());
auto searchPath = std::make_unique<SearchPathFilesystem>(absolutePath.string());
LoadSearchPath(searchPath.get());
LoadSearchPath(*searchPath);
m_asset_search_paths.CommitSearchPath(std::move(searchPath));
}
@ -148,12 +149,12 @@ bool LinkerSearchPaths::BuildProjectIndependentSearchPaths()
if (!fs::is_directory(absolutePath))
{
if (m_args.m_verbose)
std::cout << "Loading gdt search path (Not found): " << absolutePath.string() << "\n";
std::cout << std::format("Loading gdt search path (Not found): {}\n", absolutePath.string());
continue;
}
if (m_args.m_verbose)
std::cout << "Adding gdt search path: " << absolutePath.string() << "\n";
std::cout << std::format("Adding gdt search path: {}\n", absolutePath.string());
m_gdt_search_paths.CommitSearchPath(std::make_unique<SearchPathFilesystem>(absolutePath.string()));
}
@ -165,12 +166,12 @@ bool LinkerSearchPaths::BuildProjectIndependentSearchPaths()
if (!fs::is_directory(absolutePath))
{
if (m_args.m_verbose)
std::cout << "Loading source search path (Not found): " << absolutePath.string() << "\n";
std::cout << std::format("Loading source search path (Not found): {}\n", absolutePath.string());
continue;
}
if (m_args.m_verbose)
std::cout << "Adding source search path: " << absolutePath.string() << "\n";
std::cout << std::format("Adding source search path: {}\n", absolutePath.string());
m_source_search_paths.CommitSearchPath(std::make_unique<SearchPathFilesystem>(absolutePath.string()));
}
@ -182,7 +183,7 @@ void LinkerSearchPaths::UnloadProjectSpecificSearchPaths()
{
for (const auto& loadedSearchPath : m_loaded_project_search_paths)
{
UnloadSearchPath(loadedSearchPath.get());
UnloadSearchPath(*loadedSearchPath);
}
m_loaded_project_search_paths.clear();

View File

@ -14,13 +14,13 @@ public:
* \brief Loads a search path.
* \param searchPath The search path to load.
*/
void LoadSearchPath(ISearchPath* searchPath) const;
void LoadSearchPath(ISearchPath& searchPath) const;
/**
* \brief Unloads a search path.
* \param searchPath The search path to unload.
*/
void UnloadSearchPath(ISearchPath* searchPath) const;
void UnloadSearchPath(ISearchPath& searchPath) const;
SearchPaths GetAssetSearchPathsForProject(const std::string& gameName, const std::string& projectName);