载入中...
搜索中...
未找到
VegetationConversionImport.cpp
浏览该文件的文档.
2
3#include "asset/SourcePng.h"
7
8#include <algorithm>
9#include <cmath>
10#include <new>
11#include <set>
12
13namespace eve::asset_import {
14namespace {
15Result<std::string> stableGuid(std::string_view seed) {
16 const auto bytes = std::span<const std::uint8_t>(reinterpret_cast<const std::uint8_t*>(seed.data()), seed.size());
17 const auto hash = detail::sha256(bytes);
18 if (hash.size() < 39)
20 "stable vegetation texture hash is unavailable", {}, {},
21 "asset.import.vegetation-preset.publication"));
22 return Result<std::string>::success(hash.substr(7, 32));
23}
24
25std::vector<std::uint8_t> bytes(std::string value) { return {value.begin(), value.end()}; }
26
27Result<std::string> texturePathForGuid(const UnityVegetationAssetImportRequest& request, std::string_view guid) {
28 std::string found;
29 for (const auto& [path, content] : request.sourceFiles) {
30 if (!path.ends_with(".meta")) continue;
31 auto parsed = unity_detail::metaScalar(content, "guid", path);
32 if (!parsed) return Result<std::string>::failure(parsed.status());
33 if (unity_detail::foldAscii(parsed.value()) != guid) continue;
34 const auto source = path.substr(0, path.size() - 5);
35 if (!request.sourceFiles.contains(source))
37 Diagnostic::error(DiagnosticCode::NotFound, "vegetation texture metadata has no source payload", source,
38 {}, "asset.import.vegetation-preset.publication"));
39 if (!found.empty())
41 Diagnostic::error(DiagnosticCode::Conflict, "duplicate vegetation texture GUID", std::string(guid), {},
42 "asset.import.vegetation-preset.publication"));
43 found = source;
44 }
45 if (found.empty())
47 Diagnostic::error(DiagnosticCode::NotFound, "referenced vegetation texture source is absent",
48 std::string(guid), {}, "asset.import.vegetation-preset.publication"));
49 return Result<std::string>::success(std::move(found));
50}
51
52Result<void> appendMesh(PreparedAssetImport& prepared, const UnityVegetationAssetImportRequest& request,
53 const VegetationConversionResult& conversion) {
54 if (!conversion.mesh) return Result<void>::success();
55 if (prepared.manifest.assets.size() >= request.limits.maximumAssets)
57 "vegetation prepared asset count exceeds budget", {}, {},
58 "asset.import.vegetation-preset.publication"));
60 *conversion.mesh, {request.limits.maximumVerticesPerPrimitive, request.limits.maximumIndicesPerPrimitive,
61 request.limits.maximumDecodedBytes});
62 if (!blob) return Result<void>::failure(blob.status());
63 const auto key = request.outputKey.empty() ? unity_detail::foldAscii(request.materialGuid) : request.outputKey;
64 const auto id = request.package.packageId.child("unity-converted:" + key + ":mesh");
65 auto ref = detail::assetRef(id);
66 if (!ref) return Result<void>::failure(ref.status());
67 std::array<float, 3> minimum{conversion.mesh->positions[0], conversion.mesh->positions[1],
68 conversion.mesh->positions[2]};
69 auto maximum = minimum;
70 for (std::size_t offset = 3; offset < conversion.mesh->positions.size(); offset += 3)
71 for (std::size_t axis = 0; axis < 3; ++axis) {
72 minimum[axis] = std::min(minimum[axis], conversion.mesh->positions[offset + axis]);
73 maximum[axis] = std::max(maximum[axis], conversion.mesh->positions[offset + axis]);
74 }
75 if (conversion.meshBoundsMinimum) minimum = *conversion.meshBoundsMinimum;
76 if (conversion.meshBoundsMaximum) maximum = *conversion.meshBoundsMaximum;
77 Value::Array uvSets;
78 for (const auto& [set, values] : conversion.mesh->texcoords) uvSets.emplace_back(std::int64_t(set));
80 for (const auto& [name, attribute] : conversion.mesh->attributes)
81 attributes.emplace_back(Value::Object{{"name", name}, {"components", std::int64_t(attribute.components)}});
82 const std::string base = "assets/" + id.format() + "/";
83 const std::string definitionPath = base + "asset.json";
84 const std::string blobPath = base + "mesh.bin";
85 auto definition = Value(Value::Object{
86 {"schema", "eve.mesh"},
87 {"schemaVersion", std::int64_t(2)},
88 {"topology", "triangles"},
89 {"vertexCount", std::int64_t(conversion.mesh->positions.size() / 3)},
90 {"indexCount", std::int64_t(conversion.mesh->indices.size())},
91 {"positions", true},
92 {"normals", !conversion.mesh->normals.empty()},
93 {"texcoordSets", std::move(uvSets)},
94 {"attributes", std::move(attributes)},
95 {"coordinateSystem", "right-handed-x-right-y-up-minus-z-forward"},
96 {"unit", "meter"},
97 {"frontFace", "counter-clockwise"},
98 {"boundsMin", Value::Array{minimum[0], minimum[1], minimum[2]}},
99 {"boundsMax", Value::Array{maximum[0], maximum[1], maximum[2]}},
100 {"cpuReadable", conversion.meshCpuReadable},
101 {"blob", blobPath},
102 })
103 .toJson();
104 if (!definition) return Result<void>::failure(definition.status());
105 auto encoded = bytes(std::move(definition).takeValue());
106 prepared.manifest.assets.push_back({ref.value(),
107 "eve.mesh",
108 SchemaVersion(2),
109 definitionPath,
110 detail::sha256(encoded),
111 {"mesh", "source:unity", "vegetation"}});
112 prepared.entries.push_back({definitionPath, std::move(encoded)});
113 prepared.entries.push_back({blobPath, std::move(blob).takeValue()});
114 prepared.manifest.entrypoints.insert_or_assign("converted-mesh", ref.value());
115 prepared.sourceMappings.push_back({"converted-mesh", ref.value()});
116 prepared.findings.push_back({request.conversion.sourcePath, "TVE.Mesh", ImportDisposition::Baked,
117 "preset vertex streams and bounds encoded as canonical EVMESH"});
118 return Result<void>::success();
119}
120} // namespace
121
123 try {
124 if (!unity_detail::validGuid(request.materialGuid))
125 return Result<PreparedAssetImport>::failure(Diagnostic::error(
126 DiagnosticCode::InvalidArgument, "vegetation material GUID must contain 32 hexadecimal digits", {}, {},
127 "asset.import.vegetation-preset.publication"));
128 const auto materialGuid = unity_detail::foldAscii(request.materialGuid);
129 const auto outputKey = request.outputKey.empty() ? materialGuid : request.outputKey;
130 auto conversion = executeUnityVegetationConversion(request.conversion);
131 if (!conversion) return Result<PreparedAssetImport>::failure(conversion.status());
132
134 project.package = request.package;
135 project.limits = request.limits;
136 auto candidate = conversion.value().candidate;
137 std::set<std::string> generatedGuids;
138 for (const auto& [property, image] : conversion.value().textures) {
139 auto imageGuid = stableGuid(outputKey + ":" + property);
140 if (!imageGuid) return Result<PreparedAssetImport>::failure(imageGuid.status());
141 auto png = asset::detail::encodeSourcePng(image.width, image.height, image.pixels,
142 request.limits.maximumDecodedBytes);
143 if (!png) return Result<PreparedAssetImport>::failure(png.status());
144 const auto path = "Assets/Generated/TVE/" + imageGuid.value() + ".png";
145 project.files[path] = std::move(png).takeValue();
146 project.files[path + ".meta"] = bytes("fileFormatVersion: 2\nguid: " + imageGuid.value() +
147 "\nTextureImporter:\n sRGBTexture: 0\n wrapU: 0\n wrapV: 0\n"
148 " filterMode: 1\n enableMipMap: 1\n");
149 candidate.materialTextures[property] = imageGuid.value();
150 generatedGuids.insert(imageGuid.value());
151 }
152 for (const auto& [property, textureGuid] : candidate.materialTextures) {
153 if (generatedGuids.contains(textureGuid)) continue;
154 auto path = texturePathForGuid(request, textureGuid);
155 if (!path) return Result<PreparedAssetImport>::failure(path.status());
156 project.files[path.value()] = request.sourceFiles.at(path.value());
157 project.files[path.value() + ".meta"] = request.sourceFiles.at(path.value() + ".meta");
158 }
159 if (conversion.value().materialOutput != VegetationMaterialOutputMode::Off) {
160 auto material = encodeUnityVegetationConversionMaterial(candidate, request.limits.maximumDecodedBytes);
162 project.files[request.conversion.sourcePath] = std::move(material).takeValue();
163 project.files[request.conversion.sourcePath + ".meta"] =
164 bytes("fileFormatVersion: 2\nguid: " + materialGuid +
165 "\nNativeFormatImporter:\n mainObjectFileID: 2100000\n");
166 }
168 conversion.value().materialOutput == VegetationMaterialOutputMode::Off ? [&]() {
169 auto manifest = detail::baseManifest(request.package, "eve.unity-vegetation-conversion/1");
170 if (!manifest) return Result<PreparedAssetImport>::failure(manifest.status());
172 value.manifest = std::move(manifest).takeValue();
174 }()
175 : prepareUnityProjectImport(project);
176 if (!prepared) return prepared;
177 std::erase_if(prepared.value().entries,
178 [](const asset::EvaArchiveEntry& entry) { return entry.path == "reports/import.json"; });
179 auto mesh = appendMesh(prepared.value(), request, conversion.value());
180 if (!mesh) return Result<PreparedAssetImport>::failure(mesh.status());
181 auto report = detail::finalizeImportReport(prepared.value(), request.package, "unity", "tve-12.6-conversion",
182 {{"preset", request.conversion.rootPreset}});
183 if (!report) return Result<PreparedAssetImport>::failure(report.status());
184 std::uint64_t totalBytes = 0;
185 for (const auto& entry : prepared.value().entries) {
186 if (entry.bytes.size() > request.limits.maximumDecodedBytes ||
187 totalBytes > request.limits.maximumDecodedBytes - entry.bytes.size())
188 return Result<PreparedAssetImport>::failure(Diagnostic::error(
189 DiagnosticCode::InvalidArgument, "vegetation prepared output exceeds aggregate byte budget", {}, {},
190 "asset.import.vegetation-preset.publication"));
191 totalBytes += entry.bytes.size();
192 }
193 return prepared;
194 } catch (const std::bad_alloc&) {
196 Diagnostic::error(DiagnosticCode::Failed, "vegetation publication allocation failed", {}, {},
197 "asset.import.vegetation-preset.publication"));
198 }
199}
200
202 try {
203 if (request.objects.empty() || request.objects.size() > request.limits.maximumAssets)
204 return Result<PreparedAssetImport>::failure(Diagnostic::error(
205 DiagnosticCode::InvalidArgument, "vegetation batch requires a bounded non-empty object set", {}, {},
206 "asset.import.vegetation-preset.batch"));
207 auto manifest = detail::baseManifest(request.package, "eve.unity-vegetation-conversion-batch/1");
208 if (!manifest) return Result<PreparedAssetImport>::failure(manifest.status());
210 batch.manifest = std::move(manifest).takeValue();
211 std::set<std::string> outputKeys;
212 std::map<std::string, std::vector<std::uint8_t>> uniqueEntries;
213 std::set<std::string> assetIds;
214 for (const auto& object : request.objects) {
215 if (object.outputKey.empty() || !outputKeys.insert(object.outputKey).second)
216 return Result<PreparedAssetImport>::failure(Diagnostic::error(
217 DiagnosticCode::Conflict, "vegetation batch output keys must be non-empty and unique",
218 object.outputKey, {}, "asset.import.vegetation-preset.batch"));
219 auto itemRequest = object;
220 itemRequest.package = request.package;
221 itemRequest.limits = request.limits;
222 auto item = prepareUnityVegetationConversionImport(itemRequest);
223 if (!item) return Result<PreparedAssetImport>::failure(item.status());
224 for (auto& asset : item.value().manifest.assets) {
225 if (!assetIds.insert(asset.asset.format()).second)
227 Diagnostic::error(DiagnosticCode::Conflict, "vegetation batch asset identity collision",
228 asset.asset.format(), {}, "asset.import.vegetation-preset.batch"));
229 batch.manifest.assets.push_back(std::move(asset));
230 }
231 for (auto& dependency : item.value().manifest.dependencies)
232 batch.manifest.dependencies.push_back(std::move(dependency));
233 for (auto& entry : item.value().entries) {
234 if (entry.path == "reports/import.json") continue;
235 // Duplicate keys leave both arguments intact for the content/conflict check.
236 auto [found, inserted] = uniqueEntries.try_emplace(std::move(entry.path), std::move(entry.bytes));
237 if (!inserted && found->second != entry.bytes)
239 Diagnostic::error(DiagnosticCode::Conflict, "vegetation batch entry collision", entry.path, {},
240 "asset.import.vegetation-preset.batch"));
241 }
242 for (auto& mapping : item.value().sourceMappings) {
243 mapping.sourceObject = object.outputKey + "/" + mapping.sourceObject;
244 batch.sourceMappings.push_back(std::move(mapping));
245 }
246 for (auto& finding : item.value().findings) batch.findings.push_back(std::move(finding));
247 for (const auto& [name, ref] : item.value().manifest.entrypoints) {
248 const auto key =
249 object.outputKey + (name == "default" || name == object.conversion.sourcePath ? "" : "#" + name);
250 if (!batch.manifest.entrypoints.emplace(key, ref).second)
252 Diagnostic::error(DiagnosticCode::Conflict, "vegetation batch entrypoint collision", key, {},
253 "asset.import.vegetation-preset.batch"));
254 }
255 if (batch.manifest.assets.size() > request.limits.maximumAssets)
257 Diagnostic::error(DiagnosticCode::InvalidArgument, "vegetation batch asset count exceeds budget",
258 {}, {}, "asset.import.vegetation-preset.batch"));
259 }
260 batch.entries.reserve(uniqueEntries.size());
261 while (!uniqueEntries.empty()) {
262 auto entry = uniqueEntries.extract(uniqueEntries.begin());
263 batch.entries.push_back({std::move(entry.key()), std::move(entry.mapped())});
264 }
265 auto report = detail::finalizeImportReport(batch, request.package, "unity", "tve-12.6-conversion-batch",
266 {{"objectCount", std::int64_t(request.objects.size())}});
267 if (!report) return Result<PreparedAssetImport>::failure(report.status());
268 std::uint64_t totalBytes = 0;
269 for (const auto& entry : batch.entries) {
270 if (entry.bytes.size() > request.limits.maximumDecodedBytes ||
271 totalBytes > request.limits.maximumDecodedBytes - entry.bytes.size())
273 Diagnostic::error(DiagnosticCode::InvalidArgument, "vegetation batch exceeds aggregate byte budget",
274 {}, {}, "asset.import.vegetation-preset.batch"));
275 totalBytes += entry.bytes.size();
276 }
277 return Result<PreparedAssetImport>::success(std::move(batch));
278 } catch (const std::bad_alloc&) {
279 return Result<PreparedAssetImport>::failure(Diagnostic::error(DiagnosticCode::Failed,
280 "vegetation batch allocation failed", {}, {},
281 "asset.import.vegetation-preset.batch"));
282 }
283}
284} // namespace eve::asset_import
285
287
288#include <cctype>
289#include <cmath>
290#include <new>
291#include <regex>
292#include <sstream>
293
294namespace eve::asset_import {
295namespace {
296
297Result<double> number(std::string_view text, const std::string& path) {
298 std::string value(text);
299 char* end = nullptr;
300 errno = 0;
301 const auto parsed = std::strtod(value.c_str(), &end);
302 if (errno || end != value.c_str() + value.size() || !std::isfinite(parsed))
303 return Result<double>::failure(Diagnostic::error(DiagnosticCode::ParseError, "Unity material number is invalid",
304 path, {}, "asset.import.vegetation-preset.source"));
305 return Result<double>::success(parsed);
306}
307
308template <class Map, class ValueType>
309Result<void> insertUnique(Map& values, std::string name, ValueType value, const std::string& path) {
310 if (!values.emplace(std::move(name), std::move(value)).second)
312 "duplicate Unity material saved property", path, {},
313 "asset.import.vegetation-preset.source"));
314 return Result<void>::success();
315}
316} // namespace
317
319 std::string sourcePath,
320 std::uint64_t maximumBytes) {
321 if (yaml.empty() || yaml.size() > maximumBytes)
323 Diagnostic::error(DiagnosticCode::InvalidArgument, "Unity material source exceeds parsing budget",
324 sourcePath, {}, "asset.import.vegetation-preset.source"));
325 try {
326 const std::string text(reinterpret_cast<const char*>(yaml.data()), yaml.size());
327 if (text.find("\nMaterial:") == std::string::npos && !text.starts_with("Material:"))
329 Diagnostic::error(DiagnosticCode::TypeMismatch, "Unity source is not a text Material", sourcePath, {},
330 "asset.import.vegetation-preset.source"));
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) {
334 auto value = number((*i)[2].str(), sourcePath);
336 auto inserted = insertUnique(out.materialFloats, (*i)[1].str(), value.value(), sourcePath);
337 if (!inserted) return Result<VegetationConversionCandidate>::failure(inserted.status());
338 }
339 const std::regex vectorPattern(
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) {
342 std::array<double, 4> value{};
343 for (std::size_t component = 0; component < 4; ++component) {
344 auto parsed = number((*i)[component + 2].str(), sourcePath);
345 if (!parsed) return Result<VegetationConversionCandidate>::failure(parsed.status());
346 value[component] = parsed.value();
347 }
348 const auto name = (*i)[1].str();
349 auto vectorInserted = insertUnique(out.materialVectors, name, value, sourcePath);
350 if (!vectorInserted) return Result<VegetationConversionCandidate>::failure(vectorInserted.status());
351 auto colorInserted = insertUnique(out.materialColors, name, value, sourcePath);
352 if (!colorInserted) return Result<VegetationConversionCandidate>::failure(colorInserted.status());
353 }
354 const std::regex texturePattern(
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();
357 ++i) {
358 const auto name = (*i)[1].str();
359 if ((*i)[2].str() != "0") {
360 if (!(*i)[3].matched)
362 Diagnostic::error(DiagnosticCode::ParseError, "Unity texture reference lacks a GUID",
363 sourcePath, {}, "asset.import.vegetation-preset.source"));
364 auto guid = (*i)[3].str();
365 std::transform(guid.begin(), guid.end(), guid.begin(),
366 [](unsigned char value) { return static_cast<char>(std::tolower(value)); });
367 auto inserted = insertUnique(out.materialTextures, name, std::move(guid), sourcePath);
368 if (!inserted) return Result<VegetationConversionCandidate>::failure(inserted.status());
369 }
370 std::array<double, 4> transform{};
371 for (std::size_t component = 0; component < 4; ++component) {
372 auto parsed = number((*i)[component + 4].str(), sourcePath);
373 if (!parsed) return Result<VegetationConversionCandidate>::failure(parsed.status());
374 transform[component] = parsed.value();
375 }
376 auto inserted = insertUnique(out.materialTextureTransforms, name, transform, sourcePath);
377 if (!inserted) return Result<VegetationConversionCandidate>::failure(inserted.status());
378 }
379 const std::regex shaderPattern(
380 R"((?:^|\n)[ \t]*m_Shader:[ \t]*\{fileID:[ \t]*[0-9]+,[ \t]*guid:[ \t]*([0-9a-fA-F]{32}),[ \t]*type:[ \t]*[0-9]+\})");
381 std::smatch shader;
382 if (!std::regex_search(text, shader, shaderPattern))
384 Diagnostic::error(DiagnosticCode::ParseError, "Unity material shader GUID is missing", sourcePath, {},
385 "asset.import.vegetation-preset.source"));
386 out.materialShader = shader[1].str();
387 std::transform(out.materialShader.begin(), out.materialShader.end(), out.materialShader.begin(),
388 [](unsigned char value) { return static_cast<char>(std::tolower(value)); });
389 const std::regex instancingPattern(R"((?:^|\n)[ \t]*m_EnableInstancingVariants:[ \t]*([01])(?:\r?\n|$))");
390 std::smatch instancing;
391 if (std::regex_search(text, instancing, instancingPattern)) out.materialInstancing = instancing[1].str() == "1";
392 std::istringstream lines(text);
393 std::string line;
394 bool validKeywords = false;
395 while (std::getline(lines, line)) {
396 if (!line.empty() && line.back() == '\r') line.pop_back();
397 if (line == " m_ValidKeywords:") {
398 validKeywords = true;
399 continue;
400 }
401 if (validKeywords) {
402 if (line.starts_with(" - ")) {
403 if (line.size() > 4) out.materialKeywords.insert(line.substr(4));
404 continue;
405 }
406 validKeywords = false;
407 }
408 constexpr std::string_view legacy = " m_ShaderKeywords:";
409 if (line.starts_with(legacy)) {
410 std::istringstream words(line.substr(legacy.size()));
411 std::string keyword;
412 while (words >> keyword) out.materialKeywords.insert(std::move(keyword));
413 }
414 }
416 } catch (const std::regex_error&) {
418 Diagnostic::error(DiagnosticCode::Failed, "Unity material parser expression failed", sourcePath, {},
419 "asset.import.vegetation-preset.source"));
420 } catch (const std::bad_alloc&) {
422 Diagnostic::error(DiagnosticCode::Failed, "Unity material candidate allocation failed", sourcePath, {},
423 "asset.import.vegetation-preset.source"));
424 }
425}
426
428 std::string shaderName, std::string materialName,
429 std::string shaderPipeline, std::set<std::string> outputOptions) {
431 context.outputOptions = std::move(outputOptions);
432 context.shaderName = std::move(shaderName);
433 context.materialName = std::move(materialName);
434 context.shaderPipeline = std::move(shaderPipeline);
437 const auto addProperties = [&](const auto& values) {
438 for (const auto& [name, unused] : values) {
439 (void)unused;
441 }
442 };
443 addProperties(candidate.materialFloats);
444 addProperties(candidate.materialVectors);
445 addProperties(candidate.materialColors);
446 addProperties(candidate.materialTextureTransforms);
447 for (const auto& [name, unused] : candidate.materialTextures) {
448 (void)unused;
451 }
452 return context;
453}
454} // namespace eve::asset_import
SQObjectPtr key
Definition ECS.cpp:155
std::string name
Definition ECS.cpp:154
std::vector< std::uint8_t > blob
float maximum[3]
float minimum[3]
const GltfImportRequest & request
vk::UniqueImage image
std::vector< float > texcoords
JointPoint2D axis
size_t offset
std::uint64_t bytes
OceanMeshSettings mesh
std::array< uint32_t, 16 > material
std::string path
Definition PlayHost.cpp:111
std::set< std::string > values
Object::Ptr value
std::string hash
std::map< std::string, double > attributes
std::string attribute
Shader * shader
double number
bool found
unsigned line
std::string text
ScriptStructure out
std::string_view source
size_t end
AbilityInstancingPolicy instancing
std::string sourcePath
Json object
uint32_t seed
Definition TreeMesh.cpp:276
Direct Unity text-serialization adapter for TerrainData and Prefab assets.
std::vector< std::string_view > lines
const VegetationPresetContext & context
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
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
std::map< std::string, Value > Object
Definition Value.h:34
std::vector< Value > Array
Definition Value.h:33
Id128 child(std::string_view role) const noexcept
Derives a deterministic child UUID for a hierarchical identity.
Definition Identity.h:191
std::string sha256(std::span< const std::uint8_t > bytes)
Sha 256.
Result< AssetRef > assetRef(PersistentId id)
Asset ref.
std::string foldAscii(std::string value)
Fold ascii.
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.
Result< PreparedAssetImport > prepareUnityVegetationConversionImport(const UnityVegetationAssetImportRequest &request)
Convert and prepare one material, its packed images, and optional mesh as a single EVA candidate.
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...
Result< PreparedAssetImport > prepareUnityVegetationConversionBatch(const UnityVegetationBatchImportRequest &request)
Prepare several vegetation objects as one all-or-nothing EVA candidate.
EVENGINE_API_PLATFORM Result< VegetationConversionResult > executeUnityVegetationConversion(const UnityVegetationConversionRequest &request)
Decode a Unity Material, evaluate one TVE preset graph, and execute every output atomically.
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.
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.
Result< PreparedAssetImport > prepareUnityProjectImport(const UnityProjectImportRequest &request)
Import selected Unity assets, or discover a collection when both selectors are empty.
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...
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:27
@ TypeMismatch
A stable reference resolved to a different canonical domain type.
detail::StrongUint64< detail::SchemaVersionTag > SchemaVersion
Persistent data-format version; not a runtime replacement generation.
One owning regular-file entry inside an .eva archive.
Definition EvaArchive.h:31
std::vector< EvaAssetEntry > assets
Definition EvaManifest.h:69
std::vector< EvaDependency > dependencies
Definition EvaManifest.h:70
std::map< std::string, AssetRef > entrypoints
Definition EvaManifest.h:71
Owning, validated source archive candidate not yet published to disk/database.
std::vector< ImportFinding > findings
std::vector< asset::EvaArchiveEntry > entries
std::vector< ImportSourceMapping > sourceMappings
In-memory Unity project slice; keys are normalized project-relative paths.
Owning inputs for one atomically prepared Unity vegetation asset group.
Owning ordered set of independently converted vegetation objects published as one package.
Owning unpublished material, mesh and texture candidate mutated transactionally by preset commands.
std::map< std::string, std::array< double, 4 > > materialVectors
std::map< std::string, std::array< double, 4 > > materialColors
std::map< std::string, double > materialFloats
std::map< std::string, std::array< double, 4 > > materialTextureTransforms
std::map< std::string, std::string > materialTextures
Immutable source facts used by TVE preset predicates.
std::map< std::string, double > materialFloats