载入中...
搜索中...
未找到
CollapseAnimation.cpp
浏览该文件的文档.
23std::string CollapseAnimation::contentKey(std::string_view source) { return bakedAssetContentKey(source); }
26constexpr std::streamoff MaxFileBytes = static_cast<std::streamoff>(MaxSamples) * 56 + 16000056 + MaxRecipeBytes + 4;
57std::shared_ptr<const CollapseBakeRecipe> CollapseAnimation::recipe() const noexcept { return recipe_; }
58Result<CollapseAnimation> CollapseAnimation::loadForRecipe(std::string_view path, const CollapseBakeRecipe& expected) {
66 "legacy animation has no bake provenance; explicit migration or rebake required", "collapseAnimation"));
71 DiagnosticCode::Conflict, "bake provenance does not match the expected recipe", "collapseAnimation"));
74std::shared_ptr<const FractureGeometry> CollapseAnimation::fragmentGeometry() const noexcept { return geometry_; }
75float CollapseAnimation::duration() const noexcept { return frames_.empty() ? 0 : frames_.back().seconds; }
96 (result.rotX * b.rotX + result.rotY * b.rotY + result.rotZ * b.rotZ + result.rotW * b.rotW) < 0 ? -1.f : 1.f;
166 missing ? "animation file not found" : "animation file cannot be opened", "collapseAnimation"));
173 if (!file.read(encoded.data(), static_cast<std::streamsize>(encoded.size())) || file.peek() != EOF)
181 if (std::string(magic, 8) != "EVECOLL1" || (version < 1 || version > 4) || bones == 0 || frames == 0 ||
183 return Result<CollapseAnimation>::failure(invalid("unsupported schema, counts or trailing data"));
186 contentKey(encodedView.substr(0, encodedView.size() - 32)) != encodedView.substr(encodedView.size() - 32))
196 if (!in || recipeSize == 0 || recipeSize > MaxRecipeBytes || position < 0 || position > bytes ||
215 if (!in || vertices < 4 || vertices > 254 || triangles == 0 || triangles > 2730 || total > 4000000)
232 bytes != in.tellg() + static_cast<std::streamoff>(static_cast<std::uint64_t>(frames) * (4ULL + 52ULL * bones)))
236 if (!std::isfinite(frame.seconds) || (f == 0 ? frame.seconds != 0 : frame.seconds <= clip.duration()))
255 if (!in || !valid(b)) return Result<CollapseAnimation>::failure(invalid("invalid fragment data"));
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
Bounded provenance builder for explicit-coordinate baked recordings. @ownership Owns names and conten...
Definition BakeRecipe.h:21
Result< std::string > encode() const
Encode complete provenance canonically, sorting dependency and RNG names. @cost Linear in bounded met...
Definition BakeRecipe.cpp:104
static Result< BakeRecipe > decode(std::string_view bytes)
Parse a bounded canonical recipe record, rejecting duplicate names and trailing bytes....
Definition BakeRecipe.cpp:129
Owning, solver-independent baked rigid-fragment animation within Physics. @ownership Owns all samples...
Definition CollapseAnimation.h:27
Result< BonePresentation > sample(float seconds, int bone) const
Sample a fragment, clamping time to endpoints; linear translation and shortest quaternion nlerp.
Definition CollapseAnimation.cpp:80
static std::string contentKey(std::string_view source)
Stable noncryptographic cache identity over every source byte. Compatibility facade; canonical native...
Definition CollapseAnimation.cpp:23
std::shared_ptr< const FractureGeometry > fragmentGeometry() const noexcept
Shared immutable embedded meshes; empty for v1/box animations. @ownership Return value extends mesh l...
Definition CollapseAnimation.cpp:74
static Result< CollapseAnimation > loadForRecipe(std::string_view path, const CollapseBakeRecipe &expected)
Load only if embedded provenance exactly matches the supplied expected recipe. @cost Linear file vali...
Definition CollapseAnimation.cpp:58
Result< void > save(std::string_view path) const
Save a new file; refuses existing paths to preserve previous bakes. @cost Linear in recorded samples,...
Definition CollapseAnimation.cpp:109
Result< void > beginBake(const CollapseBakeRecipe &recipe)
Freeze complete provenance before the first recorded frame. @cost Linear in bounded metadata,...
Definition CollapseAnimation.cpp:45
static Result< CollapseAnimation > load(std::string_view path)
Load and validate a file before publishing an owning animation. @cost Linear in file size; perform on...
Definition CollapseAnimation.cpp:155
std::shared_ptr< const CollapseBakeRecipe > recipe() const noexcept
Immutable recorded provenance; null means historical/unidentified recording. @ownership Shared result...
Definition CollapseAnimation.cpp:57
constexpr std::uint32_t MaxRecipeBytes
Definition CollapseAnimationInternal.h:8
constexpr std::uint32_t MaxSamples
Definition CollapseAnimationInternal.h:7
Result< float > readFloat(const Value::Object &object, std::string_view name)
Reads a required finite number representable by float.
Definition WorldSnapshotParsing.cpp:66
std::string bakedAssetContentKey(std::string_view source)
Stable noncryptographic 128-bit content digest, encoded as 32 lowercase hexadecimal bytes....
Definition BakedAssetFile.cpp:14
BoneRuntimeState
Runtime lifecycle for one bone inside a geometry-collection instance.
Definition BonePresentation.h:7
Result< void > publishBakedAsset(std::string_view path, std::string_view bytes)
Publish complete baked asset bytes atomically without replacing an existing path. @ownership Borrows ...
Definition BakedAssetFile.cpp:64
@ MetresRightHandedYUp
@ NotFound
@ PreconditionViolation
@ Failed
@ Conflict
Presentation snapshot for one bone (world pose + proxy extents).
Definition BonePresentation.h:19
Owning closed convex fragment in body-local metres; outward triangle winding. Each triangle has mater...
Definition FractureGeometry.h:11
std::vector< std::uint32_t > indices
Definition FractureGeometry.h:13
std::vector< std::uint32_t > materials
Definition FractureGeometry.h:14
std::vector< float > positions
Definition FractureGeometry.h:12
Owning, typed mesh payload shared immutably by simulation, clip and renderer. @thread Read-only shari...
Definition FractureGeometry.h:19