mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-06-06 16:52:35 +00:00
refactor: streamline material dumping
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AssetDumpingContext.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Obj/Gdt/GdtStream.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
void DecompileMaterialToGdt(GdtOutputStream& out, const Material& material, AssetDumpingContext& context);
|
||||
} // namespace IW4
|
||||
@@ -1,38 +0,0 @@
|
||||
#include "DumperMaterialIW4.h"
|
||||
|
||||
#include "DecompilingMaterialDumperIW4.h"
|
||||
#include "Game/IW4/Material/JsonMaterialWriterIW4.h"
|
||||
#include "Game/IW4/Material/MaterialConstantZoneStateIW4.h"
|
||||
#include "Material/MaterialCommon.h"
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void AssetDumperMaterial::DumpPool(AssetDumpingContext& context, AssetPool<Material>* pool)
|
||||
{
|
||||
auto* materialConstantState = context.GetZoneAssetDumperState<MaterialConstantZoneState>();
|
||||
materialConstantState->ExtractNamesFromZone();
|
||||
|
||||
AbstractAssetDumper::DumpPool(context, pool);
|
||||
}
|
||||
|
||||
bool AssetDumperMaterial::ShouldDump(XAssetInfo<Material>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo<Material>* asset)
|
||||
{
|
||||
#ifdef EXPERIMENTAL_MATERIAL_COMPILATION
|
||||
if (context.m_gdt)
|
||||
{
|
||||
DecompileMaterialToGdt(*context.m_gdt, *asset->Asset(), context);
|
||||
}
|
||||
#else
|
||||
const auto assetFile = context.OpenAssetFile(material::GetFileNameForAssetName(asset->m_name));
|
||||
|
||||
if (!assetFile)
|
||||
return;
|
||||
|
||||
DumpMaterialAsJson(*assetFile, *asset->Asset(), context);
|
||||
#endif
|
||||
}
|
||||
+14
-6
@@ -1,4 +1,4 @@
|
||||
#include "DecompilingMaterialDumperIW4.h"
|
||||
#include "MaterialDecompilingDumperIW4.h"
|
||||
|
||||
#include "Game/IW4/MaterialConstantsIW4.h"
|
||||
#include "Game/IW4/ObjConstantsIW4.h"
|
||||
@@ -1108,11 +1108,19 @@ namespace
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::material
|
||||
{
|
||||
void DecompileMaterialToGdt(GdtOutputStream& out, const Material& material, AssetDumpingContext& context)
|
||||
bool DecompilingGdtDumper::ShouldDump(XAssetInfo<Material>* asset)
|
||||
{
|
||||
MaterialGdtDumper dumper(material);
|
||||
out.WriteEntry(dumper.CreateGdtEntry());
|
||||
return true;
|
||||
}
|
||||
} // namespace IW4
|
||||
|
||||
void DecompilingGdtDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<Material>* asset)
|
||||
{
|
||||
if (!context.m_gdt)
|
||||
return;
|
||||
|
||||
MaterialGdtDumper dumper(*asset->Asset());
|
||||
context.m_gdt->WriteEntry(dumper.CreateGdtEntry());
|
||||
}
|
||||
} // namespace IW4::material
|
||||
+3
-6
@@ -3,15 +3,12 @@
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::material
|
||||
{
|
||||
class AssetDumperMaterial final : public AbstractAssetDumper<Material>
|
||||
class DecompilingGdtDumper final : public AbstractAssetDumper<Material>
|
||||
{
|
||||
public:
|
||||
void DumpPool(AssetDumpingContext& context, AssetPool<Material>* pool) override;
|
||||
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<Material>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<Material>* asset) override;
|
||||
};
|
||||
} // namespace IW4
|
||||
} // namespace IW4::material
|
||||
Reference in New Issue
Block a user