载入中...
搜索中...
未找到
GltfAnimation.cpp
浏览该文件的文档.
19void require(bool condition, std::string message, DiagnosticCode code = DiagnosticCode::ParseError) {
37 require(value && value->isInt64() && value->asInt() >= 0 && std::uint64_t(value->asInt()) < bound,
43 const auto result = static_cast<float>(value.isInt64() ? double(value.asInt()) : value.asDouble());
47std::string name(const Value::Object& value, std::string fallback, const AssetImportLimits& limits) {
58Accessor accessor(const Value::Object& root, const std::vector<std::span<const std::uint8_t>>& buffers,
62 if (!parsed) throw Rejection{DiagnosticCode::ParseError, "invalid glTF skeletal accessor " + std::to_string(i)};
67 if (!value) throw Rejection{DiagnosticCode::ParseError, "invalid glTF skeletal FLOAT component"};
71 require(a.componentType == 5121 || a.componentType == 5123, "JOINTS must use unsigned bytes or shorts");
81void publish(const GltfImportRequest& request, PreparedAssetImport& output, const AssetRef& ref, std::string type,
83 require(output.manifest.assets.size() < request.limits.maximumAssets, "glTF asset budget exceeded");
104 output.findings.push_back({request.sourceName, source, ImportDisposition::Translated, "converted to " + type});
106void dependency(PreparedAssetImport& output, const AssetRef& from, const AssetRef& to, std::string role,
118 require(!nodes.empty() && nodes.size() <= request.limits.maximumAssets, "glTF node budget exceeded");
122 require(!member(node, "matrix"), "skeletal matrix nodes require TRS conversion", DiagnosticCode::Unsupported);
190 for (const auto& j : joints) require(unique.insert(index(&j, nodes.size())).second, "duplicate glTF joint");
194 require(inverse->components == 16 && inverse->componentType == 5126 && inverse->count == joints.size(),
270 auto meshRef = reference(request.package.packageId.child("gltf:mesh:" + std::to_string(meshIndex) +
272 const auto source = "nodes[" + std::to_string(n) + "].skin.primitives[" + std::to_string(p) + "]";
288 output.manifest.entrypoints.emplace("skin:" + std::to_string(n) + ":" + std::to_string(p), skinRef);
313 int kind = pathName == "translation" ? 0 : pathName == "rotation" ? 1 : pathName == "scale" ? 2 : -1;
314 require(kind >= 0, "animation target " + pathName + " is unsupported", DiagnosticCode::Unsupported);
321 require(input.components == 1 && input.count == values.count && values.components == (kind == 1 ? 4u : 3u),
327 size <= request.limits.maximumDecodedBytes && decodedBytes <= request.limits.maximumDecodedBytes - size,
334 require(time >= 0 && time > previous, "animation times must be strictly increasing and non-negative");
std::map< std::string, std::vector< Key >, std::less<> > channels
Definition AnimCurveLibrary.cpp:19
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 GltfAnimation.cpp:11
Result< Accessor > accessorAt(const Value::Object &root, const std::vector< std::span< const std::uint8_t > > &buffers, std::uint64_t accessorIndex, const AssetImportLimits &limits)
Validate an accessor retaining only buffer spans borrowed for this import.
Definition GltfDecode.cpp:148
Result< float > readFloat(const Accessor &accessor, std::uint32_t element, std::uint32_t component)
Read one bounded finite FLOAT component.
Definition GltfDecode.cpp:221
void put32(std::vector< std::uint8_t > &bytes, std::uint32_t value)
Append little-endian uint32 to owned storage.
Definition GltfDecode.cpp:27
std::uint32_t little32(std::span< const std::uint8_t > bytes, std::size_t offset)
Read a uint32 after the caller has bounded the byte range.
Definition GltfDecode.cpp:22
Result< void > appendAnimation(const GltfImportRequest &request, const Value::Object &root, const std::vector< std::span< const std::uint8_t > > &buffers, PreparedAssetImport &output)
Append owning canonical skeleton, skin and clip assets to an unpublished candidate.
Definition GltfAnimation.cpp:379
std::uint32_t componentSize(std::uint32_t type)
Return encoded component byte size, or zero for an unknown type.
Definition GltfDecode.cpp:141
void putFloat(std::vector< std::uint8_t > &bytes, float value)
Append IEEE FLOAT to owned storage.
Definition GltfDecode.cpp:31
@ Translated
@ RuntimeRequired
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:26
@ AssetRef
Result< int > publish(Heightmap &target, std::vector< float > candidate)
Publish.
Definition TerrainRasterInternal.h:62
const EditorValue * field(const EditorValue &value, const char *name)
Definition RoadNetworkEditTarget.cpp:15
std::vector< int64_t > attrs(const Node &n, const char *key, std::vector< int64_t > fallback)
Attrs.
Definition OnnxInternal.h:132
WidgetDesc child(std::string id, std::vector< WidgetDesc > children, float width, float height)
Scrollable child region with an explicit size.
Definition Widget.cpp:635
WidgetDesc row(std::vector< WidgetDesc > children, std::string id)
Horizontal elastic layout row.
Definition Widget.cpp:679
@ Unsupported
@ ParseError
StrongUuid< detail::PersistentIdTag > PersistentId
Stable instance identity for persistence, networking and process boundaries.
Definition Identity.h:254
detail::StrongUint64< detail::SchemaVersionTag > SchemaVersion
Persistent data-format version; not a runtime replacement generation.
Definition SchemaVersion.h:13
Definition Container.h:602
Untrusted .gltf/.glb input plus explicitly supplied external URI bytes.
Definition AssetImporter.h:54
Owning, validated source archive candidate not yet published to disk/database.
Definition AssetImporter.h:90