载入中...
搜索中...
未找到
VegetationConversionImport.cpp
浏览该文件的文档.
16 const auto bytes = std::span<const std::uint8_t>(reinterpret_cast<const std::uint8_t*>(seed.data()), seed.size());
27Result<std::string> texturePathForGuid(const UnityVegetationAssetImportRequest& request, std::string_view guid) {
37 Diagnostic::error(DiagnosticCode::NotFound, "vegetation texture metadata has no source payload", source,
41 Diagnostic::error(DiagnosticCode::Conflict, "duplicate vegetation texture GUID", std::string(guid), {},
52Result<void> appendMesh(PreparedAssetImport& prepared, const UnityVegetationAssetImportRequest& request,
60 *conversion.mesh, {request.limits.maximumVerticesPerPrimitive, request.limits.maximumIndicesPerPrimitive,
63 const auto key = request.outputKey.empty() ? unity_detail::foldAscii(request.materialGuid) : request.outputKey;
78 for (const auto& [set, values] : conversion.mesh->texcoords) uvSets.emplace_back(std::int64_t(set));
81 attributes.emplace_back(Value::Object{{"name", name}, {"components", std::int64_t(attribute.components)}});
116 prepared.findings.push_back({request.conversion.sourcePath, "TVE.Mesh", ImportDisposition::Baked,
122Result<PreparedAssetImport> prepareUnityVegetationConversionImport(const UnityVegetationAssetImportRequest& request) {
126 DiagnosticCode::InvalidArgument, "vegetation material GUID must contain 32 hexadecimal digits", {}, {},
160 auto material = encodeUnityVegetationConversionMaterial(candidate, request.limits.maximumDecodedBytes);
181 auto report = detail::finalizeImportReport(prepared.value(), request.package, "unity", "tve-12.6-conversion",
201Result<PreparedAssetImport> prepareUnityVegetationConversionBatch(const UnityVegetationBatchImportRequest& request) {
205 DiagnosticCode::InvalidArgument, "vegetation batch requires a bounded non-empty object set", {}, {},
207 auto manifest = detail::baseManifest(request.package, "eve.unity-vegetation-conversion-batch/1");
236 auto [found, inserted] = uniqueEntries.try_emplace(std::move(entry.path), std::move(entry.bytes));
249 object.outputKey + (name == "default" || name == object.conversion.sourcePath ? "" : "#" + name);
257 Diagnostic::error(DiagnosticCode::InvalidArgument, "vegetation batch asset count exceeds budget",
265 auto report = detail::finalizeImportReport(batch, request.package, "unity", "tve-12.6-conversion-batch",
303 return Result<double>::failure(Diagnostic::error(DiagnosticCode::ParseError, "Unity material number is invalid",
309Result<void> insertUnique(Map& values, std::string name, ValueType value, const std::string& path) {
318Result<VegetationConversionCandidate> decodeUnityVegetationConversionCandidate(std::span<const std::uint8_t> yaml,
323 Diagnostic::error(DiagnosticCode::InvalidArgument, "Unity material source exceeds parsing budget",
329 Diagnostic::error(DiagnosticCode::TypeMismatch, "Unity source is not a text Material", sourcePath, {},
332 const std::regex scalarPattern(R"((?:^|\n)[ \t]*-[ \t]+([A-Za-z_][A-Za-z0-9_]*):[ \t]*([-+0-9.eE]+))");
333 for (auto i = std::sregex_iterator(text.begin(), text.end(), scalarPattern); i != std::sregex_iterator(); ++i) {
340 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]*([^}]+)\})");
341 for (auto i = std::sregex_iterator(text.begin(), text.end(), vectorPattern); i != std::sregex_iterator(); ++i) {
350 if (!vectorInserted) return Result<VegetationConversionCandidate>::failure(vectorInserted.status());
352 if (!colorInserted) return Result<VegetationConversionCandidate>::failure(colorInserted.status());
355 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]*([^}]+)\})");
356 for (auto i = std::sregex_iterator(text.begin(), text.end(), texturePattern); i != std::sregex_iterator();
380 R"((?:^|\n)[ \t]*m_Shader:[ \t]*\{fileID:[ \t]*[0-9]+,[ \t]*guid:[ \t]*([0-9a-fA-F]{32}),[ \t]*type:[ \t]*[0-9]+\})");
384 Diagnostic::error(DiagnosticCode::ParseError, "Unity material shader GUID is missing", sourcePath, {},
387 std::transform(out.materialShader.begin(), out.materialShader.end(), out.materialShader.begin(),
389 const std::regex instancingPattern(R"((?:^|\n)[ \t]*m_EnableInstancingVariants:[ \t]*([01])(?:\r?\n|$))");
391 if (std::regex_search(text, instancing, instancingPattern)) out.materialInstancing = instancing[1].str() == "1";
418 Diagnostic::error(DiagnosticCode::Failed, "Unity material parser expression failed", sourcePath, {},
422 Diagnostic::error(DiagnosticCode::Failed, "Unity material candidate allocation failed", sourcePath, {},
Direct Unity text-serialization adapter for TerrainData and Prefab assets.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
const T & value() const &
Borrow the value from a const lvalue after checking success.
Definition Result.h:339
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
Id128 child(std::string_view role) const noexcept
Derives a deterministic child UUID for a hierarchical identity.
Definition Identity.h:191
Result< std::string > metaScalar(std::span< const std::uint8_t > bytes, std::string_view key, std::string_view path)
Read an unindented scalar from .meta; rejects duplicate keys and binary metadata.
Definition UnitySource.cpp:10
Definition AssetImporter.h:14
Result< PreparedAssetImport > prepareUnityVegetationConversionImport(const UnityVegetationAssetImportRequest &request)
Convert and prepare one material, its packed images, and optional mesh as a single EVA candidate.
Definition VegetationConversionImport.cpp:122
EVENGINE_API_PLATFORM Result< std::vector< std::uint8_t > > encodeUnityVegetationConversionMaterial(const VegetationConversionCandidate &candidate, std::uint64_t maximumBytes=16ull *1024ull *1024ull)
Encode an applied vegetation candidate as a detached Unity text Material for the canonical TVE import...
Definition VegetationPresetConversion.cpp:279
Result< PreparedAssetImport > prepareUnityVegetationConversionBatch(const UnityVegetationBatchImportRequest &request)
Prepare several vegetation objects as one all-or-nothing EVA candidate.
Definition VegetationConversionImport.cpp:201
EVENGINE_API_PLATFORM Result< VegetationConversionResult > executeUnityVegetationConversion(const UnityVegetationConversionRequest &request)
Decode a Unity Material, evaluate one TVE preset graph, and execute every output atomically.
Definition VegetationPresetConversion.cpp:215
Result< VegetationConversionCandidate > decodeUnityVegetationConversionCandidate(std::span< const std::uint8_t > yaml, std::string sourcePath, std::uint64_t maximumBytes)
Decode Unity text Material saved properties into an owning vegetation conversion baseline.
Definition VegetationConversionImport.cpp:318
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 VegetationConversionImport.cpp:427
Result< PreparedAssetImport > prepareUnityProjectImport(const UnityProjectImportRequest &request)
Import selected Unity assets, or discover a collection when both selectors are empty.
Definition UnityImporter.cpp:771
EVENGINE_API_FOUNDATION Result< std::vector< std::uint8_t > > encodeCanonicalMesh(const CanonicalMeshData &mesh, const CanonicalMeshLimits &limits={})
Encode an owning snapshot to EVMESH v3, or v2 when no named attributes exist. Borrows input synchrono...
Definition CanonicalMeshEncode.cpp:15
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:27
@ InvalidArgument
@ TypeMismatch
A stable reference resolved to a different canonical domain type.
@ NotFound
@ Failed
@ ParseError
@ Conflict
@ Object
detail::StrongUint64< detail::SchemaVersionTag > SchemaVersion
Persistent data-format version; not a runtime replacement generation.
Definition SchemaVersion.h:13
Definition Container.h:602
One owning regular-file entry inside an .eva archive.
Definition EvaArchive.h:31
std::vector< EvaDependency > dependencies
Definition EvaManifest.h:70
std::map< std::string, AssetRef > entrypoints
Definition EvaManifest.h:71
std::uint32_t maximumAssets
Definition AssetImporter.h:20
ImportPackageIdentity package
Definition AssetImporter.h:55
PersistentId packageId
Definition AssetImporter.h:34
Owning, validated source archive candidate not yet published to disk/database.
Definition AssetImporter.h:90
std::vector< ImportFinding > findings
Definition AssetImporter.h:93
std::vector< asset::EvaArchiveEntry > entries
Definition AssetImporter.h:92
std::vector< ImportSourceMapping > sourceMappings
Definition AssetImporter.h:94
asset::EvaManifest manifest
Definition AssetImporter.h:91
In-memory Unity project slice; keys are normalized project-relative paths.
Definition UnityImporter.h:15
Owning inputs for one atomically prepared Unity vegetation asset group.
Definition VegetationPreset.h:124
Owning ordered set of independently converted vegetation objects published as one package.
Definition VegetationPreset.h:134
Owning unpublished material, mesh and texture candidate mutated transactionally by preset commands.
Definition VegetationPreset.h:63
std::map< std::string, std::array< double, 4 > > materialVectors
Definition VegetationPreset.h:65
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