载入中...
搜索中...
未找到
UnityImporter.cpp
浏览该文件的文档.
2
3#include <utility>
4
7
8#include <charconv>
9#include <cmath>
10#include <regex>
11#include <set>
12#include <sstream>
13
14namespace eve::asset_import {
15namespace {
16
17Result<std::string> textFile(const UnityProjectImportRequest& request, const std::string& path) {
18 const auto found = request.files.find(path);
19 if (found == request.files.end())
21 DiagnosticCode::NotFound, "Unity source file was not supplied", path, {}, "asset.import"));
22 if (found->second.size() > request.limits.maximumSourceBytes)
24 "Unity source exceeds budget", path, {}, "asset.import"));
25 if (std::find(found->second.begin(), found->second.end(), std::uint8_t(0)) != found->second.end())
27 DiagnosticCode::Unsupported, "Unity adapter requires Force Text serialization", path, {}, "asset.import"));
28 return Result<std::string>::success({found->second.begin(), found->second.end()});
29}
30
31std::optional<std::string> firstMatch(std::string_view text, const std::regex& expression, std::size_t group = 1) {
32 std::match_results<std::string_view::const_iterator> match;
33 if (!std::regex_search(text.begin(), text.end(), match, expression) || group >= match.size()) return std::nullopt;
34 return std::string(match[group].first, match[group].second);
35}
36
37std::optional<std::uint64_t> parseUnsignedText(std::string_view text) {
38 std::uint64_t value = 0;
39 const auto result = std::from_chars(text.data(), text.data() + text.size(), value);
40 return result.ec == std::errc{} && result.ptr == text.data() + text.size() ? std::optional<std::uint64_t>(value)
41 : std::nullopt;
42}
43
44Result<float> parseFloat(std::string_view text, std::string path) {
45 std::string owned(text);
46 char* end = nullptr;
47 errno = 0;
48 const float value = std::strtof(owned.c_str(), &end);
49 if (errno != 0 || end != owned.c_str() + owned.size() || !std::isfinite(value))
50 return Result<float>::failure(Diagnostic::error(DiagnosticCode::ParseError, "Unity numeric value is invalid",
51 std::move(path), {}, "asset.import"));
53}
54
55const Value* member(const Value::Object& object, std::string_view name) {
56 const auto found = object.find(std::string(name));
57 return found == object.end() ? nullptr : &found->second;
58}
59
60std::string terrainDetailsPath(const UnityProjectImportRequest& request) {
61 if (!request.terrainDetailsPath.empty()) return request.terrainDetailsPath;
62 if (request.terrainDataPath.empty()) return {};
63 const auto adjacent = request.terrainDataPath + ".eve-details.json";
64 return request.files.contains(adjacent) ? adjacent : std::string{};
65}
66
67Result<void> appendTerrainDetailInstances(const UnityProjectImportRequest& request, CanonicalTerrainInput& terrain,
68 std::vector<ImportFinding>& findings) {
69 const auto detailsPath = terrainDetailsPath(request);
70 if (detailsPath.empty()) return Result<void>::success();
71 auto text = textFile(request, detailsPath);
72 if (!text) return Result<void>::failure(text.status());
73 auto parsed = Value::fromJson(text.value());
74 if (!parsed) return Result<void>::failure(parsed.status());
75 const auto* root = parsed.value().getIf<Value::Object>();
76 const Value* schema = root ? member(*root, "schema") : nullptr;
77 const Value* version = root ? member(*root, "schemaVersion") : nullptr;
78 const Value* instancesValue = root ? member(*root, "instances") : nullptr;
79 const Value* prototypesValue = root ? member(*root, "prototypes") : nullptr;
80 const auto* instances = instancesValue ? instancesValue->getIf<Value::Array>() : nullptr;
81 const auto* prototypes = prototypesValue ? prototypesValue->getIf<Value::Array>() : nullptr;
82 if (!schema || !schema->isString() || schema->asString() != "eve.unity-terrain-details" || !version ||
83 !version->isInt64() || (version->asInt() != 1 && version->asInt() != 2 && version->asInt() != 3) ||
84 !instances || !prototypes)
86 DiagnosticCode::Unsupported, "terrain detail sidecar must use eve.unity-terrain-details/1, /2 or /3",
87 detailsPath, {}, "asset.import"));
88 if (instances->size() > request.limits.maximumAssets || prototypes->size() > request.limits.maximumAssets ||
89 terrain.instances.size() > request.limits.maximumAssets - instances->size())
91 "terrain detail instance count exceeds import budget",
92 detailsPath, {}, "asset.import"));
93 auto number = [&](const Value::Object& object, std::string_view name, std::size_t index) -> Result<float> {
94 const Value* value = member(object, name);
95 if (!value || !value->isNumeric())
97 DiagnosticCode::ParseError, "terrain detail number is invalid",
98 "$.prototypes[" + std::to_string(index) + "]." + std::string(name), {}, "asset.import"));
99 const double parsed = value->isInt64() ? double(value->asInt()) : value->asDouble();
100 if (!std::isfinite(parsed) || parsed < -std::numeric_limits<float>::max() ||
101 parsed > std::numeric_limits<float>::max())
103 DiagnosticCode::ParseError, "terrain detail number is non-finite",
104 "$.prototypes[" + std::to_string(index) + "]." + std::string(name), {}, "asset.import"));
105 return Result<float>::success(static_cast<float>(parsed));
106 };
107 if (version->asInt() == 3) {
108 const Value* windValue = member(*root, "wavingGrass");
109 const auto* wind = windValue ? windValue->getIf<Value::Object>() : nullptr;
110 auto rootNumber = [&](std::string_view name) -> Result<float> {
111 const Value* value = wind ? member(*wind, name) : nullptr;
112 if (!value || !value->isNumeric())
114 Diagnostic::error(DiagnosticCode::ParseError, "terrain waving grass number is invalid",
115 "$.wavingGrass." + std::string(name), {}, "asset.import"));
116 const double parsed = value->isInt64() ? double(value->asInt()) : value->asDouble();
117 if (!std::isfinite(parsed) || parsed < 0.0 || parsed > std::numeric_limits<float>::max())
119 DiagnosticCode::InvalidArgument, "terrain waving grass number must be finite and nonnegative",
120 "$.wavingGrass." + std::string(name), {}, "asset.import"));
121 return Result<float>::success(static_cast<float>(parsed));
122 };
123 auto amount = rootNumber("amount");
124 auto speed = rootNumber("speed");
125 auto strength = rootNumber("strength");
126 const Value* tintValue = wind ? member(*wind, "tint") : nullptr;
127 const auto* tint = tintValue ? tintValue->getIf<Value::Array>() : nullptr;
128 if (!amount || !speed || !strength || !tint || tint->size() != 4)
130 !amount ? amount.status()
131 : !speed ? speed.status()
134 "terrain waving grass tint is invalid",
135 "$.wavingGrass.tint", {}, "asset.import"))
136 .status());
137 for (std::size_t component = 0; component < 4; ++component) {
138 if (!(*tint)[component].isNumeric())
140 "terrain waving grass tint is invalid",
141 "$.wavingGrass.tint", {}, "asset.import"));
142 const double value = (*tint)[component].isInt64() ? double((*tint)[component].asInt())
143 : (*tint)[component].asDouble();
144 if (!std::isfinite(value) || value < 0.0 || value > 1.0)
146 "terrain waving grass tint must be normalized RGBA",
147 "$.wavingGrass.tint", {}, "asset.import"));
148 terrain.wavingGrassTint[component] = static_cast<float>(value);
149 }
150 terrain.hasWavingGrass = true;
151 terrain.wavingGrassAmount = amount.value();
152 terrain.wavingGrassSpeed = speed.value();
153 terrain.wavingGrassStrength = strength.value();
154 }
155 std::vector<CanonicalTerrainDetailPrototype> detachedPrototypes;
156 detachedPrototypes.reserve(prototypes->size());
157 std::set<std::string> prototypeIds;
158 for (std::size_t index = 0; index < prototypes->size(); ++index) {
159 const auto* object = (*prototypes)[index].getIf<Value::Object>();
160 const Value* id = object ? member(*object, "prototype") : nullptr;
161 const Value* mode = object ? member(*object, "renderMode") : nullptr;
162 const Value* mesh = object ? member(*object, "usePrototypeMesh") : nullptr;
163 const Value* instancing = object ? member(*object, "useInstancing") : nullptr;
164 const Value* seed = object ? member(*object, "noiseSeed") : nullptr;
165 if (!object || !id || !id->isString() || id->asString().empty() ||
166 id->asString().size() > request.limits.maximumStringBytes ||
167 !isValidUtf8(id->asString(), Utf8NullPolicy::Reject) || !prototypeIds.emplace(id->asString()).second ||
168 !mode || !mode->isString() ||
169 (mode->asString() != "GrassBillboard" && mode->asString() != "Grass" && mode->asString() != "VertexLit") ||
170 !mesh || !mesh->isBool() || !instancing || !instancing->isBool() || !seed || !seed->isInt64())
172 Diagnostic::error(DiagnosticCode::ParseError, "terrain detail prototype metadata is invalid",
173 "$.prototypes[" + std::to_string(index) + "]", {}, "asset.import"));
174 CanonicalTerrainDetailPrototype prototype;
175 prototype.prototype = id->asString();
176 prototype.renderMode = mode->asString();
177 prototype.usePrototypeMesh = mesh->asBool();
178 prototype.useInstancing = instancing->asBool();
179 prototype.noiseSeed = seed->asInt();
180 const std::string texturePrefix = "unity-texture-guid:";
181 const std::string objectPrefix = "unity-guid:";
182 if (!prototype.usePrototypeMesh && prototype.prototype.starts_with(texturePrefix)) {
183 const auto guid = unity_detail::foldAscii(prototype.prototype.substr(texturePrefix.size()));
184 auto resource = detail::assetRef(request.package.packageId.child("unity:" + guid).child("image:default"));
185 if (!resource) return Result<void>::failure(resource.status());
186 prototype.resourceAsset = resource.value().format();
187 } else if (prototype.usePrototypeMesh && prototype.prototype.starts_with(objectPrefix)) {
188 const auto guid = unity_detail::foldAscii(prototype.prototype.substr(objectPrefix.size()));
189 auto resource = detail::assetRef(request.package.packageId.child("unity-prefab:" + guid));
190 if (!resource) return Result<void>::failure(resource.status());
191 prototype.resourceAsset = resource.value().format();
192 } else {
194 Diagnostic::error(DiagnosticCode::ParseError, "terrain detail prototype resource kind is inconsistent",
195 "$.prototypes[" + std::to_string(index) + "].prototype", {}, "asset.import"));
196 }
197 auto minWidth = number(*object, "minWidth", index);
198 auto maxWidth = number(*object, "maxWidth", index);
199 auto minHeight = number(*object, "minHeight", index);
200 auto maxHeight = number(*object, "maxHeight", index);
201 auto noiseSpread = number(*object, "noiseSpread", index);
202 auto density = number(*object, "density", index);
203 auto align = number(*object, "alignToGround", index);
204 auto jitter = number(*object, "positionJitter", index);
205 if (!minWidth || !maxWidth || !minHeight || !maxHeight || !noiseSpread || !density || !align || !jitter)
206 return Result<void>::failure(!minWidth ? minWidth.status()
207 : !maxWidth ? maxWidth.status()
208 : !minHeight ? minHeight.status()
209 : !maxHeight ? maxHeight.status()
210 : !noiseSpread ? noiseSpread.status()
211 : !density ? density.status()
212 : !align ? align.status()
213 : jitter.status());
214 prototype.minWidth = minWidth.value();
215 prototype.maxWidth = maxWidth.value();
216 prototype.minHeight = minHeight.value();
217 prototype.maxHeight = maxHeight.value();
218 prototype.noiseSpread = noiseSpread.value();
219 prototype.density = density.value();
220 prototype.alignToGround = align.value();
221 prototype.positionJitter = jitter.value();
222 if (version->asInt() >= 2) {
223 auto color = [&](std::string_view name, std::array<float, 4>& output) -> Result<void> {
224 const Value* value = member(*object, name);
225 const auto* array = value ? value->getIf<Value::Array>() : nullptr;
226 if (!array || array->size() != 4)
228 DiagnosticCode::ParseError, "terrain detail color is invalid",
229 "$.prototypes[" + std::to_string(index) + "]." + std::string(name), {}, "asset.import"));
230 for (std::size_t component = 0; component < 4; ++component) {
231 if (!(*array)[component].isNumeric())
233 DiagnosticCode::ParseError, "terrain detail color is invalid", {}, {}, "asset.import"));
234 const double value = (*array)[component].isInt64() ? double((*array)[component].asInt())
235 : (*array)[component].asDouble();
236 if (!std::isfinite(value) || value < 0.0 || value > 1.0)
238 DiagnosticCode::InvalidArgument, "terrain detail color must be finite normalized RGBA", {},
239 {}, "asset.import"));
240 output[component] = static_cast<float>(value);
241 }
242 return Result<void>::success();
243 };
244 auto healthy = color("healthyColor", prototype.healthyColor);
245 auto dry = color("dryColor", prototype.dryColor);
246 auto bend = number(*object, "bendFactor", index);
247 auto padding = number(*object, "holeEdgePadding", index);
248 const Value* densityScaling = member(*object, "useDensityScaling");
249 if (!healthy || !dry || !bend || !padding || !densityScaling || !densityScaling->isBool())
251 !healthy ? healthy.status()
252 : !dry ? dry.status()
253 : !bend ? bend.status()
254 : !padding ? padding.status()
256 "terrain detail density scaling is invalid",
257 {}, {}, "asset.import"))
258 .status());
259 prototype.bendFactor = bend.value();
260 prototype.holeEdgePadding = padding.value();
261 prototype.useDensityScaling = densityScaling->asBool();
262 }
263 detachedPrototypes.push_back(std::move(prototype));
264 }
265 auto vector = [&](const Value::Object& object, std::string_view name, std::size_t count, float* output,
266 std::size_t index) -> Result<void> {
267 const Value* value = member(object, name);
268 const auto* array = value ? value->getIf<Value::Array>() : nullptr;
269 if (!array || array->size() != count)
271 DiagnosticCode::ParseError, "terrain detail vector is invalid",
272 "$.instances[" + std::to_string(index) + "]." + std::string(name), {}, "asset.import"));
273 for (std::size_t component = 0; component < count; ++component) {
274 if (!(*array)[component].isNumeric())
276 DiagnosticCode::ParseError, "terrain detail vector is non-numeric",
277 "$.instances[" + std::to_string(index) + "]." + std::string(name), {}, "asset.import"));
278 const double number =
279 (*array)[component].isInt64() ? double((*array)[component].asInt()) : (*array)[component].asDouble();
280 if (!std::isfinite(number) || number < -std::numeric_limits<float>::max() ||
281 number > std::numeric_limits<float>::max())
283 DiagnosticCode::ParseError, "terrain detail vector is non-finite",
284 "$.instances[" + std::to_string(index) + "]." + std::string(name), {}, "asset.import"));
285 output[component] = static_cast<float>(number);
286 }
287 return Result<void>::success();
288 };
289 std::vector<CanonicalTerrainInstance> detached;
290 detached.reserve(instances->size());
291 for (std::size_t index = 0; index < instances->size(); ++index) {
292 const auto* object = (*instances)[index].getIf<Value::Object>();
293 const Value* prototype = object ? member(*object, "prototype") : nullptr;
294 if (!object || !prototype || !prototype->isString() || prototype->asString().empty() ||
295 prototype->asString().size() > request.limits.maximumStringBytes ||
296 !isValidUtf8(prototype->asString(), Utf8NullPolicy::Reject))
298 Diagnostic::error(DiagnosticCode::ParseError, "terrain detail prototype is invalid",
299 "$.instances[" + std::to_string(index) + "].prototype", {}, "asset.import"));
300 if (!prototypeIds.contains(prototype->asString()))
302 Diagnostic::error(DiagnosticCode::NotFound, "terrain detail instance prototype is undeclared",
303 "$.instances[" + std::to_string(index) + "].prototype", {}, "asset.import"));
304 CanonicalTerrainInstance instance;
305 instance.prototype = prototype->asString();
306 auto position = vector(*object, "position", 3, instance.position, index);
307 auto rotation = vector(*object, "rotation", 4, instance.rotation, index);
308 auto scale = vector(*object, "scale", 3, instance.scale, index);
309 if (!position || !rotation || !scale)
310 return Result<void>::failure(!position ? position.status()
312 : scale.status());
313 detached.push_back(std::move(instance));
314 }
315 terrain.detailPrototypes.insert(terrain.detailPrototypes.end(), std::make_move_iterator(detachedPrototypes.begin()),
316 std::make_move_iterator(detachedPrototypes.end()));
317 terrain.instances.insert(terrain.instances.end(), std::make_move_iterator(detached.begin()),
318 std::make_move_iterator(detached.end()));
319 findings.push_back({detailsPath, "TerrainData.detail-instances", ImportDisposition::Translated,
320 "Unity public ComputeDetailInstanceTransforms output imported as canonical instances"});
321 return Result<void>::success();
322}
323
324std::optional<std::string> guidFromMeta(const UnityProjectImportRequest& request, const std::string& assetPath) {
325 const auto found = request.files.find(assetPath + ".meta");
326 if (found == request.files.end()) return std::nullopt;
327 const std::string text(found->second.begin(), found->second.end());
328 auto guid = firstMatch(text, std::regex(R"((?:^|\n)guid:\s*([0-9a-fA-F]{32})(?:\r?\n|\r?$))"));
329 if (guid) *guid = unity_detail::foldAscii(std::move(*guid));
330 return guid;
331}
332
333std::map<std::string, std::string> guidPaths(const UnityProjectImportRequest& request) {
334 std::map<std::string, std::string> result;
335 for (const auto& [path, bytes] : request.files) {
336 if (!path.ends_with(".meta")) continue;
337 const std::string text(bytes.begin(), bytes.end());
338 auto guid = firstMatch(text, std::regex(R"((?:^|\n)guid:\s*([0-9a-fA-F]{32})(?:\r?\n|\r?$))"));
339 if (guid) result.emplace(unity_detail::foldAscii(*guid), path.substr(0, path.size() - 5));
340 }
341 return result;
342}
343
344std::vector<std::string> sectionEntries(std::string_view yaml, std::string_view heading) {
345 const auto start = yaml.find(heading);
346 if (start == std::string_view::npos) return {};
347 const auto lineEnd = yaml.find('\n', start);
348 if (lineEnd == std::string_view::npos) return {};
349 std::vector<std::string> entries;
350 std::string current;
351 std::istringstream lines(std::string(yaml.substr(lineEnd + 1)));
352 std::string line;
353 while (std::getline(lines, line)) {
354 if (line.starts_with(" m_") && !line.starts_with(" ")) break;
355 if (line.starts_with(" - ") || line.starts_with(" - ")) {
356 if (!current.empty()) entries.push_back(std::move(current));
357 current = line + "\n";
358 } else if (!current.empty()) {
359 current += line + "\n";
360 }
361 }
362 if (!current.empty()) entries.push_back(std::move(current));
363 return entries;
364}
365
366Result<CanonicalTerrainInput> parseTerrain(const UnityProjectImportRequest& request,
367 const std::map<std::string, std::string>& paths,
368 std::vector<ImportFinding>& findings) {
369 auto textResult = textFile(request, request.terrainDataPath);
370 if (!textResult) return Result<CanonicalTerrainInput>::failure(textResult.status());
371 const std::string yaml = std::move(textResult).takeValue();
372 auto resolutionText = firstMatch(yaml, std::regex(R"((?:m_HeightmapResolution|m_Resolution):\s*([0-9]+))"));
373 auto scaleMatchX =
374 firstMatch(yaml, std::regex(R"(m_HeightmapScale:\s*\{x:\s*([^,]+),\s*y:\s*([^,]+),\s*z:\s*([^}]+)\})"), 1);
375 auto scaleMatchY =
376 firstMatch(yaml, std::regex(R"(m_HeightmapScale:\s*\{x:\s*([^,]+),\s*y:\s*([^,]+),\s*z:\s*([^}]+)\})"), 2);
377 auto scaleMatchZ =
378 firstMatch(yaml, std::regex(R"(m_HeightmapScale:\s*\{x:\s*([^,]+),\s*y:\s*([^,]+),\s*z:\s*([^}]+)\})"), 3);
379 auto heightsHex = firstMatch(yaml, std::regex(R"(m_Heights:\s*([0-9a-fA-F]+))"));
380 if (!resolutionText || !scaleMatchX || !scaleMatchY || !scaleMatchZ || !heightsHex)
382 Diagnostic::error(DiagnosticCode::ParseError, "Unity TerrainData heightmap fields are incomplete",
383 request.terrainDataPath, {}, "asset.import"));
384 std::uint64_t resolution = 0;
385 for (char digit : *resolutionText) {
386 if (resolution > (std::numeric_limits<std::uint32_t>::max() - (digit - '0')) / 10)
388 DiagnosticCode::InvalidArgument, "Unity terrain resolution overflows", {}, {}, "asset.import"));
389 resolution = resolution * 10 + (digit - '0');
390 }
391 if (resolution < 2 || resolution > request.limits.maximumVerticesPerPrimitive ||
392 resolution > std::numeric_limits<std::uint64_t>::max() / resolution)
394 DiagnosticCode::InvalidArgument, "Unity terrain resolution is outside limits", {}, {}, "asset.import"));
395 const std::uint64_t samples = resolution * resolution;
396 if (heightsHex->size() != samples * 4)
398 DiagnosticCode::ParseError, "Unity m_Heights must contain one little-endian UInt16 per sample", {}, {},
399 "asset.import"));
400 auto spacingX = parseFloat(*scaleMatchX, "m_HeightmapScale.x");
401 auto scaleY = parseFloat(*scaleMatchY, "m_HeightmapScale.y");
402 auto spacingZ = parseFloat(*scaleMatchZ, "m_HeightmapScale.z");
403 if (!spacingX || !scaleY || !spacingZ)
405 Diagnostic::error(DiagnosticCode::ParseError, "Unity terrain scale is invalid", {}, {}, "asset.import"));
406 const auto nibble = [](char value) -> int {
407 if (value >= '0' && value <= '9') return value - '0';
408 if (value >= 'a' && value <= 'f') return value - 'a' + 10;
409 if (value >= 'A' && value <= 'F') return value - 'A' + 10;
410 return -1;
411 };
412 std::vector<std::uint16_t> sourceHeights(samples);
413 for (std::size_t index = 0; index < samples; ++index) {
414 const std::size_t at = index * 4;
415 sourceHeights[index] =
416 static_cast<std::uint16_t>((nibble((*heightsHex)[at]) << 4) | nibble((*heightsHex)[at + 1]) |
417 (nibble((*heightsHex)[at + 2]) << 12) | (nibble((*heightsHex)[at + 3]) << 8));
418 }
419 CanonicalTerrainInput terrain;
420 const auto imageAsset = [&](std::string_view guid) {
421 return std::string("asset://") +
422 request.package.packageId.child("unity:" + unity_detail::foldAscii(std::string(guid)))
423 .child("image:default")
424 .format();
425 };
426 terrain.width = terrain.height = static_cast<std::uint32_t>(resolution);
427 terrain.spacingX = spacingX.value();
428 terrain.spacingZ = spacingZ.value();
429 terrain.heightsMeters.resize(samples);
430 // Unity rows advance +Z; canonical forward is -Z, so reverse rows while preserving winding.
431 for (std::uint32_t row = 0; row < terrain.height; ++row)
432 for (std::uint32_t column = 0; column < terrain.width; ++column)
433 terrain.heightsMeters[std::size_t(row) * terrain.width + column] =
434 float(sourceHeights[std::size_t(terrain.height - 1 - row) * terrain.width + column]) / 65535.0f *
435 scaleY.value();
436 terrain.sourceTransform = {{"source", Value("unity-left-handed-x-right-y-up-z-forward")},
437 {"conversion", Value("reflect-z-and-reverse-height-rows")},
438 {"heightScaleMeters", Value(double(scaleY.value()))}};
439
440 if (auto holes = firstMatch(yaml, std::regex(R"(m_HolesTexture:.*guid:\s*([0-9a-fA-F]{32}))"))) {
441 terrain.holesSource = "unity-guid:" + unity_detail::foldAscii(*holes);
442 terrain.holesAsset = imageAsset(*holes);
443 }
444 const auto controls = sectionEntries(yaml, "m_AlphamapTextures:");
445 if (controls.size() > terrain.controlSources.size())
447 Diagnostic::error(DiagnosticCode::Unsupported, "TVE terrain supports at most four control textures",
448 request.terrainDataPath, {}, "asset.import"));
449 for (std::size_t index = 0; index < controls.size(); ++index) {
450 if (auto guid = firstMatch(controls[index], std::regex(R"(guid:\s*([0-9a-fA-F]{32}))"))) {
451 terrain.controlSources[index] = "unity-guid:" + unity_detail::foldAscii(*guid);
452 terrain.controlAssets[index] = imageAsset(*guid);
453 }
454 }
455 for (const auto& entry : sectionEntries(yaml, "m_TerrainLayers:")) {
456 auto guid = firstMatch(entry, std::regex(R"(guid:\s*([0-9a-fA-F]{32}))"));
457 if (!guid) continue;
458 CanonicalTerrainLayer layer;
459 const auto resolved = paths.find(unity_detail::foldAscii(*guid));
460 layer.name = resolved == paths.end() ? *guid : resolved->second;
461 if (resolved != paths.end()) {
462 auto layerText = textFile(request, resolved->second);
463 if (layerText) {
464 if (auto diffuse =
465 firstMatch(layerText.value(), std::regex(R"(m_DiffuseTexture:.*guid:\s*([0-9a-fA-F]{32}))"))) {
466 layer.diffuseSource = "unity-guid:" + *diffuse;
467 layer.diffuseAsset = imageAsset(*diffuse);
468 }
469 if (auto normal = firstMatch(layerText.value(),
470 std::regex(R"(m_NormalMapTexture:.*guid:\s*([0-9a-fA-F]{32}))"))) {
471 layer.normalSource = "unity-guid:" + *normal;
472 layer.normalAsset = imageAsset(*normal);
473 }
474 if (auto mask =
475 firstMatch(layerText.value(), std::regex(R"(m_MaskMapTexture:.*guid:\s*([0-9a-fA-F]{32}))"))) {
476 layer.maskSource = "unity-guid:" + *mask;
477 layer.maskAsset = imageAsset(*mask);
478 }
479 auto parseVec = [&](const char* name, auto& output) -> Result<void> {
480 const std::string expression =
481 std::string(name) + R"(:\s*\{x:\s*([^,]+),\s*y:\s*([^,]+),\s*z:\s*([^,]+),\s*w:\s*([^}]+)\})";
482 std::match_results<std::string::const_iterator> match;
483 if (!std::regex_search(layerText.value(), match, std::regex(expression)))
484 return Result<void>::success();
485 for (std::size_t component = 0; component < 4; ++component) {
486 auto parsed = parseFloat(match[component + 1].str(), resolved->second + "." + name);
487 if (!parsed) return Result<void>::failure(parsed.status());
488 output[component] = parsed.value();
489 }
490 return Result<void>::success();
491 };
492 for (auto [name, value] : {std::pair{"m_MaskMapRemapMin", &layer.maskRemapMinimum},
493 {"m_MaskMapRemapMax", &layer.maskRemapMaximum},
494 {"m_Specular", &layer.specular}}) {
495 auto parsed = parseVec(name, *value);
496 if (!parsed) return Result<CanonicalTerrainInput>::failure(parsed.status());
497 }
498 const std::regex tilePattern(R"(m_TileSize:\s*\{x:\s*([^,]+),\s*y:\s*([^}]+)\})");
499 std::match_results<std::string::const_iterator> tileMatch;
500 if (std::regex_search(layerText.value(), tileMatch, tilePattern)) {
501 auto x = parseFloat(tileMatch[1].str(), resolved->second + ".m_TileSize.x");
502 auto y = parseFloat(tileMatch[2].str(), resolved->second + ".m_TileSize.y");
503 if (!x || !y)
505 DiagnosticCode::ParseError, "Unity terrain tile size is invalid", {}, {}, "asset.import"));
506 layer.tileScaleMeters = {x.value(), y.value()};
507 layer.tileSizeMeters = x.value();
508 }
509 const std::regex offsetPattern(R"(m_TileOffset:\s*\{x:\s*([^,]+),\s*y:\s*([^}]+)\})");
510 std::match_results<std::string::const_iterator> offsetMatch;
511 if (std::regex_search(layerText.value(), offsetMatch, offsetPattern)) {
512 auto x = parseFloat(offsetMatch[1].str(), resolved->second + ".m_TileOffset.x");
513 auto y = parseFloat(offsetMatch[2].str(), resolved->second + ".m_TileOffset.y");
514 if (!x || !y)
516 Diagnostic::error(DiagnosticCode::ParseError, "Unity terrain tile offset is invalid", {},
517 {}, "asset.import"));
518 layer.tileOffsetMeters = {x.value(), y.value()};
519 }
520 for (auto [name, target] : {std::pair{"m_Metallic", &layer.metallic},
521 {"m_NormalScale", &layer.normalScale},
522 {"m_Smoothness", &layer.smoothness}}) {
523 if (auto encoded =
524 firstMatch(layerText.value(), std::regex(std::string(name) + R"(:\s*([^\r\n]+))"))) {
525 auto parsed = parseFloat(*encoded, resolved->second + "." + name);
526 if (!parsed) return Result<CanonicalTerrainInput>::failure(parsed.status());
527 *target = parsed.value();
528 }
529 }
530 }
531 }
532 terrain.layers.push_back(std::move(layer));
533 }
534
535 std::vector<std::string> prototypes;
536 for (const auto& entry : sectionEntries(yaml, "m_TreePrototypes:")) {
537 auto guid = firstMatch(entry, std::regex(R"(guid:\s*([0-9a-fA-F]{32}))"));
538 prototypes.push_back(guid ? "unity-guid:" + *guid : "unity-missing-prototype");
539 }
540 for (const auto& entry : sectionEntries(yaml, "m_TreeInstances:")) {
541 auto position = std::regex(R"(position:\s*\{x:\s*([^,]+),\s*y:\s*([^,]+),\s*z:\s*([^}]+)\})");
542 auto x = firstMatch(entry, position, 1);
543 auto y = firstMatch(entry, position, 2);
544 auto z = firstMatch(entry, position, 3);
545 auto prototype = firstMatch(entry, std::regex(R"(prototypeIndex:\s*([0-9]+))"));
546 if (!x || !y || !z || !prototype) continue;
547 const auto prototypeValue = parseUnsignedText(*prototype);
548 if (!prototypeValue || *prototypeValue >= prototypes.size())
550 DiagnosticCode::ParseError, "Unity tree prototype index is invalid", {}, {}, "asset.import"));
551 const std::size_t prototypeIndex = static_cast<std::size_t>(*prototypeValue);
552 auto px = parseFloat(*x, "tree.position.x");
553 auto py = parseFloat(*y, "tree.position.y");
554 auto pz = parseFloat(*z, "tree.position.z");
555 if (!px || !py || !pz)
557 DiagnosticCode::ParseError, "Unity tree position is invalid", {}, {}, "asset.import"));
558 CanonicalTerrainInstance instance;
559 instance.prototype = prototypes[prototypeIndex];
560 instance.position[0] = px.value() * spacingX.value() * float(resolution - 1);
561 instance.position[1] = py.value() * scaleY.value();
562 instance.position[2] = -pz.value() * spacingZ.value() * float(resolution - 1);
563 if (auto rotation = firstMatch(entry, std::regex(R"(rotation:\s*([^\r\n]+))"))) {
564 auto value = parseFloat(*rotation, "tree.rotation");
565 if (value) {
566 instance.rotation[1] = std::sin(-value.value() * 0.5f);
567 instance.rotation[3] = std::cos(-value.value() * 0.5f);
568 }
569 }
570 if (auto width = firstMatch(entry, std::regex(R"(widthScale:\s*([^\r\n]+))"))) {
571 auto value = parseFloat(*width, "tree.widthScale");
572 if (value) instance.scale[0] = instance.scale[2] = value.value();
573 }
574 if (auto height = firstMatch(entry, std::regex(R"(heightScale:\s*([^\r\n]+))"))) {
575 auto value = parseFloat(*height, "tree.heightScale");
576 if (value) instance.scale[1] = value.value();
577 }
578 terrain.instances.push_back(std::move(instance));
579 }
580 if (yaml.find("m_DetailPrototypes:") != std::string::npos) {
581 const bool hasDetailSidecar = !terrainDetailsPath(request).empty();
582 findings.push_back(
583 {request.terrainDataPath, "TerrainData.detail-prototypes",
585 !hasDetailSidecar
586 ? "detail data requires an eve.unity-terrain-details/3 public-API export"
587 : "detail prototypes and placement are supplied by the public-API sidecar"});
588 }
589 findings.push_back({request.terrainDataPath, "TerrainData.heightmap", ImportDisposition::Translated,
590 "UInt16 heights converted to metres and canonical Z"});
592}
593
594struct UnityObject {
595 std::int64_t fileId = 0;
596 std::uint32_t classId = 0;
597 std::string body;
598};
599
600std::vector<UnityObject> documents(std::string_view yaml) {
601 const std::regex header(R"(^---\s*!u!([0-9]+)\s*&(-?[0-9]+).*$)", std::regex::multiline);
602 struct Start {
603 std::size_t header;
604 std::size_t body;
605 UnityObject object;
606 };
607 std::vector<Start> starts;
608 for (std::cregex_iterator it(yaml.data(), yaml.data() + yaml.size(), header), end; it != end; ++it) {
609 const std::string signedText = (*it)[2].str();
610 std::int64_t signedId = 0;
611 const auto parsedId = std::from_chars(signedText.data(), signedText.data() + signedText.size(), signedId);
612 const auto classText = (*it)[1].str();
613 const auto classId = parseUnsignedText(classText);
614 if (parsedId.ec != std::errc{} || parsedId.ptr != signedText.data() + signedText.size() || !classId ||
615 *classId > std::numeric_limits<std::uint32_t>::max())
616 continue;
617 starts.push_back({static_cast<std::size_t>((*it).position()),
618 static_cast<std::size_t>((*it).position() + (*it).length()),
619 {signedId, static_cast<std::uint32_t>(*classId), {}}});
620 }
621 std::vector<UnityObject> result;
622 for (std::size_t index = 0; index < starts.size(); ++index) {
623 const std::size_t end = index + 1 < starts.size() ? starts[index + 1].header : yaml.size();
624 starts[index].object.body = std::string(yaml.substr(starts[index].body, end - starts[index].body));
625 result.push_back(std::move(starts[index].object));
626 }
627 return result;
628}
629
630Result<void> appendPrefab(const UnityProjectImportRequest& request, PreparedAssetImport& output,
631 std::vector<ImportFinding>& findings, const std::string& prefabPath) {
632 if (prefabPath.empty()) return Result<void>::success();
633 auto text = textFile(request, prefabPath);
634 if (!text) return Result<void>::failure(text.status());
635 if (std::regex_search(text.value(), std::regex(R"((?:^|\n)---\s*!u!(?:1|4|224)\s*&-)")))
638 "prefab signed hierarchy IDs are indexed but cannot yet be represented by scene-template",
639 prefabPath, {}, "asset.import"));
640 const auto prefabGuid = guidFromMeta(request, prefabPath);
641 if (!prefabGuid)
642 return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "Unity prefab .meta GUID is required",
643 prefabPath + ".meta", {}, "asset.import.unity"));
644 const auto objects = documents(text.value());
645 if (objects.size() > request.limits.maximumAssets)
647 "Unity prefab object count exceeds budget", prefabPath, {},
648 "asset.import"));
649 std::map<std::uint64_t, std::string> gameNames;
650 std::map<std::uint64_t, bool> gameVisibility;
651 for (const auto& object : objects) {
652 if (object.classId == 1) {
653 auto name = firstMatch(object.body, std::regex(R"(m_Name:\s*([^\r\n]+))"));
654 gameNames[object.fileId] = name.value_or("GameObject");
655 gameVisibility[object.fileId] = !std::regex_search(object.body, std::regex(R"(m_IsActive:\s*0(?:\s|$))"));
656 } else if (object.classId == 114) {
657 findings.push_back({prefabPath, "MonoBehaviour:" + std::to_string(object.fileId),
659 "C# behaviour is not executed or translated by the data importer"});
660 } else if (object.classId != 4) {
661 findings.push_back(
662 {prefabPath, "Prefab.component:" + std::to_string(object.classId) + ":" + std::to_string(object.fileId),
664 "component behavior is not converted; only GameObject/Transform hierarchy is available"});
665 }
666 }
668 for (const auto& object : objects) {
669 if (object.classId != 4 && object.classId != 224) continue;
670 auto game = firstMatch(object.body, std::regex(R"(m_GameObject:\s*\{fileID:\s*(-?[0-9]+)\})"));
671 auto father = firstMatch(object.body, std::regex(R"(m_Father:\s*\{fileID:\s*(-?[0-9]+)\})"));
672 const std::regex position(R"(m_LocalPosition:\s*\{x:\s*([^,]+),\s*y:\s*([^,]+),\s*z:\s*([^}]+)\})");
673 const std::regex rotation(
674 R"(m_LocalRotation:\s*\{x:\s*([^,]+),\s*y:\s*([^,]+),\s*z:\s*([^,]+),\s*w:\s*([^}]+)\})");
675 const std::regex scale(R"(m_LocalScale:\s*\{x:\s*([^,]+),\s*y:\s*([^,]+),\s*z:\s*([^}]+)\})");
676 if (!game) continue;
677 auto vector = [&](const std::regex& regex, std::size_t count, float* target, bool reflect) -> Result<void> {
678 for (std::size_t component = 0; component < count; ++component) {
679 auto field = firstMatch(object.body, regex, component + 1);
680 if (!field)
682 "Unity transform field is missing", prefabPath, {},
683 "asset.import.unity"));
684 auto parsed = parseFloat(*field, prefabPath);
685 if (!parsed) return Result<void>::failure(parsed.status());
686 target[component] = parsed.value();
687 }
688 if (reflect) target[2] = -target[2];
689 return Result<void>::success();
690 };
691 float p[3], q[4], s[3];
692 auto pResult = vector(position, 3, p, true);
693 if (!pResult) return pResult;
694 auto qResult = vector(rotation, 4, q, false);
695 if (!qResult) return qResult;
696 q[0] = -q[0];
697 q[1] = -q[1];
698 auto sResult = vector(scale, 3, s, false);
699 if (!sResult) return sResult;
700 const auto gameIdValue = parseUnsignedText(*game);
701 const auto parentIdValue = father ? parseUnsignedText(*father) : std::optional<std::uint64_t>(0);
702 if (!gameIdValue || !parentIdValue)
704 DiagnosticCode::ParseError, "Unity transform fileID overflows", prefabPath, {}, "asset.import.unity"));
705 const auto gameId = *gameIdValue;
706 const std::uint64_t parentId = *parentIdValue;
708 node["objectId"] = Value(
709 request.package.packageId.child("unity:" + *prefabGuid + ":" + std::to_string(object.fileId)).format());
710 node["sourceFileId"] = Value(static_cast<std::int64_t>(object.fileId));
711 node["name"] = Value(gameNames.contains(gameId) ? gameNames[gameId] : "GameObject");
712 node["visible"] = Value(!gameVisibility.contains(gameId) || gameVisibility.at(gameId));
713 node["parentSourceFileId"] = Value(static_cast<std::int64_t>(parentId));
714 node["position"] = Value(Value::Array{Value(double(p[0])), Value(double(p[1])), Value(double(p[2]))});
715 node["rotation"] =
716 Value(Value::Array{Value(double(q[0])), Value(double(q[1])), Value(double(q[2])), Value(double(q[3]))});
717 node["scale"] = Value(Value::Array{Value(double(s[0])), Value(double(s[1])), Value(double(s[2]))});
718 nodes.emplace_back(std::move(node));
719 }
720 if (nodes.empty())
723 "prefab has no directly convertible Transform nodes; nested prefab expansion is required",
724 prefabPath, {}, "asset.import"));
725 const PersistentId sceneId = request.package.packageId.child("unity-prefab:" + *prefabGuid);
726 Value::Object definition;
727 definition["schema"] = Value("eve.scene-template");
728 definition["schemaVersion"] = Value(std::int64_t(3));
729 definition["sourceGuid"] = Value(*prefabGuid);
730 definition["nodes"] = Value(std::move(nodes));
731 definition["renderers"] = Value(Value::Array{});
732 definition["coordinateSystem"] = Value("right-handed-x-right-y-up-minus-z-forward");
733 auto encoded = Value(std::move(definition)).toJson();
734 if (!encoded) return Result<void>::failure(encoded.status());
735 std::string definitionText = std::move(encoded).takeValue();
736 const std::string path = "assets/" + sceneId.format() + "/asset.json";
737 auto reference = detail::assetRef(sceneId);
738 if (!reference) return Result<void>::failure(reference.status());
739 output.manifest.assets.push_back(
740 {std::move(reference).takeValue(),
741 "eve.scene-template",
742 SchemaVersion(3),
743 path,
744 detail::sha256(std::span<const std::uint8_t>(reinterpret_cast<const std::uint8_t*>(definitionText.data()),
745 definitionText.size())),
746 {"scene", "source:unity-prefab"}});
747 output.entries.push_back({path, {definitionText.begin(), definitionText.end()}});
748 if (output.manifest.entrypoints.empty()) {
749 auto entrypoint = detail::assetRef(sceneId);
750 if (!entrypoint) return Result<void>::failure(entrypoint.status());
751 output.manifest.entrypoints.emplace("default", std::move(entrypoint).takeValue());
752 }
753 findings.push_back({prefabPath, "Prefab.GameObject.Transform", ImportDisposition::Translated,
754 "GUID/fileID hierarchy converted to canonical TRS"});
755 return Result<void>::success();
756}
757
758} // namespace
759
761 auto manifest = detail::baseManifest(request.package, "eve.unity-prefab/1");
762 if (!manifest) return Result<PreparedAssetImport>::failure(manifest.status());
764 output.manifest = std::move(manifest).takeValue();
765 auto prefab = appendPrefab(request, output, output.findings, path);
767 for (const auto& asset : output.manifest.assets) output.sourceMappings.push_back({"Prefab#Transform", asset.asset});
769}
770
772 if (request.files.empty() || request.package.packageId.isNil())
774 Diagnostic::error(DiagnosticCode::InvalidArgument, "Unity project files and package identity are required",
775 {}, {}, "asset.import"));
776 auto sourceIndex = indexUnitySources(request.files, request.limits);
777 if (!sourceIndex) return Result<PreparedAssetImport>::failure(sourceIndex.status());
778 if (request.terrainDataPath.empty() && request.prefabPath.empty())
779 return prepareUnityCollection(request, sourceIndex.value());
780 std::vector<ImportFinding> findings = sourceIndex.value().findings;
782 if (!request.terrainDataPath.empty()) {
783 auto terrain = parseTerrain(request, guidPaths(request), findings);
785 auto details = appendTerrainDetailInstances(request, terrain.value(), findings);
786 if (!details) return Result<PreparedAssetImport>::failure(details.status());
787 auto prepared =
788 prepareCanonicalTerrainImport(request.package, terrain.value(), "eve.unity-terrain/1", request.limits);
789 if (!prepared) return Result<PreparedAssetImport>::failure(prepared.status());
790 output = std::move(prepared).takeValue();
791 if (!terrain.value().detailPrototypes.empty()) {
792 auto collection = prepareUnityCollection(request, sourceIndex.value());
793 if (collection) {
794 std::set<PersistentId> selected;
795 for (const auto& prototype : terrain.value().detailPrototypes) {
796 auto resource = AssetRef::parse(prototype.resourceAsset);
797 if (resource) selected.emplace(resource.value().id());
798 }
799 bool changed = true;
800 while (changed) {
801 changed = false;
802 for (const auto& dependency : collection.value().manifest.dependencies)
803 if (selected.contains(dependency.from.id()) && selected.emplace(dependency.to.id()).second)
804 changed = true;
805 }
806 std::set<std::string> runtimePrefixes;
807 for (const auto& asset : collection.value().manifest.assets) {
808 if (!selected.contains(asset.asset.id())) continue;
809 const bool duplicate = std::any_of(output.manifest.assets.begin(), output.manifest.assets.end(),
810 [&](const auto& existing) {
811 return existing.asset.id() == asset.asset.id();
812 });
813 if (!duplicate) output.manifest.assets.push_back(asset);
814 runtimePrefixes.emplace("assets/" + asset.asset.id().format() + "/");
815 }
816 for (const auto& dependency : collection.value().manifest.dependencies)
817 if (selected.contains(dependency.from.id()) && selected.contains(dependency.to.id()))
818 output.manifest.dependencies.push_back(dependency);
819 for (const auto& entry : collection.value().entries)
820 if (std::any_of(runtimePrefixes.begin(), runtimePrefixes.end(), [&](const auto& prefix) {
821 return entry.path.starts_with(prefix);
822 }))
823 output.entries.push_back(entry);
824 }
825 }
826 } else {
827 auto manifest = detail::baseManifest(request.package, "eve.unity-prefab/1");
828 if (!manifest) return Result<PreparedAssetImport>::failure(manifest.status());
829 output.manifest = std::move(manifest).takeValue();
830 }
831 auto prefab = appendPrefab(request, output, findings, request.prefabPath);
833 output.manifest.provenance["sourceEngine"] = Value("unity");
834 output.manifest.provenance["sourceCoordinateSystem"] = Value("left-handed-x-right-y-up-z-forward");
835 output.findings.insert(output.findings.end(), std::make_move_iterator(findings.begin()),
836 std::make_move_iterator(findings.end()));
837 for (const auto& asset : output.manifest.assets) {
838 std::string sourceObject = request.terrainDataPath + "#" + asset.type;
839 if (asset.type == "eve.scene-template") sourceObject = request.prefabPath + "#Transform";
840 output.sourceMappings.push_back({std::move(sourceObject), asset.asset});
841 }
842 auto report = detail::finalizeImportReport(output, request.package, "unity", "force-text",
843 {{"serialization", Value("force-text")}});
844 if (!report) return Result<PreparedAssetImport>::failure(report.status());
846}
847
848} // namespace eve::asset_import
double z
double y
double x
LogicalId target
Duration start
int root
Definition AnimSmr.cpp:119
std::string selected
std::string prefab
std::string output
std::string terrain
ActiveSource owned
AuthorityStoreHandleRef reference
Definition Authority.cpp:24
const std::string & s
std::unordered_map< std::string, QuestRuntime > entries
int mask
bool changed
glm::vec4 p[6]
std::string name
Definition ECS.cpp:154
std::uint64_t parentId
float strength
float density
const GltfImportRequest & request
wgpu::PopErrorScopeStatus status
glm::vec4 tint
std::array< double, 10 > q
std::int32_t second
std::int32_t first
std::vector< Colorf > px
std::uint32_t height
std::uint32_t width
std::array< float, 4 > rotation
std::array< float, 3 > position
std::array< float, 3 > scale
std::map< std::string, Node > nodes
std::string id
std::vector< std::filesystem::path > paths
Poco::JSON::Object::Ptr result
std::uint64_t bytes
Texture * normal
OceanMeshSettings mesh
std::string error
Definition Package.cpp:174
TileLayer * layer
std::string path
Definition PlayHost.cpp:111
std::string body
Object::Ptr value
RoadNetwork resolved
const RoadNode * node
double number
bool found
unsigned line
std::string text
unsigned column
size_t end
double current
std::string resource
int count
AbilityActivationGroup group
AbilityInstancingPolicy instancing
double spacingZ
double spacingX
Json object
uint32_t seed
Definition TreeMesh.cpp:276
V3 heading
Definition TreeMesh.cpp:429
float(ui::Theme::* member)[4]
std::int64_t fileId
std::uint32_t classId
Direct Unity text-serialization adapter for TerrainData and Prefab assets.
std::vector< ImportFinding > findings
std::vector< std::string_view > lines
std::size_t at
uint32_t index
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
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
static Result< Value > fromJson(std::string_view json)
Parse one strict JSON value into an owning Value.
Definition Value.cpp:177
std::map< std::string, Value > Object
Definition Value.h:34
std::vector< Value > Array
Definition Value.h:33
std::string format() const
Formats the ID in lower-case canonical UUID text.
Definition Identity.h:172
Id128 child(std::string_view role) const noexcept
Derives a deterministic child UUID for a hierarchical identity.
Definition Identity.h:191
StateValue objects
Definition Snapshot.cpp:110
std::string sha256(std::span< const std::uint8_t > bytes)
Sha 256.
Result< asset::EvaManifest > baseManifest(const ImportPackageIdentity &package, std::string_view importer)
Base manifest.
Result< AssetRef > assetRef(PersistentId id)
Asset ref.
std::string foldAscii(std::string value)
Fold ascii.
Result< PreparedAssetImport > prepareCanonicalTerrainImport(const ImportPackageIdentity &package, const CanonicalTerrainInput &terrain, std::string_view importer, const AssetImportLimits &limits)
Build eve.terrain, terrain material, PCG and instance assets from canonical input.
Result< PreparedAssetImport > prepareUnityPrefab(const UnityProjectImportRequest &request, const std::string &path)
Prepare one prefab without copying or re-indexing the source collection.
Result< PreparedAssetImport > prepareUnityCollection(const UnityProjectImportRequest &request, const UnitySourceIndex &index)
Prepare an owning collection candidate using a validated source index.
Result< UnitySourceIndex > indexUnitySources(const UnitySourceFiles &files, const AssetImportLimits &limits)
Validate project paths and .meta identities and index serialized GUID/fileID references.
Result< PreparedAssetImport > prepareUnityProjectImport(const UnityProjectImportRequest &request)
Import selected Unity assets, or discover a collection when both selectors are empty.
const Value * field(const Value &value, const char *key)
Borrow an optional object field.
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:27
eve::Diagnostic Diagnostic
eve::Result< T > Result
std::string header(int localX, int localY)
Header.
Definition KernelGen.cpp:13
WidgetDesc row(std::vector< WidgetDesc > children, std::string id)
Horizontal elastic layout row.
Definition Widget.cpp:870
DiagnosticCode
Stable machine-readable diagnostic codes.
Definition Diagnostic.h:47
StrongUuid< detail::PersistentIdTag > PersistentId
Stable instance identity for persistence, networking and process boundaries.
Definition Identity.h:253
detail::StrongUint64< detail::SchemaVersionTag > SchemaVersion
Persistent data-format version; not a runtime replacement generation.
bool isValidUtf8(std::string_view text, Utf8NullPolicy nullPolicy) noexcept
Validate shortest-form UTF-8, Unicode scalar range and optional NUL exclusion.
Owning, validated source archive candidate not yet published to disk/database.
In-memory Unity project slice; keys are normalized project-relative paths.
glm::vec4 color