载入中...
搜索中...
未找到
DeformMeshPresentation.cpp
浏览该文件的文档.
26DeformMeshPresentation::DeformMeshPresentation(std::unique_ptr<Impl> impl) : impl_(std::move(impl)) {}
28Result<std::unique_ptr<DeformMeshPresentation>> DeformMeshPresentation::prepare(DeformTrack track, float ropeRadius) {
37 const auto indexCount = triangles ? topology.indices().size() * 2 : topology.indices().size() / 2 * 96;
41 auto impl = std::make_unique<Impl>(Impl{std::move(track), topology, ropeRadius, {}, {}, {}, {}, {}, {}});
73 return Output::success(std::unique_ptr<DeformMeshPresentation>(new DeformMeshPresentation(std::move(impl))));
75 return Output::failure(Diagnostic::error(DiagnosticCode::Failed, "deformation mesh allocation failed"));
79 if (!impl_->track.isSameAsset(player.track())) return Result<void>::failure(invalid("foreign deformation player"));
103 glm::cross(point(indices[i + 1]) - point(indices[i]), point(indices[i + 2]) - point(indices[i]));
133 if (!representable) return Result<void>::failure(invalid("deformation mesh position overflow"));
135 if (!std::isfinite(value)) return Result<void>::failure(invalid("deformation mesh position overflow"));
137 if (!std::isfinite(value)) return Result<void>::failure(invalid("deformation mesh normal overflow"));
140Result<graphics::Mesh*> DeformMeshPresentation::createMesh(DeformPlayback& player, graphics::Graphics& graphics) {
151Result<void> DeformMeshPresentation::upload(DeformPlayback& player, graphics::Graphics& graphics,
153 if (!graphics.describeMesh(&mesh)) return Result<void>::failure(invalid("foreign or released deformation mesh"));
156 if (!graphics.updateMeshVertices(&mesh, impl_->positions.data(), impl_->normals.data(), impl_->uv.data(),
159 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Failed, "deformation mesh upload failed"));
A structured explanation of a failed, degraded, or noteworthy result.
Definition Diagnostic.h:94
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
Definition Graphics.h:134
Prepared dynamic mesh presentation over an owned deformation player. @ownership Owns immutable asset ...
Definition DeformMeshPresentation.h:17
~DeformMeshPresentation()
Result< void > upload(DeformPlayback &player, graphics::Graphics &graphics, graphics::Mesh &mesh)
Sample and upload all prepared streams to a live mesh owned by the supplied Graphics....
Definition DeformMeshPresentation.cpp:151
static Result< std::unique_ptr< DeformMeshPresentation > > prepare(DeformTrack track, float ropeRadius)
Prepare double-sided triangles or capped eight-sided tubes from a metre-space clip.
Definition DeformMeshPresentation.cpp:28
DeformMeshPresentation(const DeformMeshPresentation &)=delete
Result< graphics::Mesh * > createMesh(DeformPlayback &player, graphics::Graphics &graphics)
Sample the player and create one Graphics-owned mesh with current topology. @ownership Returned point...
Definition DeformMeshPresentation.cpp:140
Independent clock and placement over a shared immutable deformation clip. @ownership Owns reusable sc...
Definition DeformPlayback.h:11
Result< void > sample(std::span< DeformPoint > output)
Sample and transform into exact-sized output; all failures preserve the caller's entire buffer....
Definition DeformPlayback.cpp:37
DeformTrack track() const
Return a cheap owning immutable clip copy, independent of player lifetime.
Definition DeformPlayback.cpp:36
Immutable connectivity and UV ownership for fixed-topology deformation playback. @ownership Copies sh...
Definition DeformTopology.h:23
DeformPrimitive primitive() const noexcept
Primitive interpretation of the index stream.
Definition DeformTopology.cpp:57
Immutable fixed-topology deformation clip, independent of simulation and rendering providers....
Definition DeformTrack.h:25
std::shared_ptr< const BakeRecipe > recipe() const noexcept
Return shared immutable provenance including explicit coordinates.
Definition DeformTrack.cpp:75
DeformTopology topology() const
Return a cheap owning copy of the fixed connectivity and UVs.
Definition DeformTrack.cpp:74
@ Triangles
@ MetresRightHandedYUp
@ InvalidArgument
@ Failed
Definition Container.h:602
std::vector< float > positions
Definition DeformMeshPresentation.cpp:17
std::vector< std::uint32_t > indices
Definition DeformMeshPresentation.cpp:18
std::vector< float > normals
Definition DeformMeshPresentation.cpp:17
std::vector< DeformPoint > sampled
Definition DeformMeshPresentation.cpp:16
float radius
Definition DeformMeshPresentation.cpp:15
DeformTrack track
Definition DeformMeshPresentation.cpp:13
std::vector< float > uv
Definition DeformMeshPresentation.cpp:17
DeformTopology topology
Definition DeformMeshPresentation.cpp:14
std::vector< glm::dvec3 > accumulated
Definition DeformMeshPresentation.cpp:19