Skip to content

armgit / raea

Public Imported from GitHub
0

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.

FP11b: a mark's region and a matte's box share one union (grow.rs), and raea-perceive is looked for beside raea, then on PATH, in a loop of its own

shinyobjectz535acb5a4fa2
diff --git a/apps/fingerprint/src/notes.rs b/apps/fingerprint/src/notes.rs
index c2d37bfe..948c2041 100644
--- a/apps/fingerprint/src/notes.rs
+++ b/apps/fingerprint/src/notes.rs
@@ -63,7 +63,7 @@ pub fn region(pin: &Value) -> Option<[f32; 4]> {
let (Some(x), Some(y)) = (p[0].as_f64(), p[1].as_f64()) else { continue };
let (x, y) = (x as f32, y as f32);
let b = [(x - reach).max(0.0), (y - reach).max(0.0), (x + reach).min(1.0), (y + reach).min(1.0)];
- r = Some(r.map_or(b, |a| [a[0].min(b[0]), a[1].min(b[1]), a[2].max(b[2]), a[3].max(b[3])]));
+ r = Some(raea_sys_fingerprint_use::grow::union(r, b));
}
}
r.filter(|a| a[2] > a[0] && a[3] > a[1])
diff --git a/systems/fingerprint-use/src/grow.rs b/systems/fingerprint-use/src/grow.rs
index 7beafe05..7af42c3f 100644
--- a/systems/fingerprint-use/src/grow.rs
+++ b/systems/fingerprint-use/src/grow.rs
@@ -22,10 +22,18 @@ pub struct Grown {
/// raea-perceive: $RAEA_PERCEIVE, else beside this raea, else on PATH
pub fn perceive() -> Option<PathBuf> {
+ if let Some(p) = std::env::var_os("RAEA_PERCEIVE").filter(|v| !v.is_empty()) {
+ return Some(p.into());
+ }
let name = if cfg!(windows) { "raea-perceive.exe" } else { "raea-perceive" };
- let beside = std::env::current_exe().ok().and_then(|e| e.canonicalize().ok()).and_then(|e| Some(e.parent()?.join(name)));
- let on_path = std::env::var_os("PATH").into_iter().flat_map(|p| std::env::split_paths(&p).collect::<Vec<_>>()).map(|d| d.join(name));
- std::env::var_os("RAEA_PERCEIVE").filter(|v| !v.is_empty()).map(PathBuf::from).into_iter().chain(beside).chain(on_path).find(|p| p.is_file())
+ let mut dirs: Vec<PathBuf> = Vec::new();
+ if let Ok(exe) = std::env::current_exe().and_then(|e| e.canonicalize()) {
+ dirs.extend(exe.parent().map(Path::to_path_buf));
+ }
+ if let Some(path) = std::env::var_os("PATH") {
+ dirs.extend(std::env::split_paths(&path));
+ }
+ dirs.into_iter().map(|d| d.join(name)).find(|p| p.is_file())
}
/// The box around a matte's pixels at 128 or more, x0,y0,x1,y1 in 0-1; None when too little of it is on