载入中...
搜索中...
未找到
OceanWake.cpp
浏览该文件的文档.
21bool finite(glm::dvec2 p) { return std::isfinite(p.x) && std::isfinite(p.y) && glm::length(p) <= 1e9; }
25 Diagnostic::error(DiagnosticCode::InvalidArgument, "Invalid ocean wake input", "fluids.ocean.wake"));
32 !std::isfinite(s.length) || s.length < 8.0 || s.length > 4096.0 || !std::isfinite(s.depth) || s.depth < 0.1 ||
34 !std::isfinite(s.damping) || s.damping < 0.0 || s.damping > 10.0 || !std::isfinite(s.absorptionWidth) ||
44 return Result<std::unique_ptr<OceanWake>>::success(std::unique_ptr<OceanWake>(new OceanWake(std::move(impl))));
48 if (impl_->revision == std::numeric_limits<std::uint64_t>::max() || impulses.size() > 256) return invalid<void>();
51 p.radius < s.length / s.resolution || p.radius > s.length * 0.25 || !std::isfinite(p.velocity) ||
65 const double shape = directionLength > 1e-8 ? glm::dot(delta, p.direction / directionLength) : 1.0;
76OceanWakeStep::OceanWakeStep(std::unique_ptr<OceanWake> candidate) : candidate_(std::move(candidate)) {}
80 if (impl_->revision == std::numeric_limits<std::uint64_t>::max()) return invalid<std::unique_ptr<OceanWakeStep>>();
91 DiagnosticCode::Conflict, "Ocean wake candidate is foreign, consumed or stale", "fluids.ocean.wake"));
99 std::abs(endTime - impl_->time - dt) > 1e-8 || endTime > 1e9 || std::abs(water.time() - impl_->time) > 1e-8)
177 std::hypot(impl_->height[i + 1] - impl_->height[i - 1], impl_->height[i + n] - impl_->height[i - n]) /
180 const double curvature = (4.0 * impl_->height[i] - impl_->height[i + 1] - impl_->height[i - 1] -
183 const double crest = std::clamp(impl_->height[i] / 0.6, 0.0, 1.0) * std::clamp(curvature / 0.10, 0.0, 1.0);
192 if (impl_->revision == std::numeric_limits<std::uint64_t>::max() || !finite(center)) return invalid<void>();
257OceanWakeGridView OceanWake::gridView() const { return {impl_->settings, impl_->time, impl_->height, impl_->foam}; }
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
Immutable spatial projection at one simulation timestamp, independent of its spectrum owner....
Definition OceanSpectrum.h:61
Owning, single-use candidate; no source frame, owner pointer or GPU resource is retained....
Definition OceanWake.h:119
OceanWakeStep(const OceanWakeStep &)=delete
EVENGINE_API_DOMAINS ~OceanWakeStep()
Caller-owned wave field with finite-depth gravity dispersion and absorbing boundaries....
Definition OceanWake.h:53
EVENGINE_API_DOMAINS Result< void > recenter(glm::dvec2 center)
Move the window by whole cells, retaining overlapping world-space history.
Definition OceanWake.cpp:191
EVENGINE_API_DOMAINS OceanWakeSettings settings() const
Owning configuration including current window center.
Definition OceanWake.cpp:256
EVENGINE_API_DOMAINS Result< void > commitStep(OceanWakeStep &step)
Publish a prepared candidate by constant-time state swap without allocation.
Definition OceanWake.cpp:87
static EVENGINE_API_DOMAINS Result< std::unique_ptr< OceanWake > > create(const OceanWakeSettings &settings)
Construct a checked field via explicit settings; copies settings and retains no input.
Definition OceanWake.cpp:30
EVENGINE_API_DOMAINS Result< void > inject(std::span< const OceanWakeImpulse > impulses)
Inject a bounded batch of localized disturbances atomically into vertical velocity/foam.
Definition OceanWake.cpp:46
OceanWake(const OceanWake &)=delete
EVENGINE_API_DOMAINS Result< std::unique_ptr< OceanWakeStep > > prepareStep(double dt, double endTime, const OceanSpectrumFrame &water) const
Prepare an owning candidate for one fixed step with exact per-mode dispersion omega² = g*k*tanh(k*dep...
Definition OceanWake.cpp:78
EVENGINE_API_DOMAINS double time() const
Current externally advanced simulation time, initially zero.
Definition OceanWake.cpp:255
EVENGINE_API_DOMAINS OceanWakeGridView gridView() const
Borrow raw height/foam for immediate GPU upload; never retain across mutation or destruction.
Definition OceanWake.cpp:257
EVENGINE_API_DOMAINS Result< OceanWakeSample > sample(glm::dvec2 worldXZ) const
Query a world point; returns zero outside the tile, InvalidArgument for nonfinite inputs.
Definition OceanWake.cpp:217
EVENGINE_API_DOMAINS ~OceanWake()
std::array< double, 4 > derivatives(double t)
Definition OceanInterpolationInternal.h:8
std::array< double, 4 > weights(double t)
Definition OceanInterpolationInternal.h:4
void forward2D(std::vector< Complex > &a, unsigned n)
Produce normalized Fourier amplitudes from a validated N by N spatial grid. @cost O(N squared log N) ...
Definition OceanFourierInternal.h:57
void inverse2D(std::vector< Complex > &a, unsigned n)
Transform a validated N by N grid in place using row/column scratch. @cost O(N squared log N) arithme...
Definition OceanFourierInternal.h:39
Status invalid(const char *message)
Definition OceanBindingInternal.h:21
@ InvalidArgument
@ Conflict
Definition Container.h:602
Call-only borrowed raw grids; owner must remain alive and unmodified during consumption.
Definition OceanWake.h:42
Local world-space height perturbation, world slope and vertical particle speed.
Definition OceanWake.h:35
Local dispersive wave tile, SI units; kept independent of the observing camera.
Definition OceanWake.h:16
Definition OceanWake.cpp:13