载入中...
搜索中...
未找到
SurfaceFluidContracts.h
浏览该文件的文档.
1#pragma once
2
12#include "common/Result.h"
13#include "common/Time.h"
16
17#include <glm/glm.hpp>
18
19#include <cstdint>
20#include <memory>
21#include <span>
22#include <vector>
23
24namespace eve::fluids {
25
26class FluidSurfaceRenderer;
27struct FluidSurfaceParams;
28
31public:
33 virtual ~ISurfaceFluidSimulation() = default;
34
40 [[nodiscard("check the surface-fluid step outcome")]]
42
44 [[nodiscard]] virtual int particleCount() const noexcept = 0;
46 [[nodiscard]] virtual std::span<const FluidParticle> particles() const noexcept = 0;
47};
48
51public:
53 virtual ~ISurfaceConstraint() = default;
54
56 [[nodiscard("check surface constraint construction")]]
57 virtual eve::Result<void> build(const std::vector<glm::vec3>& positions, const std::vector<std::uint32_t>& indices,
58 const std::vector<glm::vec2>& uvs = {}) = 0;
59
61 [[nodiscard("check surface constraint pose update")]]
62 virtual eve::Result<void> setTransform(const glm::mat4& transform) = 0;
63
65 [[nodiscard("check surface constraint pose update")]]
66 virtual eve::Result<void> setDeformedPositions(const std::vector<glm::vec3>& worldPositions) = 0;
67
69 [[nodiscard]] virtual bool isValid() const noexcept = 0;
70
72 [[nodiscard("check surface location evaluation")]]
73 virtual eve::Result<SurfaceSample> evaluate(const SurfaceLocation& location, eve::Duration poseDelta) const = 0;
74
76 [[nodiscard("check surface projection")]]
77 virtual eve::Result<SurfaceLocation> project(const glm::vec3& worldPosition, float maxDistance) const = 0;
78
80 [[nodiscard("check surface traversal")]]
81 virtual eve::Result<SurfaceWalkResult> walk(const SurfaceLocation& start, const glm::vec3& displacement,
82 int maxCrossings = 16) const = 0;
83};
84
87public:
90
95 [[nodiscard("check screen-space reconstruction")]]
96 virtual eve::Result<void> reconstruct(std::span<const glm::vec3> positions, float particleRadius) = 0;
97
99 [[nodiscard("check scene-depth composition")]]
100 virtual eve::Result<void> occlude(std::span<const float> sceneDepth, float depthBias = 0.001f) = 0;
101
103 [[nodiscard]] virtual int width() const noexcept = 0;
105 [[nodiscard]] virtual int height() const noexcept = 0;
107 [[nodiscard]] virtual std::span<const float> depth() const noexcept = 0;
109 [[nodiscard]] virtual std::span<const glm::vec3> normals() const noexcept = 0;
111 [[nodiscard]] virtual std::span<const float> thickness() const noexcept = 0;
113 [[nodiscard]] virtual std::span<const std::uint8_t> color() const noexcept = 0;
115 [[nodiscard]] virtual bool usingGpu() const noexcept = 0;
116};
117
120public:
123 explicit FluidSimulationAdapter(FluidSimulation& solver) noexcept : solver_(&solver) {}
124
126 [[nodiscard]] eve::Result<void> step(const eve::SimulationStep& step) override;
128 [[nodiscard]] int particleCount() const noexcept override;
130 [[nodiscard]] std::span<const FluidParticle> particles() const noexcept override;
131
132private:
133 FluidSimulation* solver_ = nullptr;
134 eve::SimulationTick lastTick_ = eve::SimulationTick::zero();
135};
136
139public:
143
145 [[nodiscard]] eve::Result<void> build(const std::vector<glm::vec3>& positions,
146 const std::vector<std::uint32_t>& indices,
147 const std::vector<glm::vec2>& uvs = {}) override;
149 [[nodiscard]] eve::Result<void> setTransform(const glm::mat4& transform) override;
151 [[nodiscard]] eve::Result<void> setDeformedPositions(const std::vector<glm::vec3>& worldPositions) override;
153 [[nodiscard]] bool isValid() const noexcept override;
155 [[nodiscard]] eve::Result<SurfaceSample> evaluate(const SurfaceLocation& location,
156 eve::Duration poseDelta) const override;
158 [[nodiscard]] eve::Result<SurfaceLocation> project(const glm::vec3& worldPosition,
159 float maxDistance) const override;
161 [[nodiscard]] eve::Result<SurfaceWalkResult> walk(const SurfaceLocation& start, const glm::vec3& displacement,
162 int maxCrossings = 16) const override;
163
164private:
165 FluidSurfaceBinding* binding_ = nullptr;
166};
167
175public:
185
188
190 [[nodiscard]] eve::Result<void> reconstruct(std::span<const glm::vec3> positions, float particleRadius) override;
192 [[nodiscard]] eve::Result<void> occlude(std::span<const float> sceneDepth, float depthBias = 0.001f) override;
194 [[nodiscard]] int width() const noexcept override;
196 [[nodiscard]] int height() const noexcept override;
198 [[nodiscard]] std::span<const float> depth() const noexcept override;
200 [[nodiscard]] std::span<const glm::vec3> normals() const noexcept override;
202 [[nodiscard]] std::span<const float> thickness() const noexcept override;
204 [[nodiscard]] std::span<const std::uint8_t> color() const noexcept override;
206 [[nodiscard]] bool usingGpu() const noexcept override;
207
208private:
209 std::unique_ptr<FluidSurfaceRenderer> renderer_;
210};
211
212} // namespace eve::fluids
Duration start
float thickness
Definition CaveMesh.cpp:83
std::vector< std::uint32_t > indices
std::vector< float > normals
std::vector< float > positions
std::uint32_t height
std::uint32_t width
eve::action::ActionVfxBinding binding
Move-only, checked operation results for the common layer.
Common time values and an injectable deterministic simulation clock.
float step
Definition TreeMesh.cpp:314
std::uint32_t depth
Signed, fixed-resolution simulation duration in nanoseconds.
Definition Time.h:43
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Adapter exposing the existing CPU FluidSimulation through the contract.
FluidSimulationAdapter(FluidSimulation &solver) noexcept
Constructs a FluidSimulationAdapter.
CPU reference surface-flow solver.
Dynamic triangle surface used to bind films and droplets to deforming meshes.
Adapter exposing existing FluidSurfaceBinding operations as checked results.
FluidSurfaceConstraintAdapter(FluidSurfaceBinding &binding) noexcept
Constructs a FluidSurfaceConstraintAdapter.
Buffer-level screen-space fluid renderer.
Presentation contract for screen-space surface reconstruction.
virtual eve::Result< void > occlude(std::span< const float > sceneDepth, float depthBias=0.001f)=0
Removes reconstructed color behind borrowed linear scene depth without allocating.
virtual ~IScreenSpaceSurfaceReconstruction()=default
Releases the renderer adapter and its presentation buffers.
virtual int width() const noexcept=0
Output width in pixels.
virtual eve::Result< void > reconstruct(std::span< const glm::vec3 > positions, float particleRadius)=0
Reconstructs depth, thickness, normals, and color from particles.
Backend-neutral contract for mesh-surface binding and traversal.
virtual ~ISurfaceConstraint()=default
Releases the borrowed-constraint adapter.
virtual eve::Result< void > setDeformedPositions(const std::vector< glm::vec3 > &worldPositions)=0
Applies a deformed pose with the existing topology.
virtual bool isValid() const noexcept=0
Returns whether topology and poses are currently valid.
virtual eve::Result< void > build(const std::vector< glm::vec3 > &positions, const std::vector< std::uint32_t > &indices, const std::vector< glm::vec2 > &uvs={})=0
Builds topology and pose state from owning caller data.
virtual eve::Result< void > setTransform(const glm::mat4 &transform)=0
Applies a rigid pose while preserving the previous pose.
Backend-neutral contract for advancing a surface-fluid solver.
virtual eve::Result< void > step(const eve::SimulationStep &step)=0
Advances the solver at an injected simulation tick.
virtual std::span< const FluidParticle > particles() const noexcept=0
Borrows a read-only live-particle view until the next solver mutation.
virtual int particleCount() const noexcept=0
Returns the number of live particles.
virtual ~ISurfaceFluidSimulation()=default
Releases the borrowed-solver adapter.
Minimal SSF adapter over the existing CPU/GPU FluidSurfaceRenderer.
~ScreenSpaceSurfaceReconstructionAdapter() override
Releases ScreenSpaceSurfaceReconstructionAdapter resources.
ScreenSpaceSurfaceReconstructionAdapter & operator=(const ScreenSpaceSurfaceReconstructionAdapter &)=delete
ScreenSpaceSurfaceReconstructionAdapter(const ScreenSpaceSurfaceReconstructionAdapter &)=delete
std::vector< ParamSpec > params
GLSL compute kernels for the GPU surface-flow solver.
Definition FluidTarget.h:12
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
One deterministic fixed-step emitted by SimulationClock.
Definition Time.h:158
One simulated particle (CPU reference layout).
Definition FluidMath.h:54
Camera + reconstruction tuning for the SSF pipeline.
Stable material-space address of a point on a triangle surface.
Evaluated world-space frame and motion at a surface location.
Result of walking a material point across triangle adjacency.
glm::vec4 color