class

FWaterQuadTree

A camera-following quadtree over one ocean body: the frustum's worth of the surface is meshed finely and the rest coarsely, so a 4 km ocean costs what is on screen rather than what exists. UE's WaterQuadTree has the same shape; lakes and rivers keep their spline meshes, because a closed polygon and a ribbon are not grids and gain nothing from a quadtree.

Module
Game
Header
#include "Water/WaterQuadTree.h"
Namespace
Mowo

Everything here is pure geometry over a viewer position — no world, no renderer — so the selection a camera produces is a headless test.

Public functions

ReturnsNameDescription
voidSelectNodesDepth-first selection, deterministic in node order.
floatDistanceToNodeDistance from a node's square to a point, 0 inside.
floatMorphFactor0 = keep this level's own sampling, 1 = fully collapsed onto the parent's.
FWaterSplineMeshBuildMeshMeshes the selected nodes into one buffer.
Vec2SnapCenterRoot centre snapped to the finest leaf's vertex spacing.
floatLeafVertexStepVertex spacing of the finest level, in metres.

Function details

SelectNodes

C++
static void SelectNodes(const FWaterQuadTreeParams& params, const Vec2& viewLocalXZ, std::vector<FWaterQuadNode>& outNodes)

Depth-first selection, deterministic in node order. A node subdivides while the viewer is inside size * lodScale of its square and the level budget allows; the leaves it returns tile the root exactly.

DistanceToNode

C++
static float DistanceToNode(const FWaterQuadNode& node, const Vec2& viewLocalXZ)

Distance from a node's square to a point, 0 inside. The selection rule and the morph factor both measure with this, so a vertex never morphs against a distance its own node did not subdivide against.

MorphFactor

C++
static float MorphFactor(const FWaterQuadTreeParams& params, const FWaterQuadNode& node, const Vec2& viewLocalXZ)

0 = keep this level's own sampling, 1 = fully collapsed onto the parent's. Rises across the far end of the node's LOD range.

BuildMesh

C++
static FWaterSplineMesh BuildMesh(const FWaterQuadTreeParams& params, const std::vector<FWaterQuadNode>& nodes, const Vec2& viewLocalXZ)

Meshes the selected nodes into one buffer. Vertices are welded per node only — neighbouring nodes of the same level share an edge exactly, and a level boundary is sealed by the morph rather than by a stitch strip, which is the whole point of morphing.

SnapCenter

C++
static Vec2 SnapCenter(const FWaterQuadTreeParams& params, const Vec2& viewLocalXZ)

Root centre snapped to the finest leaf's vertex spacing. Exposed because the rebuild trigger compares against it: the mesh is only worth rebuilding when the snapped centre actually moved.

LeafVertexStep

C++
static float LeafVertexStep(const FWaterQuadTreeParams& params)

Vertex spacing of the finest level, in metres.

Generated from Water/WaterQuadTree.h via game.json · Nov 5, 2026Version 1.0.0