Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
Debris thinned by raea-sys-touch's rule, a crack's bounds by parry's Aabb (two near copies folded)
shinyobjectzc37509d17ff9
diff --git a/systems/damage/src/lib.rs b/systems/damage/src/lib.rsindex bae2cfdb..f2f86abe 100644--- a/systems/damage/src/lib.rs+++ b/systems/damage/src/lib.rs@@ -13,6 +13,7 @@#[cfg(test)]mod tests;+use parry3d::bounding_volume::Aabb;use parry3d::glamx::Vec3;use parry3d::query::{Ray, RayCast};use rayon::prelude::*;@@ -181,8 +182,8 @@ pub fn cracks(s: &Surface, pts: &[Point]) -> (Vec<f32>, Vec<Corner>) {.iter().map(|c| {let path = crack(s, c);- let (lo, hi) = path.iter().fold((Vec3::splat(f32::MAX), Vec3::splat(f32::MIN)), |(l, h), &p| (l.min(p), h.max(p)));- (c.n, path, lo - Vec3::splat(REACH), hi + Vec3::splat(REACH))+ let b = Aabb::from_points(path.iter().copied());+ (c.n, path, b.mins - Vec3::splat(REACH), b.maxs + Vec3::splat(REACH))}).collect();let d = pts@@ -217,7 +218,7 @@ fn landing(s: &Surface, q: &Point) -> Option<Vec3> {/// Debris on the walking surface in front of outdoor plaster whose loss potential is high, one a GAP_DEBRIS apart,/// each with the potential of the plaster above it.pub fn debris(s: &Surface, pts: &[Point], crack: &[f32]) -> Vec<(Spot, f32)> {- let mut c: Vec<(Spot, f32)> = pts+ let c: Vec<(Spot, f32)> = pts.iter().zip(crack).filter(|(q, _)| standing(s, q) && s.mat[q.tri as usize] == Mat::Plaster && q.ground <= LOSS[1] && q.rain >= OUTDOORS)@@ -225,13 +226,7 @@ pub fn debris(s: &Surface, pts: &[Point], crack: &[f32]) -> Vec<(Spot, f32)> {.filter(|(_, l)| *l >= DEBRIS_LOSS).filter_map(|(q, l)| Some((Spot { what: "debris", by: "weather", at: landing(s, q)?, n: s.up, size: DEBRIS }, l))).collect();- c.sort_by_key(|(sp, _)| raea_sys_touch::seed(sp.at));- let mut kept: Vec<(Spot, f32)> = Vec::new();- for x in c {- if !kept.iter().any(|k| k.0.at.distance(x.0.at) < GAP_DEBRIS) {- kept.push(x);- }- }+ let mut kept = raea_sys_touch::thin_by(c, GAP_DEBRIS, |x| x.0.at, |_| true);kept.sort_by(|a, b| a.0.at.x.total_cmp(&b.0.at.x).then(a.0.at.z.total_cmp(&b.0.at.z)));kept}diff --git a/systems/touch/src/lib.rs b/systems/touch/src/lib.rsindex 7f1a414b..4edeb4ee 100644--- a/systems/touch/src/lib.rs+++ b/systems/touch/src/lib.rs@@ -21,7 +21,7 @@ use std::collections::HashMap;use parry3d::glamx::Vec3;use parry3d::shape::TriMesh;-pub use spots::Spot;+pub use spots::{Spot, thin_by};/// Bumped when the output would change for the same input (a bake that uses it keys on it).pub const VERSION: &str = "raea-sys-touch 5";diff --git a/systems/touch/src/spots.rs b/systems/touch/src/spots.rsindex eba178a4..2bd239b5 100644--- a/systems/touch/src/spots.rs+++ b/systems/touch/src/spots.rs@@ -83,12 +83,19 @@ fn thin(c: Vec<Spot>, gap: f32) -> Vec<Spot> {}/// As thin, keeping only candidates that pass `ok` (tested only on those the gap leaves).-fn thin_if(mut c: Vec<Spot>, gap: f32, ok: impl Fn(&Spot) -> bool) -> Vec<Spot> {- c.sort_by_key(|s| seed(s.at));- let mut kept: Vec<Spot> = Vec::new();- for s in c {- if !kept.iter().any(|k| k.at.distance(s.at) < gap) && ok(&s) {- kept.push(s);+fn thin_if(c: Vec<Spot>, gap: f32, ok: impl Fn(&Spot) -> bool) -> Vec<Spot> {+ thin_by(c, gap, |s| s.at, ok)+}++/// Candidates of any kind kept in seed order of where each is (`at`), none nearer than `gap` to one kept, and only+/// those that pass `ok` (tested only on those the gap leaves): thin's rule for what carries a spot (raea-sys-damage's+/// debris with its loss).+pub fn thin_by<T>(mut c: Vec<T>, gap: f32, at: impl Fn(&T) -> Vec3, ok: impl Fn(&T) -> bool) -> Vec<T> {+ c.sort_by_cached_key(|x| seed(at(x)));+ let mut kept: Vec<T> = Vec::new();+ for x in c {+ if !kept.iter().any(|k| at(k).distance(at(&x)) < gap) && ok(&x) {+ kept.push(x);}}keptdiff --git a/tools/dupes.max b/tools/dupes.maxindex 84a20044..54dcb9cc 100644--- a/tools/dupes.max+++ b/tools/dupes.max@@ -30,4 +30,4 @@# core/grow's would change every tree)# near: runtime/live props.rs Live::controls/held (accessors); io/av1 and io/soft Backend::sound (one-line forwards)exact=294-near=59+near=58