From dbe5cffb2f9a03e6a9e53d24ae864fb07b11f57d Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Sat, 7 Mar 2026 10:02:39 +0000 Subject: [PATCH] feat: use templated techset compiler for IW4 --- src/Common/Game/IW4/IW4.h | 2 ++ src/ObjCompiling/Game/IW4/ObjCompilerIW4.cpp | 4 ++-- src/ObjCompiling/Techset/TechsetCompiler.cpp.template | 8 +++++++- src/ObjCompiling/Techset/TechsetCompiler.h.template | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Common/Game/IW4/IW4.h b/src/Common/Game/IW4/IW4.h index ac7400b2..d30ba9aa 100644 --- a/src/Common/Game/IW4/IW4.h +++ b/src/Common/Game/IW4/IW4.h @@ -223,6 +223,8 @@ namespace IW4 using AssetTracer = Asset; using AssetVehicle = Asset; using AssetAddonMapEnts = Asset; + + using SubAssetTechnique = SubAsset; } // namespace IW4 DEFINE_ASSET_NAME_ACCESSOR(IW4::AssetPhysPreset, name); diff --git a/src/ObjCompiling/Game/IW4/ObjCompilerIW4.cpp b/src/ObjCompiling/Game/IW4/ObjCompilerIW4.cpp index 66f326d3..79a9723a 100644 --- a/src/ObjCompiling/Game/IW4/ObjCompilerIW4.cpp +++ b/src/ObjCompiling/Game/IW4/ObjCompilerIW4.cpp @@ -1,10 +1,10 @@ #include "ObjCompilerIW4.h" #include "Game/IW4/IW4.h" +#include "Game/IW4/Techset/TechsetCompilerIW4.h" #include "Game/IW4/Techset/VertexDeclCompilerIW4.h" #include "Image/ImageIwdPostProcessor.h" #include "Material/CompilerMaterialIW4.h" -#include "Techset/CompilerTechsetIW4.h" #include @@ -18,9 +18,9 @@ namespace #ifdef EXPERIMENTAL_MATERIAL_COMPILATION collection.AddAssetCreator(material::CreateCompilerIW4(memory, searchPath, gdt)); - collection.AddAssetCreator(techset::CreateLoaderIW4(memory, searchPath)); #endif collection.AddAssetCreator(techset::CreateVertexDeclCompilerIW4(memory)); + collection.AddAssetCreator(techset::CreateTechsetCompilerIW4(memory, searchPath)); } void ConfigurePostProcessors(AssetCreatorCollection& collection, diff --git a/src/ObjCompiling/Techset/TechsetCompiler.cpp.template b/src/ObjCompiling/Techset/TechsetCompiler.cpp.template index b005610b..38a4890f 100644 --- a/src/ObjCompiling/Techset/TechsetCompiler.cpp.template +++ b/src/ObjCompiling/Techset/TechsetCompiler.cpp.template @@ -1,4 +1,4 @@ -#options GAME(T6) +#options GAME(IW4, T6) #filename "Game/" + GAME + "/Techset/TechsetCompiler" + GAME + ".cpp" @@ -69,6 +69,7 @@ namespace return static_cast(0); } +#if defined(FEATURE_T6) MaterialType GetMaterialType(const std::string& name) { for (unsigned materialTypeIndex = MTL_TYPE_MODEL; materialTypeIndex < MTL_TYPE_COUNT; materialTypeIndex++) @@ -87,6 +88,7 @@ namespace technique.passArray[passIndex].materialType = materialType; } } +#endif MaterialTechniqueSet* ConvertTechniqueSet(const techset::CommonTechset& commonTechset, MemoryManager& memory) { @@ -114,7 +116,9 @@ namespace return failure ? AssetCreationResult::Failure() : AssetCreationResult::NoAction(); auto* techset = ConvertTechniqueSet(*commonTechset, m_memory); +#if defined(FEATURE_T6) const auto materialType = GetMaterialType(assetName); +#endif for (auto techniqueIndex = 0u; techniqueIndex < std::extent_v; techniqueIndex++) { @@ -128,10 +132,12 @@ namespace techset->techniques[techniqueIndex] = technique->Asset(); +#if defined(FEATURE_T6) // Another techset may override this for the technique // but the game determines the material type by techset name. // So this may just be a constraint that cannot be changed. ApplyMaterialTypeToTechnique(*techset->techniques[techniqueIndex], materialType); +#endif } return AssetCreationResult::Success(context.AddAsset(AssetRegistration(assetName, techset))); diff --git a/src/ObjCompiling/Techset/TechsetCompiler.h.template b/src/ObjCompiling/Techset/TechsetCompiler.h.template index 78ba580e..4bbdfc78 100644 --- a/src/ObjCompiling/Techset/TechsetCompiler.h.template +++ b/src/ObjCompiling/Techset/TechsetCompiler.h.template @@ -1,4 +1,4 @@ -#options GAME(T6) +#options GAME(IW4, T6) #filename "Game/" + GAME + "/Techset/TechsetCompiler" + GAME + ".h"