载入中...
搜索中...
未找到
DeformCaptureInternal.h
浏览该文件的文档.
1#pragma once
2#include <cmath>
5template <class Source, class Connectivity>
6Result<DeformFrame> captureDeformSource(const Source& source, float seconds, DeformPrimitive primitive,
7 Connectivity connectivity) {
8 const int count = source.getParticleCount();
9 if (!std::isfinite(seconds) || seconds < 0 || count <= 0 || count > 1048576)
11 "invalid deformation capture time or particle count",
12 "deformBakeCapture"));
13 auto indices = connectivity();
14 if (!indices) return Result<DeformFrame>::failure(indices.status());
15 auto topology =
16 DeformTopology::prepare(primitive, static_cast<std::size_t>(count), std::move(indices).takeValue(), {});
17 if (!topology) return Result<DeformFrame>::failure(topology.status());
18 std::vector<DeformPoint> positions;
19 positions.reserve(static_cast<std::size_t>(count));
20 for (int i = 0; i < count; ++i) {
21 DeformPoint point{source.getParticleX(i), source.getParticleY(i), source.getParticleZ(i)};
22 if (!std::isfinite(point.x) || !std::isfinite(point.y) || !std::isfinite(point.z))
24 DiagnosticCode::InvalidArgument, "nonfinite deformation capture position", "deformBakeCapture"));
25 positions.push_back(point);
26 }
27 return Result<DeformFrame>::success({seconds, std::move(topology).takeValue(), std::move(positions)});
28}
29} // namespace eve::physics::bake_detail
std::vector< std::uint32_t > indices
std::vector< float > positions
Topology topology
std::string_view source
int count
glm::vec3 point
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
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
static Result< DeformTopology > prepare(DeformPrimitive primitive, std::size_t vertexCount, std::vector< std::uint32_t > indices, std::vector< DeformUV > uv)
Validate bounded connectivity and freeze it with a deterministic content identity.
Result< DeformFrame > captureDeformSource(const Source &source, float seconds, DeformPrimitive primitive, Connectivity connectivity)
DeformPrimitive
Explicit primitive arity; connectivity retains order and triangle winding.
Owning position in the explicit coordinates recorded by the recipe.
Definition DeformTrack.h:11