mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-03-15 17:33:03 +00:00
feat: use templated techset compiler for IW4
This commit is contained in:
@@ -223,6 +223,8 @@ namespace IW4
|
||||
using AssetTracer = Asset<ASSET_TYPE_TRACER, TracerDef>;
|
||||
using AssetVehicle = Asset<ASSET_TYPE_VEHICLE, VehicleDef>;
|
||||
using AssetAddonMapEnts = Asset<ASSET_TYPE_ADDON_MAP_ENTS, AddonMapEnts>;
|
||||
|
||||
using SubAssetTechnique = SubAsset<SUB_ASSET_TYPE_TECHNIQUE, MaterialTechnique>;
|
||||
} // namespace IW4
|
||||
|
||||
DEFINE_ASSET_NAME_ACCESSOR(IW4::AssetPhysPreset, name);
|
||||
|
||||
@@ -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 <memory>
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<MaterialWorldVertexFormat>(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<decltype(MaterialTechniqueSet::techniques)>; 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<AssetTechniqueSet>(assetName, techset)));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#options GAME(T6)
|
||||
#options GAME(IW4, T6)
|
||||
|
||||
#filename "Game/" + GAME + "/Techset/TechsetCompiler" + GAME + ".h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user