载入中...
搜索中...
未找到
FogDensityField.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4#include "common/Result.h"
6
7#include <cstddef>
8#include <cstdint>
9#include <span>
10#include <vector>
11
12#include <glm/vec3.hpp>
13
14namespace eve::graphics::fog {
15
22public:
24 [[nodiscard]] Result<void> resize(int width, int height, int depth, const FogWorldBounds& bounds);
25
26 [[nodiscard]] int width() const noexcept { return width_; }
27 [[nodiscard]] int height() const noexcept { return height_; }
28 [[nodiscard]] int depth() const noexcept { return depth_; }
29 [[nodiscard]] const FogWorldBounds& bounds() const noexcept { return bounds_; }
30 [[nodiscard]] glm::vec3 cellSize() const noexcept { return cellSize_; }
31 [[nodiscard]] std::uint64_t revision() const noexcept { return revision_; }
32
34 void clear();
35
37 void setDensity(int x, int y, int z, float density);
39 [[nodiscard]] float densityAt(int x, int y, int z) const noexcept;
40
42 void setCurlVelocity(int x, int y, int z, const glm::vec3& velocity);
44 [[nodiscard]] glm::vec3 curlVelocityAt(int x, int y, int z) const noexcept;
45
47 void setLightAssist(int x, int y, int z, const glm::vec3& assist);
49 [[nodiscard]] glm::vec3 lightAssistAt(int x, int y, int z) const noexcept;
50
52 [[nodiscard]] float sampleDensity(const glm::vec3& world) const noexcept;
54 [[nodiscard]] glm::vec3 sampleCurlVelocity(const glm::vec3& world) const noexcept;
56 [[nodiscard]] glm::vec3 sampleLightAssist(const glm::vec3& world) const noexcept;
57
66 [[nodiscard]] Result<void> seedHeightBand(float baseDensity, float baseHeight, float falloff,
67 float curlScale, std::uint32_t seed);
68
70 [[nodiscard]] bool isOccupied(int x, int y, int z, float threshold = 1e-4f) const noexcept;
71
73 [[nodiscard]] std::span<float> densitySpan() noexcept;
74 [[nodiscard]] std::span<const float> densitySpan() const noexcept;
75
76private:
77 [[nodiscard]] std::size_t index(int x, int y, int z) const noexcept;
78 [[nodiscard]] glm::vec3 cellCenter(int x, int y, int z) const noexcept;
79 void sampleLattice(const glm::vec3& world, int& x0, int& y0, int& z0, int& x1, int& y1, int& z1,
80 float& fx, float& fy, float& fz) const noexcept;
81
82 int width_ = 0;
83 int height_ = 0;
84 int depth_ = 0;
85 FogWorldBounds bounds_{};
86 glm::vec3 cellSize_{1.f};
87 std::uint64_t revision_ = 1;
88 std::vector<float> density_;
89 std::vector<glm::vec3> curl_;
90 std::vector<glm::vec3> lightAssist_;
91};
92
93} // namespace eve::graphics::fog
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float z
Definition AnimClip.cpp:738
#define EVENGINE_API_WORLD
Definition Export.h:109
std::uint32_t height
std::uint32_t width
World3D * world
std::uint32_t seed
Definition PointSet.cpp:807
Move-only, checked operation results for the common layer.
uint32_t index
std::uint32_t depth
Move-only operation result carrying either a value or Status.
Definition Result.h:155
World-space density bands, curl assist velocity, and lighting helpers.
const FogWorldBounds & bounds() const noexcept
std::uint64_t revision() const noexcept
glm::vec3 cellSize() const noexcept
Axis-aligned world bounds for a fog simulation domain.
Definition FogTypes.h:96
glm::vec4 bounds