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
| Returns | Name | Description |
|---|---|---|
void | SelectNodes | Depth-first selection, deterministic in node order. |
float | DistanceToNode | Distance from a node's square to a point, 0 inside. |
float | MorphFactor | 0 = keep this level's own sampling, 1 = fully collapsed onto the parent's. |
FWaterSplineMesh | BuildMesh | Meshes the selected nodes into one buffer. |
Vec2 | SnapCenter | Root centre snapped to the finest leaf's vertex spacing. |
float | LeafVertexStep | Vertex spacing of the finest level, in metres. |
Function details
SelectNodes
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
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
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
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
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
static float LeafVertexStep(const FWaterQuadTreeParams& params)Vertex spacing of the finest level, in metres.