载入中...
搜索中...
未找到
OceanWaterView.cpp
浏览该文件的文档.
2#include "fluids/OceanWake.h"
3
4#include <cmath>
5
6namespace eve::fluids {
7namespace {
8template <class T>
10 return Result<T>::failure(
11 Diagnostic::error(DiagnosticCode::InvalidArgument, "Ocean and wake timestamps differ", "fluids.ocean.time"));
12}
13} // namespace
15 auto base = spectrum_.get().sample(worldXZ);
16 if (!base) return base;
17 if (!wake_) return base;
18 if (std::abs(wake_->get().time() - time()) > 1e-8) return staleTime<OceanSurfaceSample>();
19 auto local = wake_->get().sample(worldXZ);
20 if (!local) return Result<OceanSurfaceSample>::failure(local.status());
21 auto value = base.value();
22 value.height += local.value().height;
23 value.velocity.y +=
24 local.value().velocity + glm::dot(glm::dvec2(value.velocity.x, value.velocity.z), local.value().gradient);
25 const auto gradient = glm::dvec2(-value.normal.x, -value.normal.z) / value.normal.y + local.value().gradient;
26 value.normal = glm::normalize(glm::dvec3(-gradient.x, 1.0, -gradient.y));
28}
30 auto base = spectrum_.get().position(parameterXZ);
31 if (!base) return base;
32 if (!wake_) return base;
33 if (std::abs(wake_->get().time() - time()) > 1e-8) return staleTime<glm::dvec3>();
34 auto value = base.value();
35 auto local = wake_->get().sample({value.x, value.z});
36 if (!local) return Result<glm::dvec3>::failure(local.status());
37 value.y += local.value().height;
39}
41 auto base = spectrum_.get().geometry(parameterXZ);
42 if (!base || !wake_) return base;
43 if (std::abs(wake_->get().time() - time()) > 1e-8) return staleTime<OceanSurfaceGeometry>();
44 auto value = base.value();
45 auto local = wake_->get().sample({value.position.x, value.position.z});
47 value.position.y += local.value().height;
48 value.foam = local.value().foam;
49 value.tangentX.y += glm::dot(local.value().gradient, glm::dvec2(value.tangentX.x, value.tangentX.z));
50 value.tangentZ.y += glm::dot(local.value().gradient, glm::dvec2(value.tangentZ.x, value.tangentZ.z));
52}
53} // namespace eve::fluids
std::string local
Object::Ptr value
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
double time() const
Shared injected simulation timestamp.
EVENGINE_API_DOMAINS Result< OceanSurfaceGeometry > geometry(glm::dvec2 parameterXZ) const
Evaluate combined position and tangents directly; wake gradients follow displaced world XZ.
EVENGINE_API_DOMAINS Result< OceanSurfaceSample > sample(glm::dvec2 worldXZ) const
Query combined water in world coordinates; errors propagate without changing either owner.
EVENGINE_API_DOMAINS Result< glm::dvec3 > position(glm::dvec2 parameterXZ) const
Displace a mesh parameter point and add wake height at the resulting world XZ.
GLSL compute kernels for the GPU surface-flow solver.
Definition FluidTarget.h:12