mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-07-11 13:41:50 +00:00
refactor: extract material name into common source file
This commit is contained in:
22
src/ObjCommon/Material/MaterialCommon.cpp
Normal file
22
src/ObjCommon/Material/MaterialCommon.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include "MaterialCommon.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <format>
|
||||
|
||||
namespace material
|
||||
{
|
||||
std::string GetFileNameForAssetName(const std::string& assetName)
|
||||
{
|
||||
std::string sanitizedFileName(assetName);
|
||||
if (sanitizedFileName[0] == '*')
|
||||
{
|
||||
std::ranges::replace(sanitizedFileName, '*', '_');
|
||||
const auto parenthesisPos = sanitizedFileName.find('(');
|
||||
if (parenthesisPos != std::string::npos)
|
||||
sanitizedFileName.erase(parenthesisPos);
|
||||
sanitizedFileName = std::format("generated/{}", sanitizedFileName);
|
||||
}
|
||||
|
||||
return std::format("materials/{}.json", sanitizedFileName);
|
||||
}
|
||||
} // namespace material
|
8
src/ObjCommon/Material/MaterialCommon.h
Normal file
8
src/ObjCommon/Material/MaterialCommon.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace material
|
||||
{
|
||||
std::string GetFileNameForAssetName(const std::string& assetName);
|
||||
}
|
Reference in New Issue
Block a user