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.

LT1: raea light check finds the home folder on every OS (raea_io_home), raea-light gets its layer, and three one-line closures no longer copy others'.

shinyobjectz2b8ca92365cb
diff --git a/Cargo.lock b/Cargo.lock
index 07b24fc4..df171b92 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -14693,6 +14693,7 @@ name = "raea-light"
version = "0.1.0"
dependencies = [
"image",
+ "raea-io-home",
"raea-runtime-bundle",
"serde_json",
]
diff --git a/engine/light/Cargo.toml b/engine/light/Cargo.toml
index 66d7b317..db197d68 100644
--- a/engine/light/Cargo.toml
+++ b/engine/light/Cargo.toml
@@ -11,3 +11,5 @@ image = { version = "0.25", default-features = false, features = ["png"] }
serde_json = "1"
# the CLI's flag reader and result type
raea-runtime-bundle = { path = "../../runtime/bundle" }
+# the home folder on every OS (HOME, then USERPROFILE)
+raea-io-home = { path = "../../io/home" }
diff --git a/engine/light/src/lib.rs b/engine/light/src/lib.rs
index 0920866e..b07e9d2a 100644
--- a/engine/light/src/lib.rs
+++ b/engine/light/src/lib.rs
@@ -49,7 +49,7 @@ struct Scene {
const LIVE_SECONDS: &str = "6";
fn home(p: &str) -> PathBuf {
- match (p.strip_prefix("~/"), std::env::var_os("HOME")) {
+ match (p.strip_prefix("~/"), raea_io_home::user_home()) {
(Some(rest), Some(h)) => PathBuf::from(h).join(rest),
_ => PathBuf::from(p),
}
@@ -234,14 +234,14 @@ pub fn light(args: &[String]) -> R<String> {
let list = scenes(Path::new(&args[1]))?;
let out = PathBuf::from(flag(args, "-o").ok_or(format!("usage: {USAGE}"))?);
let only = flag(args, "--scene");
- let paths: Vec<String> = flag(args, "--paths").map_or_else(|| PATHS.iter().map(|p| p.to_string()).collect(), |p| p.split(',').map(str::to_string).collect());
+ let paths: Vec<String> = flag(args, "--paths").map_or_else(|| PATHS.map(String::from).to_vec(), |p| p.split(',').map(String::from).collect());
if let Some(p) = paths.iter().find(|p| !PATHS.contains(&p.as_str())) {
return Err(format!("--paths: {p} isn't a light path to check ({})", PATHS.join(", ")));
}
let spp: u32 = flag(args, "--spp").map(|v| v.parse().map_err(|_| format!("--spp {v}: a count of samples"))).transpose()?.unwrap_or(256);
let fresh = args.iter().any(|a| a == "--fresh");
let mut reports = Vec::new();
- for s in list.iter().filter(|s| only.as_deref().is_none_or(|o| o == s.name)) {
+ for s in list.iter().filter(|s| match &only { Some(o) => *o == s.name, None => true }) {
eprintln!("raea light: {} ...", s.name);
reports.push(check(s, &paths, spp, &out, fresh)?);
}
diff --git a/engine/light/src/metric.rs b/engine/light/src/metric.rs
index e5e0e463..3befc92b 100644
--- a/engine/light/src/metric.rs
+++ b/engine/light/src/metric.rs
@@ -81,7 +81,7 @@ pub fn distance(a: &Luma, reference: &Luma) -> Result<Distance, String> {
t.1 += 1;
}
let n = a.y.len().max(1) as f64;
- let (k, worst) = tiles.iter().enumerate().map(|(k, (s, c))| (k, s / (*c).max(1) as f64)).fold((0, 0.0), |b, t| if t.1 > b.1 { t } else { b });
+ let (k, worst) = tiles.iter().enumerate().map(|(k, &(s, c))| (k, s / c.max(1) as f64)).fold((0, 0.0), |b, t| if t.1 > b.1 { t } else { b });
Ok(Distance { mean: (sum / n) as f32, bias: (signed / n) as f32, worst: worst as f32, worst_at: (k % tw, k / tw) })
}
diff --git a/tools/layers.toml b/tools/layers.toml
index 9a212298..7e76bb4d 100644
--- a/tools/layers.toml
+++ b/tools/layers.toml
@@ -78,6 +78,8 @@ raea-sys-parity = "systems" # the parity probe, in raea's App and the examples'
raea-bench-swatch = "systems" # a Blitz widget fixture (bench/bridge/swatch) the plugin catalog declares: a leaf on vendored crates, so a runtime crate may build it in
raea-render = "runtime"
raea-render-raytrace = "runtime"
+# `raea light check`: raea Light's measures (docs/realism.feature LT1)
+raea-light = "runtime"
raea-bevy-plugins = "runtime"
raea-bevy-calls = "runtime"
raea-bevy-adapters = "runtime"