Water depth at p inside the triangle (a,b,c).
- Parameters
-
| p | Sample point (scene space). |
| a,b,c | Triangle corner positions (scene space). |
| z0,z1,z2 | Corner bed elevations, in corner order a,b,c. |
| sd0,sd1,sd2 | Corner SIGNED depths (η_k − z_k); exactly 0 == no data. |
| degenerate | Optional out-flag: set true (with return 0) when the triangle is degenerate and barycentric weights are undefined — the caller falls back to its cell value. |
- Returns
- depth ≥ 0; 0 when no corner carries a valid η (cell is dry).
Algorithm (plan + iteration 2 after visual review):
- barycentric weights (w,v,u) against (a,b,c) — identical construction to SWMM2DMeshLayer::sampleZAt so ground and depth share one basis;
- η_k = z_k + sd_k; a corner SUPPLIES surface only when WET (sd_k > 0); sd_k < 0 (η below that corner's own bed) and sd_k == 0 (no data) corners carry no water and are excluded from the blend AND the cap;
- nWet == 0 → 0 (dry) ; nWet == 3 → plain signed-depth blend (bit-identical to the pre-existing fully-wet path) ; else → weight-renormalized average of the wet corners' η (equals the plain lerp on an all-wet edge; holds level toward non-supplying corners — zero gradient in the dry direction);
- cap η at the max over WET corners (driving head — guards extrapolating weights at/outside the edge);
- return max(0, η − ground_interp).