载入中...
搜索中...
未找到
CollapseDust.h
浏览该文件的文档.
1#pragma once
2#include <array>
3#include <future>
4#include <glm/mat4x4.hpp>
5#include <memory>
6#include <optional>
7#include <string_view>
8#include <vector>
9#include "common/Export.h"
10#include "common/Result.h"
11namespace eve::fluids {
12class VolumeFluid;
13} // namespace eve::fluids
14namespace eve::graphics {
15class Camera3D;
16class AtmosphereVolume;
17class Graphics;
18class Texture;
19class Volumetric;
20} // namespace eve::graphics
21namespace eve::physics {
22class CollapseAnimation;
25 glm::mat4 view{1.f}, inverseViewProjection{1.f};
26 float fov = 39.f, nearDistance = 0.2f, farDistance = 65.f;
27};
30 std::vector<unsigned char> atlas, depth;
33 float seconds = 0.f;
34};
48public:
53 CollapseDust(const CollapseDust&) = delete;
60 [[nodiscard]] Result<void> capture(const fluids::VolumeFluid& source, float seconds);
64 [[nodiscard]] Result<void> present(fluids::VolumeFluid& target, float seconds) const;
71 [[nodiscard]] Result<void> save(std::string_view path) const;
78 [[nodiscard]] Result<void> load(std::string_view path);
80 [[nodiscard]] int frameCount() const { return static_cast<int>(frames_.size()); }
84 [[nodiscard]] Result<void> prepareDepth(int width, int height);
93 [[nodiscard]] Result<void> injectFog(graphics::AtmosphereVolume& grid, const glm::mat4& inverseViewProjection,
94 float seconds, float density, float radius) const;
99 [[nodiscard]] Result<void> updateDepthTexture(graphics::Graphics& graphics, graphics::Texture& texture,
100 const CollapseAnimation& clip, float seconds,
102
107 [[nodiscard]] Result<void> prepareFog(const CollapseAnimation& clip, int depthWidth, int depthHeight, int gridWidth,
108 int gridHeight, int gridDepth);
114 [[nodiscard]] Result<DustFogRequest> requestFog(float seconds, const DustFogView& view, float density,
115 float radius);
119 [[nodiscard]] Result<std::optional<DustFogFrame>> takeFogFrame();
126 float seconds, graphics::Camera3D& camera, float density,
127 float radius);
128
129private:
130 [[nodiscard]] Result<void> rasterizeDepth(const CollapseAnimation& clip, float seconds, graphics::Camera3D& camera);
131 [[nodiscard]] Result<void> rasterizeDepthView(const CollapseAnimation& clip, float seconds,
132 const DustFogView& view);
133 struct Frame {
134 float seconds;
135 float spacing;
136 std::vector<std::array<float, 7>> particles;
137 };
138 std::vector<Frame> frames_;
139 std::vector<float> depth_;
140 std::vector<unsigned char> depthPixels_;
141 int width_ = 0, height_ = 0;
142 std::shared_ptr<const CollapseAnimation> fogClip_;
143 int gridWidth_ = 0, gridHeight_ = 0, gridDepth_ = 0;
144 float requestedSeconds_ = -1.f, requestedDensity_ = -1.f, requestedRadius_ = -1.f;
145 DustFogView requestedView_, presentedView_;
146 bool presented_ = false;
147 // Declared last so the sole future joins before other member destruction.
148 std::future<Result<DustFogFrame>> future_;
149};
150} // namespace eve::physics
LogicalId target
#define EVENGINE_API_DOMAINS
Definition Export.h:110
float density
float camera[2]
glm::vec4 clip
std::uint32_t height
std::uint32_t width
bool present
double radius
Definition MeleeHit.cpp:42
OceanSprayView view
Texture * texture
std::vector< BakedParticleSample > particles
std::string path
Definition PlayHost.cpp:111
Move-only, checked operation results for the common layer.
Graphics * graphics
std::string_view source
int spacing
Move-only operation result carrying either a value or Status.
Definition Result.h:176
CPU position-based free-volume fluid with a bounded spatial grid. @ownership Owns all particle state;...
Camera-frustum volume used by the volumetric fog passes and CPU references.
EVENGINE_API_BACKENDS public API.
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:15
Volumetric light + fog.
Definition Volumetric.h:38
Owning, solver-independent baked rigid-fragment animation within Physics. @ownership Owns all samples...
Owning gas presentation cache, independent of the source solver. @ownership Owns frames and depth scr...
CollapseDust & operator=(CollapseDust &&)=delete
CollapseDust(CollapseDust &&)=delete
CollapseDust(const CollapseDust &)=delete
int frameCount() const
Recorded frame count.
CollapseDust & operator=(const CollapseDust &)=delete
CollapseDust()
Construct an empty owning cache; no worker starts until requested.
GLSL compute kernels for the GPU surface-flow solver.
Definition FluidTarget.h:12
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
Optional physics backend for vehicle mobility and body attach.
Definition Climbing.h:36
DustFogDisplay
Whether a matching-view fog image is available for compositing.
DustFogRequest
Explicit worker admission state.
Owning worker output; no GPU or source pointers. Graphics borrows pixels only for upload.
std::vector< unsigned char > atlas
std::vector< unsigned char > depth
Owning camera snapshot; CPU workers never access an ECS camera.