2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-03-05 12:33:02 +00:00

chore: use CommonTechset instead of TechsetDefinition

This commit is contained in:
Jan Laupetin
2026-01-19 22:13:12 +00:00
parent c9d5f208d5
commit e61ec8582a
40 changed files with 306 additions and 301 deletions

View File

@@ -11,10 +11,10 @@
#include "Pool/GlobalAssetPool.h"
#include "StateMap/StateMapFromTechniqueExtractor.h"
#include "StateMap/StateMapHandler.h"
#include "Techset/CommonTechsetCache.h"
#include "Techset/TechniqueFileReader.h"
#include "Techset/TechniqueStateMapCache.h"
#include "Techset/TechsetCommon.h"
#include "Techset/TechsetDefinitionCache.h"
#include "Utils/Logging/Log.h"
#include <cassert>
@@ -795,7 +795,7 @@ namespace
m_registration.AddDependency(techset);
m_material.techniqueSet = techset->Asset();
auto& definitionCache = m_context.GetZoneAssetCreationState<::techset::TechsetDefinitionCache>();
auto& definitionCache = m_context.GetZoneAssetCreationState<::techset::CommonTechsetCache>();
bool failure = false;
const auto* techsetDefinition = m_techset_creator->LoadTechsetDefinition(techsetName, m_context, failure);
@@ -808,12 +808,12 @@ namespace
SetTechniqueSetCameraRegion(techsetDefinition);
}
void SetTechniqueSetStateBits(const ::techset::TechsetDefinition* techsetDefinition)
void SetTechniqueSetStateBits(const techset::CommonTechset* commonTechset)
{
for (auto i = 0; i < TECHNIQUE_COUNT; i++)
{
std::string techniqueName;
if (techsetDefinition->GetTechniqueByIndex(i, techniqueName))
auto techniqueName = commonTechset->m_technique_names[i];
if (!techniqueName.empty())
{
const auto stateBitsForTechnique = GetStateBitsForTechnique(techniqueName);
const auto foundStateBits = std::ranges::find_if(m_state_bits,
@@ -892,17 +892,17 @@ namespace
return outBits;
}
void SetTechniqueSetCameraRegion(const ::techset::TechsetDefinition* techsetDefinition) const
void SetTechniqueSetCameraRegion(const techset::CommonTechset* commonTechset) const
{
std::string tempName;
if (techsetDefinition->GetTechniqueByIndex(TECHNIQUE_LIT, tempName))
if (!commonTechset->m_technique_names[TECHNIQUE_LIT].empty())
{
if (m_material.info.sortKey >= SORTKEY_TRANS_START)
m_material.cameraRegion = CAMERA_REGION_LIT_TRANS;
else
m_material.cameraRegion = CAMERA_REGION_LIT_OPAQUE;
}
else if (techsetDefinition->GetTechniqueByIndex(TECHNIQUE_EMISSIVE, tempName))
else if (!commonTechset->m_technique_names[TECHNIQUE_EMISSIVE].empty())
{
m_material.cameraRegion = CAMERA_REGION_EMISSIVE;
}

View File

@@ -7,11 +7,11 @@
#include "Shader/D3D9ShaderAnalyser.h"
#include "Shader/ShaderCommon.h"
#include "StateMap/StateMapReader.h"
#include "Techset/CommonTechsetCache.h"
#include "Techset/CommonTechsetLoader.h"
#include "Techset/TechniqueFileReader.h"
#include "Techset/TechniqueStateMapCache.h"
#include "Techset/TechsetCommon.h"
#include "Techset/TechsetDefinitionCache.h"
#include "Techset/TechsetFileReader.h"
#include "Utils/Alignment.h"
#include "Utils/Logging/Log.h"
@@ -1284,7 +1284,7 @@ namespace
}
private:
AssetCreationResult CreateTechsetFromDefinition(const std::string& assetName, const TechsetDefinition& definition, AssetCreationContext& context)
AssetCreationResult CreateTechsetFromDefinition(const std::string& assetName, const CommonTechset& definition, AssetCreationContext& context)
{
auto* techset = m_memory.Alloc<MaterialTechniqueSet>();
techset->name = m_memory.Dup(assetName.c_str());
@@ -1294,8 +1294,8 @@ namespace
const TechniqueLoader techniqueLoader(m_search_path, m_memory, context, this);
for (auto i = 0u; i < std::extent_v<decltype(MaterialTechniqueSet::techniques)>; i++)
{
std::string techniqueName;
if (definition.GetTechniqueByIndex(i, techniqueName))
const auto& techniqueName = definition.m_technique_names[i];
if (!techniqueName.empty())
{
auto* technique = techniqueLoader.LoadMaterialTechnique(techniqueName);
@@ -1312,10 +1312,10 @@ namespace
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
}
TechsetDefinition* LoadTechsetDefinition(const std::string& assetName, AssetCreationContext& context, bool& failure) override
CommonTechset* LoadTechsetDefinition(const std::string& assetName, AssetCreationContext& context, bool& failure) override
{
failure = false;
auto& definitionCache = context.GetZoneAssetCreationState<TechsetDefinitionCache>();
auto& definitionCache = context.GetZoneAssetCreationState<CommonTechsetCache>();
auto* cachedTechsetDefinition = definitionCache.GetCachedTechsetDefinition(assetName);
if (cachedTechsetDefinition)
return cachedTechsetDefinition;
@@ -1325,17 +1325,13 @@ namespace
if (!file.IsOpen())
return nullptr;
const TechsetFileReader reader(*file.m_stream, techsetFileName, techniqueTypeNames, std::extent_v<decltype(techniqueTypeNames)>);
auto techsetDefinition = reader.ReadTechsetDefinition();
auto techsetDefinition = LoadCommonTechset(assetName, commonTechniqueTypeNames, m_search_path, failure);
if (!techsetDefinition)
{
failure = true;
return nullptr;
}
auto* techsetDefinitionPtr = techsetDefinition.get();
definitionCache.AddTechsetDefinitionToCache(assetName, std::move(techsetDefinition));
definitionCache.AddCommonTechsetToCache(assetName, std::move(techsetDefinition));
return techsetDefinitionPtr;
}

View File

@@ -4,7 +4,7 @@
#include "Game/IW4/IW4.h"
#include "SearchPath/ISearchPath.h"
#include "StateMap/StateMapDefinition.h"
#include "Techset/TechsetDefinition.h"
#include "Techset/CommonTechset.h"
#include "Utils/MemoryManager.h"
#include <memory>
@@ -18,7 +18,7 @@ namespace techset
ICreatorIW4() = default;
virtual ~ICreatorIW4() = default;
virtual TechsetDefinition* LoadTechsetDefinition(const std::string& assetName, AssetCreationContext& context, bool& failure) = 0;
virtual CommonTechset* LoadTechsetDefinition(const std::string& assetName, AssetCreationContext& context, bool& failure) = 0;
virtual const state_map::StateMapDefinition* LoadStateMapDefinition(const std::string& stateMapName, AssetCreationContext& context) = 0;
};

View File

@@ -4,6 +4,7 @@
#include "Image/ImageIPakPostProcessor.h"
#include "Image/ImageIwdPostProcessor.h"
#include "KeyValuePairs/KeyValuePairsCompilerT6.h"
#include "Techset/TechsetCompilerT6.h"
#include <memory>
@@ -20,6 +21,7 @@ namespace
auto& memory = zone.Memory();
collection.AddAssetCreator(key_value_pairs::CreateCompilerT6(memory, zone, zoneDefinition.m_zone_definition, zoneStates));
collection.AddAssetCreator(techset::CreateCompilerT6(memory, searchPath));
}
void ConfigurePostProcessors(AssetCreatorCollection& collection,

View File

@@ -0,0 +1,23 @@
#include "TechsetCompilerT6.h"
#include "Game/T6/T6.h"
namespace
{
class TechsetCompilerT6 final : public AssetCreator<T6::AssetTechniqueSet>
{
public:
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
{
return AssetCreationResult::NoAction();
}
};
} // namespace
namespace techset
{
std::unique_ptr<IAssetCreator> CreateCompilerT6(MemoryManager& memory, ISearchPath& searchPath)
{
return std::make_unique<TechsetCompilerT6>();
}
} // namespace techset

View File

@@ -0,0 +1,12 @@
#pragma once
#include "Asset/IAssetCreator.h"
#include "SearchPath/ISearchPath.h"
#include "Utils/MemoryManager.h"
#include <memory>
namespace techset
{
std::unique_ptr<IAssetCreator> CreateCompilerT6(MemoryManager& memory, ISearchPath& searchPath);
} // namespace techset