载入中...
搜索中...
未找到
OceanSpectrum.h
浏览该文件的文档.
1#pragma once
2
3#include "common/Export.h"
4
6
7#include <cstdint>
8#include <memory>
9
10namespace eve::fluids {
11
14 unsigned resolution = 64;
15 double length = 256.0;
16 double minimumWavelength = 8.0;
17 double maximumWavelength = 64.0;
18};
19
22 std::uint64_t seed = 1;
24 double peakPeriod = 7.0;
25 double peakEnhancement = 3.3;
26 double gravity = 9.81;
27 double seaLevel = 0.0;
28 double choppiness = 0.5;
29 glm::dvec2 windDirection{1.0, 0.0};
30 glm::dvec2 current{0.0};
31 std::vector<OceanSpectrumBand> bands{{64, 64.0, 2.0, 8.0}, {64, 256.0, 8.0, 64.0}, {64, 1024.0, 64.0, 1024.0}};
32};
33
36 unsigned resolution = 0;
37 double length = 0.0;
38 std::vector<glm::dvec3> displacement;
39 std::vector<glm::dvec3> velocity;
40};
41
45 double foam = 0.0;
46 glm::dvec3 position{0.0};
47 glm::dvec3 tangentX{1.0, 0.0, 0.0};
48 glm::dvec3 tangentZ{0.0, 0.0, 1.0};
50 glm::dvec3 normal() const { return glm::normalize(glm::cross(tangentZ, tangentX)); }
51};
52
53class OceanSpectrum;
54class OceanSpectrumFrameBuilder;
55struct OceanSpectrumData;
56
62public:
64 std::span<const OceanSpectrumGrid> grids() const { return grids_; }
66 double time() const { return time_; }
83
84private:
88 OceanSpectrumFrame() = default;
89 double time_ = 0.0;
90 double seaLevel_ = 0.0;
91 glm::dvec2 current_{0.0};
92 std::vector<OceanSpectrumGrid> grids_;
93};
94
97public:
101 EVENGINE_API_DOMAINS double variance() const;
102
103private:
107 explicit OceanSpectrum(std::shared_ptr<const OceanSpectrumData> data) : data_(std::move(data)) {}
108 std::shared_ptr<const OceanSpectrumData> data_;
109};
110
123
126public:
134
135private:
136 friend class OceanSpectrum;
137 OceanSpectrumFrameBuilder(std::shared_ptr<const OceanSpectrumData> data, double time)
138 : data_(std::move(data)), time_(time) {}
139 std::shared_ptr<const OceanSpectrumData> data_;
140 double time_;
141};
142} // namespace eve::fluids
#define EVENGINE_API_DOMAINS
Definition Export.h:110
std::array< float, 3 > position
std::string geometry
Move-only operation result carrying either a value or Status.
Definition Result.h:176
Borrowed diagnostic readback builder; revision checked again at build, never silently reads a newer f...
Prepare GPU allocation from an owning immutable spectrum lease; providers borrowed through build().
Own endpoint leases immediately; changing/destroying original spectra cannot affect build.
Owning transition projection preparation; no borrowed source lifetime requirements.
Authored construction stage; build copies settings and never retains builder references.
EVENGINE_API_DOMAINS Result< OceanSpectrum > build() const
Validate band coverage and build seeded JONSWAP coefficients atomically.
Owns a shared immutable spectrum lease and timestamp; safe after the original spectrum is destroyed.
EVENGINE_API_DOMAINS Result< OceanSpectrumFrame > build() const
Evaluate six fields through inverse FFT and publish an owning frame.
Immutable spatial projection at one simulation timestamp, independent of its spectrum owner....
double time() const
Simulation seconds used to generate every grid in this frame.
EVENGINE_API_DOMAINS Result< OceanSurfaceSample > sample(glm::dvec2 worldXZ) const
Invert horizontal displacement at world XZ and return the matching water sample.
std::span< const OceanSpectrumGrid > grids() const
Borrow immutable grids until this frame is destroyed or moved; do not retain across mutation.
Immutable initial spectrum; data is shared only with owning frame builders.
EVENGINE_API_DOMAINS OceanSpectrumFrameBuilder frameBuilder(double time) const
Prepare a cheap owning builder; time validation and FFT work occur at build().
EVENGINE_API_DOMAINS double variance() const
Expected ensemble surface variance, normalized to significantWaveHeight squared / 16.
GLSL compute kernels for the GPU surface-flow solver.
Definition FluidTarget.h:12
A periodic spectral tile; disjoint wavelength bands prevent duplicated energy.
Owning periodic displacement and particle velocity arrays; index = z * resolution + x.
std::vector< glm::dvec3 > velocity
std::vector< glm::dvec3 > displacement
Authored JONSWAP wind sea in SI units; seed names the ocean phase stream.
std::vector< OceanSpectrumBand > bands
Owning parametric surface geometry; derivatives are with respect to undisplaced world X and Z.
double foam
Local persistent foam coverage, composed by OceanWaterView from its wake owner.
glm::dvec3 normal() const
Compute the oriented unit normal from the same derivatives used by world-space queries.