2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-01-11 03:01:49 +00:00

refactor: streamline techset dumper

This commit is contained in:
Jan Laupetin
2025-07-30 23:22:18 +01:00
parent e26c66ed60
commit ea1c232164
13 changed files with 216 additions and 180 deletions

View File

@@ -21,7 +21,7 @@
#include "Sound/AssetDumperSndCurve.h"
#include "StringTable/StringTableDumperIW4.h"
#include "StructuredDataDef/AssetDumperStructuredDataDefSet.h"
#include "Techset/AssetDumperTechniqueSet.h"
#include "Techset/TechsetDumperIW4.h"
#include "Tracer/AssetDumperTracer.h"
#include "Vehicle/AssetDumperVehicle.h"
#include "Weapon/AssetDumperWeapon.h"
@@ -49,7 +49,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
#endif
DUMP_ASSET_POOL(AssetDumperPixelShader, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER)
DUMP_ASSET_POOL(AssetDumperVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER)
DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET)
DUMP_ASSET_POOL(techset::Dumper, m_technique_set, ASSET_TYPE_TECHNIQUE_SET)
DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE)
// DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND)
DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE)

View File

@@ -1,17 +0,0 @@
#pragma once
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
namespace IW4
{
class AssetDumperTechniqueSet final : public AbstractAssetDumper<MaterialTechniqueSet>
{
static std::string GetTechniqueFileName(const MaterialTechnique* technique);
static std::string GetTechsetFileName(const MaterialTechniqueSet* techset);
protected:
bool ShouldDump(XAssetInfo<MaterialTechniqueSet>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialTechniqueSet>* asset) override;
};
} // namespace IW4

View File

@@ -1,9 +1,10 @@
#include "AssetDumperTechniqueSet.h"
#include "TechsetDumperIW4.h"
#include "Dumping/AbstractTextDumper.h"
#include "Game/IW4/TechsetConstantsIW4.h"
#include "Pool/GlobalAssetPool.h"
#include "Shader/D3D9ShaderAnalyser.h"
#include "Techset/TechsetCommon.h"
#include <algorithm>
#include <cassert>
@@ -12,6 +13,7 @@
#include <type_traits>
using namespace IW4;
using namespace ::techset;
namespace IW4
{
@@ -531,48 +533,37 @@ namespace IW4
};
} // namespace IW4
std::string AssetDumperTechniqueSet::GetTechniqueFileName(const MaterialTechnique* technique)
namespace IW4::techset
{
std::ostringstream ss;
ss << "techniques/" << technique->name << ".tech";
return ss.str();
}
std::string AssetDumperTechniqueSet::GetTechsetFileName(const MaterialTechniqueSet* techset)
{
std::ostringstream ss;
ss << "techsets/" << techset->name << ".techset";
return ss.str();
}
bool AssetDumperTechniqueSet::ShouldDump(XAssetInfo<MaterialTechniqueSet>* asset)
{
return true;
}
void AssetDumperTechniqueSet::DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialTechniqueSet>* asset)
{
const auto* techset = asset->Asset();
const auto techsetFile = context.OpenAssetFile(GetTechsetFileName(techset));
if (techsetFile)
bool Dumper::ShouldDump(XAssetInfo<MaterialTechniqueSet>* asset)
{
TechsetFileWriter writer(*techsetFile);
writer.DumpTechset(techset);
return true;
}
auto* techniqueState = context.GetZoneAssetDumperState<TechniqueDumpingZoneState>();
for (const auto* technique : techset->techniques)
void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialTechniqueSet>* asset)
{
if (technique && techniqueState->ShouldDumpTechnique(technique))
const auto* techset = asset->Asset();
const auto techsetFile = context.OpenAssetFile(GetFileNameForTechsetName(techset->name));
if (techsetFile)
{
const auto techniqueFile = context.OpenAssetFile(GetTechniqueFileName(technique));
if (techniqueFile)
TechsetFileWriter writer(*techsetFile);
writer.DumpTechset(techset);
}
auto* techniqueState = context.GetZoneAssetDumperState<TechniqueDumpingZoneState>();
for (const auto* technique : techset->techniques)
{
if (technique && techniqueState->ShouldDumpTechnique(technique))
{
TechniqueFileWriter writer(*techniqueFile);
writer.DumpTechnique(technique);
const auto techniqueFile = context.OpenAssetFile(GetFileNameForTechniqueName(technique->name));
if (techniqueFile)
{
TechniqueFileWriter writer(*techniqueFile);
writer.DumpTechnique(technique);
}
}
}
}
}
} // namespace IW4::techset

View File

@@ -0,0 +1,14 @@
#pragma once
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
namespace IW4::techset
{
class Dumper final : public AbstractAssetDumper<MaterialTechniqueSet>
{
protected:
bool ShouldDump(XAssetInfo<MaterialTechniqueSet>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialTechniqueSet>* asset) override;
};
} // namespace IW4::techset