载入中...
搜索中...
未找到
UnityNativeMesh.cpp
浏览该文件的文档.
14 if (!std::regex_search(text, m, std::regex(pattern))) throw std::runtime_error("missing Mesh field");
26 if (text.size() % 2 || text.size() / 2 > limit) throw std::runtime_error("Mesh byte budget or hex length invalid");
31 if (parsed.ec != std::errc{} || parsed.ptr != text.data() + i + 2) throw std::runtime_error("invalid Mesh hex");
37 if (at > data.size() || size > data.size() - at) throw std::runtime_error("Mesh buffer truncated");
53 DiagnosticCode::Unsupported, "native asset is not a text Mesh", source.path, {}, "asset.import"));
60 Diagnostic::error(DiagnosticCode::Unsupported, "requires uncompressed static Mesh version 9 or 11",
66 if (section.find("vertices: []") == std::string::npos || section.find("shapes: []") == std::string::npos)
82 Channel c{std::stoull((*it)[1]), std::stoull((*it)[2]), std::stoull((*it)[3]), std::stoull((*it)[4])};
85 Diagnostic::error(DiagnosticCode::Unsupported, "Mesh requires interleaved float32 vertex channels",
95 Diagnostic::error(DiagnosticCode::Unsupported, "Mesh skin channels require animation conversion",
103 auto vertices = hex(capture(text, R"(_typelessdata: ([0-9a-fA-F]*))"), request.limits.maximumDecodedBytes);
106 auto indices = hex(capture(text, R"(m_IndexBuffer: ([0-9a-fA-F]*))"), request.limits.maximumDecodedBytes);
110 if (indices.size() % indexSize || indices.size() / indexSize > request.limits.maximumIndicesPerPrimitive)
114 DiagnosticCode::Unsupported, "external Mesh stream unsupported", source.path, {}, "asset.import"));
147 if (channels[2].dimension != 4) throw std::runtime_error("Mesh tangent must have four components");
159 R"( firstByte: ([0-9]+)\r?\n indexCount: ([0-9]+)\r?\n topology: ([0-9]+)\r?\n baseVertex: ([0-9]+))");
164 const auto first = std::stoull((*it)[1]), n = std::stoull((*it)[2]), topology = std::stoull((*it)[3]),
169 if (n % 3 || first != consumed || first > indices.size() || n > (indices.size() - first) / indexSize ||
184 primitives.emplace_back(Value::Object{{"attributes", Value(attributes)}, {"indices", Value(accessor)}});
187 if (primitives.empty() || consumed != indices.size() || buffer.size() > request.limits.maximumDecodedBytes)
189 if (canonicalVertexBytes * slots.size() + indices.size() * 2 > request.limits.maximumDecodedBytes)
197 {"meshes", Value(Value::Array{Value(Value::Object{{"primitives", Value(std::move(primitives))}})})}});
208 // Canonical identity follows the Unity slot, including empty slots, never the compacted glTF ordinal.
211 auto mappingIt = std::find_if(result.value().sourceMappings.begin(), result.value().sourceMappings.end(),
213 if (mappingIt == result.value().sourceMappings.end()) throw std::runtime_error("missing primitive mapping");
216 auto newRef = detail::assetRef(request.package.packageId.child("unity:" + source.guid + ":" + id +
242 std::erase_if(result.value().entries, [](const auto& entry) { return entry.path == "reports/import.json"; });
247 detail::finalizeImportReport(result.value(), identity, "unity", "mesh-v" + std::to_string(version));
std::map< std::string, std::vector< Key >, std::less<> > channels
Definition AnimCurveLibrary.cpp:19
Direct Unity text-serialization adapter for TerrainData and Prefab assets.
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
Result< std::string > toJson() const
Serialize this value as deterministic compact JSON.
Definition Value.cpp:67
static Result< Value > fromJson(std::string_view json)
Parse one strict JSON value into an owning Value.
Definition Value.cpp:57
Id128 child(std::string_view role) const noexcept
Derives a deterministic child UUID for a hierarchical identity.
Definition Identity.h:192
EVENGINE_API_PLATFORM Result< void > finalizeImportReport(PreparedAssetImport &prepared, const ImportPackageIdentity &package, std::string_view sourceEngine, std::string_view sourceVersion, Value::Object options={})
Append the deterministic mandatory import report and bind it from provenance.
Definition ImportReport.cpp:21
Definition AssetImporter.h:14
@ Translated
Result< PreparedAssetImport > prepareUnityNativeMesh(const UnityProjectImportRequest &request, const UnitySourceAsset &source)
Decode a bounded static Unity text Mesh into owning canonical submesh candidates.
Definition UnityNativeMesh.cpp:46
EVENGINE_API_PLATFORM Result< PreparedAssetImport > prepareGltfImport(const GltfImportRequest &request)
Decode triangle primitives from glTF 2.0 into canonical typed mesh blobs.
Definition GltfImporter.cpp:205
@ Unsupported
@ ParseError
std::uint32_t maximumAssets
Definition AssetImporter.h:20
std::uint32_t maximumVerticesPerPrimitive
Definition AssetImporter.h:21
std::uint64_t maximumDecodedBytes
Definition AssetImporter.h:19
std::uint32_t maximumIndicesPerPrimitive
Definition AssetImporter.h:22
ImportPackageIdentity package
Definition AssetImporter.h:55
PersistentId packageId
Definition AssetImporter.h:34
In-memory Unity project slice; keys are normalized project-relative paths.
Definition UnityImporter.h:15
Immutable-by-convention owning source index entry; no borrowed source addresses.
Definition UnitySource.h:38