mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-06-27 03:18:17 +00:00
chore: use templated vertex decl compiler
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
#include "ObjCompilerIW4.h"
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Game/IW4/Techset/VertexDeclCompilerIW4.h"
|
||||
#include "Image/ImageIwdPostProcessor.h"
|
||||
#include "Material/CompilerMaterialIW4.h"
|
||||
#include "Techset/CompilerTechsetIW4.h"
|
||||
#include "Techset/CompilerVertexDeclIW4.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace
|
||||
collection.AddAssetCreator(material::CreateCompilerIW4(memory, searchPath, gdt));
|
||||
collection.AddAssetCreator(techset::CreateLoaderIW4(memory, searchPath));
|
||||
#endif
|
||||
collection.AddAssetCreator(vertex_decl::CreateLoaderIW4(memory));
|
||||
collection.AddAssetCreator(techset::CreateVertexDeclCompilerIW4(memory));
|
||||
}
|
||||
|
||||
void ConfigurePostProcessors(AssetCreatorCollection& collection,
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
#include "CompilerVertexDeclIW4.h"
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Game/IW4/Techset/TechsetConstantsIW4.h"
|
||||
#include "Techset/CommonVertexDeclCreator.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
namespace
|
||||
{
|
||||
class LoaderVertexDecl final : public AssetCreator<AssetVertexDecl>
|
||||
{
|
||||
public:
|
||||
explicit LoaderVertexDecl(MemoryManager& memory)
|
||||
: m_memory(memory)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto commonVertexDecl = techset::CreateVertexDeclFromName(assetName, commonRoutingInfos);
|
||||
if (!commonVertexDecl)
|
||||
return AssetCreationResult::Failure();
|
||||
|
||||
if (commonVertexDecl->m_routing.size() > std::extent_v<decltype(MaterialVertexStreamRouting::data)>)
|
||||
{
|
||||
con::error("Vertex declaration can only have up to {} routing entries", std::extent_v<decltype(MaterialVertexStreamRouting::data)>);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
auto* vertexDecl = m_memory.Alloc<MaterialVertexDeclaration>();
|
||||
|
||||
vertexDecl->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
for (const auto& commonRoutingEntry : commonVertexDecl->m_routing)
|
||||
{
|
||||
vertexDecl->routing.data[vertexDecl->streamCount].source = commonRoutingEntry.m_source;
|
||||
vertexDecl->routing.data[vertexDecl->streamCount].dest = commonRoutingEntry.m_destination;
|
||||
vertexDecl->hasOptionalSource = vertexDecl->hasOptionalSource || commonRoutingEntry.m_source >= STREAM_SRC_OPTIONAL_BEGIN;
|
||||
|
||||
vertexDecl->streamCount++;
|
||||
}
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(AssetRegistration<AssetVertexDecl>(assetName, vertexDecl)));
|
||||
}
|
||||
|
||||
MemoryManager& m_memory;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace vertex_decl
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetVertexDecl>> CreateLoaderIW4(MemoryManager& memory)
|
||||
{
|
||||
return std::make_unique<LoaderVertexDecl>(memory);
|
||||
}
|
||||
} // namespace vertex_decl
|
||||
@@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/IAssetCreator.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace vertex_decl
|
||||
{
|
||||
std::unique_ptr<AssetCreator<IW4::AssetVertexDecl>> CreateLoaderIW4(MemoryManager& memory);
|
||||
} // namespace vertex_decl
|
||||
Reference in New Issue
Block a user