One smoothstep for the systems: raea_core_ease::smoothstep (raea-sys-damage's copied raea-sys-foliage's)

Neither crate can depend on the other (systems don't reach sideways), so the cubic Hermite ease goes down to
raea-core-ease, the curves crate, and both use it; foliage keeps its name for it (smooth). Behaviour unchanged:
cargo test -p raea-core-ease -p raea-sys-damage -p raea-sys-foliage pass.
This commit is contained in:
shinyobjectz committed 2026-11-19 09:58:24 -08:00
1 parent adec0aef74
commit 02051ee992
6 files changed
+15 -9

No files matched your search

Generated
+2
View File
@@ -15808,6 +15808,7 @@ name = "raea-sys-damage"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"parry3d", "parry3d",
"raea-core-ease",
"raea-sys-touch", "raea-sys-touch",
"rayon", "rayon",
] ]
@@ -15909,6 +15910,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"image", "image",
"parry3d", "parry3d",
"raea-core-ease",
"raea-sys-glb", "raea-sys-glb",
"serde_json", "serde_json",
] ]
+7
View File
@@ -7,3 +7,10 @@ pub mod color;
pub mod easing; pub mod easing;
pub mod interpolate; pub mod interpolate;
pub mod spring; pub mod spring;
/// 0 below `a`, 1 above `b`, and between them the cubic Hermite ease (WGSL's smoothstep), for a value that fades in
/// over a range rather than a key's time.
pub fn smoothstep(a: f32, b: f32, x: f32) -> f32 {
let t = ((x - a) / (b - a)).clamp(0.0, 1.0);
t * t * (3.0 - 2.0 * t)
}
+2
View File
@@ -10,3 +10,5 @@ description = "Where a building breaks: cracks from the corners of its openings,
parry3d = "0.31" parry3d = "0.31"
rayon = "1" rayon = "1"
raea-sys-touch = { path = "../touch" } raea-sys-touch = { path = "../touch" }
# smoothstep, shared with raea-sys-foliage
raea-core-ease = { path = "../../core/ease" }
+1 -5
View File
@@ -17,6 +17,7 @@ use parry3d::glamx::Vec3;
use parry3d::query::{Ray, RayCast}; use parry3d::query::{Ray, RayCast};
use rayon::prelude::*; use rayon::prelude::*;
use raea_core_ease::smoothstep as smooth;
use raea_sys_touch::{Mat, Point, Spot, Surface}; use raea_sys_touch::{Mat, Point, Spot, Surface};
/// A cache key's part: a change to the rules changes every bake that used them. /// A cache key's part: a change to the rules changes every bake that used them.
@@ -53,11 +54,6 @@ const DROP: f32 = 0.5;
/// walk from it /// walk from it
const OUTDOORS: f32 = 0.02; const OUTDOORS: f32 = 0.02;
fn smooth(a: f32, b: f32, x: f32) -> f32 {
let t = ((x - a) / (b - a)).clamp(0.0, 1.0);
t * t * (3.0 - 2.0 * t)
}
/// How readily the coat at `q` comes off (0-1), with `crack` its distance to the nearest crack (metres). /// How readily the coat at `q` comes off (0-1), with `crack` its distance to the nearest crack (metres).
pub fn loss(q: &Point, crack: f32) -> f32 { pub fn loss(q: &Point, crack: f32) -> f32 {
let l = &LOSS; let l = &LOSS;
+2
View File
@@ -11,3 +11,5 @@ parry3d = "0.31"
serde_json = "1" serde_json = "1"
image = { version = "0.25", default-features = false, features = ["png"] } image = { version = "0.25", default-features = false, features = ["png"] }
raea-sys-glb = { path = "../glb" } raea-sys-glb = { path = "../glb" }
# smoothstep, shared with raea-sys-damage
raea-core-ease = { path = "../../core/ease" }
+1 -4
View File
@@ -130,10 +130,7 @@ pub(crate) fn leaves(sp: &Species, req: &Request, nodes: &[Node], env: &Envelope
} }
/// 0 below `a`, 1 above `b`, smoothly between (a leaf's gaps, its teeth's roots in atlas.rs). /// 0 below `a`, 1 above `b`, smoothly between (a leaf's gaps, its teeth's roots in atlas.rs).
pub(crate) fn smooth(a: f32, b: f32, x: f32) -> f32 { pub(crate) use raea_core_ease::smoothstep as smooth;
let t = ((x - a) / (b - a)).clamp(0.0, 1.0);
t * t * (3.0 - 2.0 * t)
}
/// Value noise in 3D, 0 to 1, from a seed. /// Value noise in 3D, 0 to 1, from a seed.
fn noise3(p: Vec3, seed: u64) -> f32 { fn noise3(p: Vec3, seed: u64) -> f32 {