FWaterCarveDebounce
Decides when an automatic terrain re-carve should follow a spline edit.
- Module
- Game
- Header
#include "Water/WaterCarveDebounce.h"- Namespace
Mowo
A carve rewrites a heightfield region, refits collision and pushes an undo record, so running one per dragged frame is both a stall and an undo stack a designer cannot walk back through. Running one only on a button is the state this shipped in, where the river and its bed silently disagree until someone remembers. The middle is a debounce: every edit re-arms the timer, and the carve runs once the edits stop.
It is a pure decision — no clock of its own, no terrain, no transaction — so the rule is testable headlessly and the panel that owns the carve keeps owning it.
Properties
| Type | Name | Description |
|---|---|---|
static constexpr float | kDefaultDelaySeconds | Seconds of quiet after the last edit before the carve runs. Long enough that releasing a handle to grab the next one is still one edit, short enough that the bed follows the water while the designer is still looking at it. Default 0.5f. |
Public functions
| Returns | Name | Description |
|---|---|---|
void | SetDelaySeconds | |
float | GetDelaySeconds | |
void | Touch | An edit landed. |
bool | IsPending | |
bool | Consume | True exactly once per settled burst of edits. |
void | Cancel | Drops a pending carve without running it — the body was deleted, the tool was disarmed, or the edit it belonged to was undone. |
Function details
SetDelaySeconds
void SetDelaySeconds(float seconds)GetDelaySeconds
float GetDelaySeconds() constTouch
void Touch(float nowSeconds)An edit landed. Re-arms the timer whether or not one was already pending — a drag is hundreds of these and must produce one carve at the end, not one per frame.
IsPending
bool IsPending() constConsume
bool Consume(float nowSeconds)True exactly once per settled burst of edits. Consuming the pending flag here rather than leaving it to the caller is deliberate: a caller that forgot to clear it would re-carve every frame forever, which is the failure this class exists to prevent.
Cancel
void Cancel()Drops a pending carve without running it — the body was deleted, the tool was disarmed, or the edit it belonged to was undone.