载入中...
搜索中...
未找到
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;
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")]]
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")]]
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;
115 [[nodiscard]] virtual bool usingGpu() const noexcept = 0;
116};
117
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,
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
211
212} // namespace eve::fluids
Duration start
std::shared_ptr< AudioBinding > binding_
std::vector< std::uint32_t > indices
std::vector< float > normals
std::vector< float > positions
std::uint32_t height
std::uint32_t width
float thickness
std::vector< RecipeParam > params
glm::dvec3 displacement
eve::action::ActionVfxBinding binding
std::string build
Move-only, checked operation results for the common layer.
Common time values and an injectable deterministic simulation clock.
float step
Definition TreeMesh.cpp:451
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:176
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
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