Skip to content

raisin::WaterFlow ​

struct · #include <rayrai/Water.hpp>

Shallow-water simulation of a Rectangle body (WaterBody::flow).

The rectangle becomes a grid of cells over the scene under it. Water flows downhill over that bed under gravity and bed friction, fills hollows, parts around whatever rises through it and runs out at open edges; its waves travel at the speed shallow water allows. The bed is the highest surface under each cell below center.z + bedCeiling, down to center.z - depth: RaiSim objects, visuals and instanced visuals that cast shadows, except foliage that sways in the wind. RaiSim bodies that are not static push the water aside and leave wakes while any part of them is below its surface. The rest of the bed is captured again when objects or visuals are added or removed, or a static RaiSim object moves or changes its body type; a visual that moves is not followed.

The simulation runs on the GPU and advances with the water clock (RayraiWindow::advanceWaterTime); it starts with water up to center.z in every cell whose bed is lower, so a center.z below the bed starts dry. The surface is drawn from the simulated depth and velocity: the ripples, foam and caustics drift with the current, and foam forms where the water runs fast and shallow. Gerstner waves still ride on top, fading out where the water is shallow.

Public attributes ​

enabled ​

cpp
bool enabled

Simulate the body, which must be a Rectangle.

cellSize ​

cpp
float cellSize

Grid spacing, metres, [0.01, 100]; the rectangle may span at most kMaxWaterFlowCells cells per side. Smaller cells resolve narrower streams and smaller wakes at a higher cost.

manningRoughness ​

cpp
float manningRoughness

Manning roughness of the bed, s/m^(1/3), [0, 0.5]: about 0.012 for concrete, 0.03 for a natural stream bed and 0.1 for a weedy one.

edges ​

cpp
WaterFlowEdges edges

Edges of the rectangle.

bedCeiling ​

cpp
float bedCeiling

Height above center.z up to which scene geometry forms the bed, metres, (0, 1e4]. A solid that reaches above it blocks the water; anything wholly above it (a bridge deck, a canopy) does not.

movingBodies ​

cpp
bool movingBodies

Capture the RaiSim bodies that move every frame so they push the water.

foamStrength ​

cpp
float foamStrength

Foam where the water runs fast and shallow, [0, 1]; 0 turns it off.

sources ​

cpp
std::vector<WaterFlowSource> sources

At most kMaxWaterFlowSources.

RaiSim — physics for robotics and AI.