2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-04-07 12:18:40 +00:00

feat: add t6 vertexdecl sub asset creator

This commit is contained in:
Jan Laupetin
2026-02-27 21:28:28 +01:00
parent 3ef8cc7260
commit 9a527c16fa
15 changed files with 179 additions and 8 deletions

View File

@@ -207,4 +207,18 @@ namespace techset
return std::nullopt;
}
CommonVertexDeclaration::CommonVertexDeclaration(std::vector<CommonStreamRouting> routing)
: m_routing(std::move(routing))
{
}
void CommonVertexDeclaration::SortRoutingEntries()
{
std::ranges::sort(m_routing,
[](const CommonStreamRouting& r1, const CommonStreamRouting& r2)
{
return r1.m_source < r2.m_source;
});
}
} // namespace techset

View File

@@ -234,6 +234,11 @@ namespace techset
class CommonVertexDeclaration
{
public:
CommonVertexDeclaration() = default;
explicit CommonVertexDeclaration(std::vector<CommonStreamRouting> routing);
void SortRoutingEntries();
std::vector<CommonStreamRouting> m_routing;
};

View File

@@ -0,0 +1,67 @@
#include "CommonVertexDeclCreator.h"
#include "Utils/Logging/Log.h"
#include <algorithm>
namespace
{
bool NextAbbreviation(const std::string& assetName, std::string& abbreviation, size_t& offset)
{
if (offset >= assetName.size())
return false;
if (offset + 1 < assetName.size() && isdigit(assetName[offset + 1]))
{
abbreviation = std::string(assetName, offset, 2);
offset += 2;
}
else
{
abbreviation = std::string(assetName, offset, 1);
offset += 1;
}
return true;
}
} // namespace
namespace techset
{
std::optional<CommonVertexDeclaration> CreateVertexDeclFromName(const std::string& name, const CommonStreamRoutingInfos& routingInfos)
{
CommonVertexDeclaration result;
size_t currentOffset = 0u;
std::string sourceAbbreviation;
while (NextAbbreviation(name, sourceAbbreviation, currentOffset))
{
std::string destinationAbbreviation;
if (!NextAbbreviation(name, destinationAbbreviation, currentOffset))
{
con::error("Failed to detect vertex decl destination abbreviation: {}", name);
return std::nullopt;
}
const auto maybeSource = routingInfos.GetSourceByAbbreviation(sourceAbbreviation);
if (!maybeSource)
{
con::error("Unknown vertex decl source abbreviation: {}", sourceAbbreviation);
return std::nullopt;
}
const auto maybeDestination = routingInfos.GetDestinationByAbbreviation(destinationAbbreviation);
if (!maybeDestination)
{
con::error("Unknown vertex decl destination abbreviation: {}", destinationAbbreviation);
return std::nullopt;
}
result.m_routing.emplace_back(*maybeSource, *maybeDestination);
}
result.SortRoutingEntries();
return result;
}
} // namespace techset

View File

@@ -0,0 +1,11 @@
#pragma once
#include "CommonTechnique.h"
#include <optional>
#include <string>
namespace techset
{
std::optional<CommonVertexDeclaration> CreateVertexDeclFromName(const std::string& name, const CommonStreamRoutingInfos& routingInfos);
}