using Godot; /// /// The island-falloff shaping functions (terrain-water task 11) — pure numeric /// functions of their inputs (D-035; a named future C++ candidate, kept standalone). /// /// SMOOTH CREST — the mountain spine's ridge axis is the line x = centre, and /// `1 - |x - cx|` peaks there with a slope discontinuity. Measured on the shipped /// terrain, that crease is the single largest slope step anywhere on the map once /// the by-design Trench walls are excluded (top 4 of 5999 columns). SmoothAbs /// rounds the crest without moving its height. /// public static class IslandFalloff { // ---- centre-line crest ------------------------------------------------ // Rounding radius in normalized spine-width units (1.0 = MapSize/2 * 1.15 // ~ 4710 px at 8K). 0.03 ~ 141 px: it cuts the crest's 1-px kink by 99.3% // (-7.64e-04 -> -5.41e-06 raw, against a natural profile curvature of ~1.1e-07) // while filling at most 3.9 m, decaying under 0.5 m by ~1100 px from the axis. public const float CREST_EPSILON = 0.03f; /// /// A C¹ stand-in for |d|: exactly 0 with zero slope at d = 0, and converging to /// |d| within e²/(2|d|) away from it. Replaces the V-shaped crest of the spine /// with a rounded one WITHOUT lowering it — SmoothAbs(0) is 0, so the peak keeps /// its full height. /// public static float SmoothAbs(float d, float epsilon) { float a = Mathf.Abs(d); return a * a / Mathf.Sqrt(a * a + epsilon * epsilon); } }