mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-03-16 01:43:04 +00:00
chore: use templated vertex decl compiler
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
#include "ObjCompilerIW4.h"
|
#include "ObjCompilerIW4.h"
|
||||||
|
|
||||||
#include "Game/IW4/IW4.h"
|
#include "Game/IW4/IW4.h"
|
||||||
|
#include "Game/IW4/Techset/VertexDeclCompilerIW4.h"
|
||||||
#include "Image/ImageIwdPostProcessor.h"
|
#include "Image/ImageIwdPostProcessor.h"
|
||||||
#include "Material/CompilerMaterialIW4.h"
|
#include "Material/CompilerMaterialIW4.h"
|
||||||
#include "Techset/CompilerTechsetIW4.h"
|
#include "Techset/CompilerTechsetIW4.h"
|
||||||
#include "Techset/CompilerVertexDeclIW4.h"
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ namespace
|
|||||||
collection.AddAssetCreator(material::CreateCompilerIW4(memory, searchPath, gdt));
|
collection.AddAssetCreator(material::CreateCompilerIW4(memory, searchPath, gdt));
|
||||||
collection.AddAssetCreator(techset::CreateLoaderIW4(memory, searchPath));
|
collection.AddAssetCreator(techset::CreateLoaderIW4(memory, searchPath));
|
||||||
#endif
|
#endif
|
||||||
collection.AddAssetCreator(vertex_decl::CreateLoaderIW4(memory));
|
collection.AddAssetCreator(techset::CreateVertexDeclCompilerIW4(memory));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigurePostProcessors(AssetCreatorCollection& collection,
|
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
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#options GAME(T6)
|
#options GAME(IW4, T6)
|
||||||
|
|
||||||
#filename "Game/" + GAME + "/Techset/VertexDeclCompiler" + GAME + ".cpp"
|
#filename "Game/" + GAME + "/Techset/VertexDeclCompiler" + GAME + ".cpp"
|
||||||
|
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
#define FEATURE_T5
|
#define FEATURE_T5
|
||||||
#elif GAME == "T6"
|
#elif GAME == "T6"
|
||||||
#define FEATURE_T6
|
#define FEATURE_T6
|
||||||
|
#define IS_SUB_ASSET
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This file was templated.
|
// This file was templated.
|
||||||
@@ -33,14 +34,16 @@ using namespace GAME;
|
|||||||
|
|
||||||
#set COMPILER_CLASS_NAME "VertexDeclCompiler" + GAME
|
#set COMPILER_CLASS_NAME "VertexDeclCompiler" + GAME
|
||||||
|
|
||||||
#if defined(FEATURE_T6)
|
#if defined(IS_SUB_ASSET)
|
||||||
#define ABSTRACT_CREATOR_NAME SubAssetCreator
|
#define ABSTRACT_CREATOR_NAME SubAssetCreator
|
||||||
#define OVERRIDEN_CREATOR_METHOD CreateSubAsset
|
#define OVERRIDEN_CREATOR_METHOD CreateSubAsset
|
||||||
|
#define ADD_ASSET_METHOD AddSubAsset
|
||||||
#define ASSET_NAME SubAssetVertexDecl
|
#define ASSET_NAME SubAssetVertexDecl
|
||||||
#define INTERFACE_NAME ISubAssetCreator
|
#define INTERFACE_NAME ISubAssetCreator
|
||||||
#else
|
#else
|
||||||
#define ABSTRACT_CREATOR_NAME AssetCreator
|
#define ABSTRACT_CREATOR_NAME AssetCreator
|
||||||
#define OVERRIDEN_CREATOR_METHOD CreateAsset
|
#define OVERRIDEN_CREATOR_METHOD CreateAsset
|
||||||
|
#define ADD_ASSET_METHOD AddAsset
|
||||||
#define ASSET_NAME AssetVertexDecl
|
#define ASSET_NAME AssetVertexDecl
|
||||||
#define INTERFACE_NAME IAssetCreator
|
#define INTERFACE_NAME IAssetCreator
|
||||||
#endif
|
#endif
|
||||||
@@ -69,6 +72,10 @@ namespace
|
|||||||
|
|
||||||
auto* vertexDecl = m_memory.Alloc<MaterialVertexDeclaration>();
|
auto* vertexDecl = m_memory.Alloc<MaterialVertexDeclaration>();
|
||||||
|
|
||||||
|
#ifndef IS_SUB_ASSET
|
||||||
|
vertexDecl->name = m_memory.Dup(assetName.c_str());
|
||||||
|
#endif
|
||||||
|
|
||||||
for (const auto& commonRoutingEntry : commonVertexDecl->m_routing)
|
for (const auto& commonRoutingEntry : commonVertexDecl->m_routing)
|
||||||
{
|
{
|
||||||
vertexDecl->routing.data[vertexDecl->streamCount].source = commonRoutingEntry.m_source;
|
vertexDecl->routing.data[vertexDecl->streamCount].source = commonRoutingEntry.m_source;
|
||||||
@@ -78,7 +85,7 @@ namespace
|
|||||||
vertexDecl->streamCount++;
|
vertexDecl->streamCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return AssetCreationResult::Success(context.AddSubAsset(AssetRegistration<ASSET_NAME>(assetName, vertexDecl)));
|
return AssetCreationResult::Success(context.ADD_ASSET_METHOD(AssetRegistration<ASSET_NAME>(assetName, vertexDecl)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#options GAME(T6)
|
#options GAME(IW4, T6)
|
||||||
|
|
||||||
#filename "Game/" + GAME + "/Techset/VertexDeclCompiler" + GAME + ".h"
|
#filename "Game/" + GAME + "/Techset/VertexDeclCompiler" + GAME + ".h"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user