8 if (
s.segments < 16 ||
s.segments > 1024 ||
s.segments % 8 != 0 ||
s.rings < 2 ||
s.rings > 512 ||
9 !std::isfinite(
s.firstRadius) || !std::isfinite(
s.outerRadius) ||
s.firstRadius < 0.01 ||
10 s.outerRadius <
s.firstRadius *
s.rings ||
s.outerRadius > 1
e6)
15 auto extent = [&](
double growth) {
16 double width =
s.firstRadius, total = 0.0;
17 for (
unsigned ring = 0; ring <
s.rings; ++ring) {
23 double lo = 1.0,
hi = 1.0 +
s.outerRadius /
s.firstRadius;
25 const double mid = (
lo +
hi) * 0.5;
26 if (extent(
mid) <
s.outerRadius)
31 const double growth = (
lo +
hi) * 0.5;
34 result.indices.reserve(3 *
s.segments * (2 *
s.rings - 1));
36 result.parameterOffsets.emplace_back(0.0);
38 for (
unsigned ring = 0; ring <
s.rings; ++ring) {
41 if (ring + 1 ==
s.rings)
radius =
s.outerRadius;
44 for (
unsigned segment = 0; segment <
s.segments; ++segment) {
45 const unsigned side = segment / (
s.segments / 4);
46 const double t = 2.0 * (segment % (
s.segments / 4)) / (
s.segments / 4) - 1.0;
55 const auto outer = 1 + ring *
s.segments + segment;
56 const auto next = 1 + ring *
s.segments + (segment + 1) %
s.segments;
58 result.indices.insert(
result.indices.end(), {0, next, outer});
60 const auto inner = outer -
s.segments;
62 result.indices.insert(
result.indices.end(), {inner, next, outer, inner, innerNext, next});
RoadLaneDirection direction
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.
static Result success(T value)
Construct a successful result owning value.
static Result failure(Status status)
Construct a failed result from a structured status.
EVENGINE_API_DOMAINS Result< OceanMeshData > build() const
Build positively oriented triangles on XZ, graded geometrically from near water to horizon.
OceanMeshSettings settings
Value vector(glm::dvec3 v)
GLSL compute kernels for the GPU surface-flow solver.
Owning immutable topology projection; XZ offsets are relative to the render origin....
std::vector< glm::dvec2 > parameterOffsets