载入中...
搜索中...
未找到
VegetationPresetSource.cpp
浏览该文件的文档.
18 return Result<double>::failure(Diagnostic::error(DiagnosticCode::ParseError, "Unity material number is invalid",
24Result<void> insertUnique(Map& values, std::string name, ValueType value, const std::string& path) {
33Result<VegetationConversionCandidate> decodeUnityVegetationConversionCandidate(std::span<const std::uint8_t> yaml,
38 Diagnostic::error(DiagnosticCode::InvalidArgument, "Unity material source exceeds parsing budget",
44 Diagnostic::error(DiagnosticCode::TypeMismatch, "Unity source is not a text Material", sourcePath, {},
47 const std::regex scalarPattern(R"((?:^|\n)[ \t]*-[ \t]+([A-Za-z_][A-Za-z0-9_]*):[ \t]*([-+0-9.eE]+))");
48 for (auto i = std::sregex_iterator(text.begin(), text.end(), scalarPattern); i != std::sregex_iterator(); ++i) {
55 R"((?:^|\n)[ \t]*-[ \t]+([A-Za-z_][A-Za-z0-9_]*):[ \t]*\{(?:r|x):[ \t]*([^,}]+),[ \t]*(?:g|y):[ \t]*([^,}]+),[ \t]*(?:b|z):[ \t]*([^,}]+),[ \t]*(?:a|w):[ \t]*([^}]+)\})");
56 for (auto i = std::sregex_iterator(text.begin(), text.end(), vectorPattern); i != std::sregex_iterator(); ++i) {
65 if (!vectorInserted) return Result<VegetationConversionCandidate>::failure(vectorInserted.status());
67 if (!colorInserted) return Result<VegetationConversionCandidate>::failure(colorInserted.status());
70 R"((?:^|\n)[ \t]*-[ \t]+([A-Za-z_][A-Za-z0-9_]*):[ \t]*(?:\r?\n)[ \t]+m_Texture:[ \t]*\{fileID:[ \t]*(-?[0-9]+)(?:,[ \t]*guid:[ \t]*([0-9a-fA-F]{32}),[ \t]*type:[ \t]*[0-9]+)?\}[ \t]*(?:\r?\n)[ \t]+m_Scale:[ \t]*\{x:[ \t]*([^,}]+),[ \t]*y:[ \t]*([^}]+)\}[ \t]*(?:\r?\n)[ \t]+m_Offset:[ \t]*\{x:[ \t]*([^,}]+),[ \t]*y:[ \t]*([^}]+)\})");
71 for (auto i = std::sregex_iterator(text.begin(), text.end(), texturePattern); i != std::sregex_iterator();
95 R"((?:^|\n)[ \t]*m_Shader:[ \t]*\{fileID:[ \t]*[0-9]+,[ \t]*guid:[ \t]*([0-9a-fA-F]{32}),[ \t]*type:[ \t]*[0-9]+\})");
99 Diagnostic::error(DiagnosticCode::ParseError, "Unity material shader GUID is missing", sourcePath, {},
102 std::transform(out.materialShader.begin(), out.materialShader.end(), out.materialShader.begin(),
104 const std::regex instancingPattern(R"((?:^|\n)[ \t]*m_EnableInstancingVariants:[ \t]*([01])(?:\r?\n|$))");
106 if (std::regex_search(text, instancing, instancingPattern)) out.materialInstancing = instancing[1].str() == "1";
133 Diagnostic::error(DiagnosticCode::Failed, "Unity material parser expression failed", sourcePath, {},
137 Diagnostic::error(DiagnosticCode::Failed, "Unity material candidate allocation failed", sourcePath, {},
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
Definition AssetImporter.h:14
EVENGINE_API_PLATFORM Result< VegetationConversionCandidate > decodeUnityVegetationConversionCandidate(std::span< const std::uint8_t > yaml, std::string sourcePath, std::uint64_t maximumBytes=16ull *1024ull *1024ull)
Decode Unity text Material saved properties into an owning vegetation conversion baseline.
Definition VegetationPresetSource.cpp:33
EVENGINE_API_PLATFORM VegetationPresetContext makeVegetationPresetContext(const VegetationConversionCandidate &candidate, std::string shaderName, std::string materialName, std::string shaderPipeline, std::set< std::string > outputOptions={})
Project one conversion baseline into immutable preset predicate facts.
Definition VegetationPresetSource.cpp:142
@ InvalidArgument
@ TypeMismatch
A stable reference resolved to a different canonical domain type.
@ Failed
@ ParseError
@ Conflict
Owning unpublished material, mesh and texture candidate mutated transactionally by preset commands.
Definition VegetationPreset.h:63
std::string materialShader
Definition VegetationPreset.h:72
std::map< std::string, std::array< double, 4 > > materialVectors
Definition VegetationPreset.h:65
bool materialInstancing
Definition VegetationPreset.h:74
std::set< std::string > materialKeywords
Definition VegetationPreset.h:69
std::map< std::string, std::array< double, 4 > > materialColors
Definition VegetationPreset.h:66
std::map< std::string, double > materialFloats
Definition VegetationPreset.h:64
std::map< std::string, std::array< double, 4 > > materialTextureTransforms
Definition VegetationPreset.h:68
std::map< std::string, std::string > materialTextures
Definition VegetationPreset.h:67
Immutable source facts used by TVE preset predicates.
Definition VegetationPreset.h:29
std::set< std::string > materialTextures
Definition VegetationPreset.h:36
std::string shaderName
Definition VegetationPreset.h:31
std::map< std::string, double > materialFloats
Definition VegetationPreset.h:34
std::set< std::string > outputOptions
Definition VegetationPreset.h:30
std::set< std::string > materialProperties
Definition VegetationPreset.h:35
std::string materialName
Definition VegetationPreset.h:32
std::string shaderPipeline
Definition VegetationPreset.h:33
std::set< std::string > materialKeywords
Definition VegetationPreset.h:37