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.

DR3: nothing reads as fixed by hiding it: a clip no frame shows is said as a note, a renamed part is renamed, a video from the export cache says what it found, a run is set against the one before of its kind; renders inside another (a review's tiles, a quick check's stills) keep no entry; a review's cameras face where they're put

shinyobjectzeab9198a1e1d
diff --git a/apps/check/src/lib.rs b/apps/check/src/lib.rs
index abeef5c4..d9bfab1f 100644
--- a/apps/check/src/lib.rs
+++ b/apps/check/src/lib.rs
@@ -178,12 +178,12 @@ fn report(video: &str, mut issues: Vec<Issue>, more: Vec<Finding>, passed: Vec<S
let mut s = format!("raea check {video}\n");
// kept in its project's record beside its renders (DR3), what `raea findings` and `raea next` read
let kept = raea_core_facts::record::keep("raea check", std::path::Path::new(video), out.map(std::path::Path::new), &found, vec![], &raea_io_trace::utc(std::time::SystemTime::now()).1);
- let kept = kept.map(|e| format!("kept in the project's record as {}", e.id));
+ let kept = kept.map(|e| format!("raea check: kept in the project's record as {} (raea findings reads it)", e.id));
for line in found.iter().map(Finding::line).chain(passed.iter().map(|p| format!("ok {p}"))).chain(kept) {
s.push_str(&line);
s.push('\n');
}
- Ok((s + &finding::count(&found), bad))
+ Ok((s + &format!("raea check: {}", finding::count(&found)), bad))
}
struct Probe {
diff --git a/apps/check/src/quick.rs b/apps/check/src/quick.rs
index a6bcc747..f1bc8dc0 100644
--- a/apps/check/src/quick.rs
+++ b/apps/check/src/quick.rs
@@ -22,7 +22,8 @@ pub fn quick(args: &[String], tastes: Vec<raea_core_brief::Taste>) -> R<(String,
std::fs::create_dir_all(&tmp).map_err(|e| format!("{}: {e}", tmp.display()))?;
let manifest = tmp.join("render.json");
let me = std::env::current_exe().map_err(|e| e.to_string())?;
- let out = std::process::Command::new(me).arg("render").arg(file).args(["--at", &at, "-o"]).arg(format!("{}/", tmp.display())).arg("--manifest").arg(&manifest).output().map_err(|e| e.to_string())?;
+ // the stills are part of this check, which keeps the one entry in the project's record (DR3)
+ let out = std::process::Command::new(me).arg("render").arg(file).args(["--at", &at, "-o"]).arg(format!("{}/", tmp.display())).arg("--manifest").arg(&manifest).env("RAEA_RECORD", "off").output().map_err(|e| e.to_string())?;
// rendered when its manifest was written: a render whose stills clip exits 1 (DR3), and those findings are read here
let result = if manifest.is_file() {
on_manifest(file, &manifest, args, tastes)
@@ -36,7 +37,7 @@ pub fn quick(args: &[String], tastes: Vec<raea_core_brief::Taste>) -> R<(String,
}
}
let f = raea_core_facts::Finding::new("render", raea_core_facts::Level::Error, why.join("\n"), "raea check --quick");
- Ok((format!("raea check {file}: it doesn't render\n{}\n{}", f.line(), raea_core_facts::finding::count(&[f])), true))
+ Ok((format!("raea check {file}: it doesn't render\n{}\nraea check: {}", f.line(), raea_core_facts::finding::count(&[f])), true))
};
let _ = std::fs::remove_dir_all(&tmp);
result
diff --git a/apps/direction/src/findings.rs b/apps/direction/src/findings.rs
index d0afdd74..fdc90251 100644
--- a/apps/direction/src/findings.rs
+++ b/apps/direction/src/findings.rs
@@ -9,7 +9,7 @@ use raea_core_facts::{Finding, finding};
use raea_runtime_bundle::flag;
use serde_json::{Value, json};
-pub const USAGE: &str = "raea findings [PROJECT | EDIT.tsx] [--about NAME] [--check ID] [--open] [--since RENDER] [--json] (what each render and raea check found, from the project's record: fixed, new and carried since the one before, or since RENDER; --open: only what stands)";
+pub const USAGE: &str = "raea findings [PROJECT|EDIT.tsx] [--about NAME] [--check ID] [--open] [--since RENDER] [--json] (what each render and raea check found, from the project's record: fixed, new and carried since the one before, or since RENDER; --open: only what stands)";
/// The oldest entry of the unbroken run up to the latest that all found `f`.
fn carried_since(entries: &[&Entry], f: &Finding) -> String {
@@ -29,17 +29,19 @@ fn compare(entries: &[&Entry], since: Option<&str>, keep: &dyn Fn(&Finding) -> b
let ch = record::changes(before.map_or(&none, |b| &b.findings), &now.findings);
let list = |fs: Vec<&Finding>| fs.into_iter().filter(|f| keep(f)).cloned().collect::<Vec<Finding>>();
let carried: Vec<Value> = list(ch.carried).into_iter().map(|f| json!({"since": carried_since(entries, &f), "finding": f})).collect();
+ let renamed: Vec<Value> = ch.renamed.into_iter().filter(|(_, n)| keep(n)).map(|(was, f)| json!({"was": was.about.iter().map(|a| &a.name).collect::<Vec<_>>(), "finding": f})).collect();
let fixed = if open { Vec::new() } else { list(ch.fixed) };
- Some(json!({"of": now.of, "id": now.id, "by": now.by, "commit": now.commit, "out": now.out, "against": before.map(|b| &b.id),
- "new": list(ch.new), "carried": carried, "fixed": fixed, "despite": now.despite}))
+ Some(json!({"of": now.of, "kind": now.kind, "id": now.id, "by": now.by, "commit": now.commit, "out": now.out, "against": before.map(|b| &b.id),
+ "new": list(ch.new), "carried": carried, "renamed": renamed, "fixed": fixed, "despite": now.despite}))
}
/// One thing's lines: its entry, then what is new, carried and fixed.
fn lines(r: &Value) -> Vec<String> {
let read = |v: &Value| serde_json::from_value::<Finding>(v.clone()).ok();
let mut t = vec![format!(
- "{} ({} {}{}, against {})",
+ "{} {} ({} {}{}, against {})",
r["of"].as_str().unwrap_or(""),
+ r["kind"].as_str().filter(|k| !k.is_empty()).unwrap_or("run"),
r["by"].as_str().unwrap_or(""),
r["id"].as_str().unwrap_or(""),
r["commit"].as_str().map(|c| format!(" at {c}")).unwrap_or_default(),
@@ -51,7 +53,15 @@ fn lines(r: &Value) -> Vec<String> {
t.push(format!(" carried {} (since {})", f.line(), c["since"].as_str().unwrap_or("")));
}
}
+ for c in r["renamed"].as_array().into_iter().flatten() {
+ if let Some(f) = read(&c["finding"]) {
+ let was: Vec<&str> = c["was"].as_array().into_iter().flatten().filter_map(Value::as_str).collect();
+ t.push(format!(" renamed {} (the same, about {} before: not fixed)", f.line(), was.join(", ")));
+ }
+ }
t.extend(r["fixed"].as_array().into_iter().flatten().filter_map(read).map(|f| format!(" fixed {}", f.line())));
+ // what was let through, and why: the error stands in the count all the same
+ t.extend(r["despite"].as_array().into_iter().flatten().map(|d| format!(" despite {}: {}", d["check"].as_str().unwrap_or(""), d["why"].as_str().unwrap_or(""))));
t
}
@@ -60,7 +70,7 @@ fn standing(reports: &[Value]) -> Vec<Finding> {
let mut out = Vec::new();
for r in reports {
out.extend(r["new"].as_array().into_iter().flatten().filter_map(|v| serde_json::from_value(v.clone()).ok()));
- out.extend(r["carried"].as_array().into_iter().flatten().filter_map(|c| serde_json::from_value(c["finding"].clone()).ok()));
+ out.extend(["carried", "renamed"].iter().flat_map(|k| r[*k].as_array().into_iter().flatten()).filter_map(|c| serde_json::from_value(c["finding"].clone()).ok()));
}
out
}
@@ -78,11 +88,12 @@ pub fn cli(args: &[String]) -> Result<String, String> {
let keep = |f: &Finding| about.as_deref().is_none_or(|n| f.about.iter().any(|a| a.name == n || a.key.as_deref() == Some(n))) && check.as_deref().is_none_or(|c| f.check == c);
let all = record::read(&project);
let only = target.is_file().then(|| record::rel(&project, &target));
- let mut ofs: Vec<&str> = all.iter().map(|e| e.of.as_str()).filter(|o| only.as_deref().is_none_or(|w| w == *o)).collect();
+ // each thing by what kind of output it was (a video against the video before it, a review against a review)
+ let mut ofs: Vec<(&str, &str)> = all.iter().map(|e| (e.of.as_str(), e.kind.as_str())).filter(|(o, _)| only.as_deref().is_none_or(|w| w == *o)).collect();
ofs.sort();
ofs.dedup();
let open = args.iter().any(|a| a == "--open");
- let reports: Vec<Value> = ofs.iter().filter_map(|of| compare(&all.iter().filter(|e| e.of == *of).collect::<Vec<_>>(), since.as_deref(), &keep, open)).collect();
+ let reports: Vec<Value> = ofs.iter().filter_map(|(of, kind)| compare(&all.iter().filter(|e| e.of == *of && e.kind == *kind).collect::<Vec<_>>(), since.as_deref(), &keep, open)).collect();
let count = finding::count(&standing(&reports));
if args.iter().any(|a| a == "--json") {
return Ok(serde_json::to_string_pretty(&json!({"project": project, "entries": all.len(), "reports": reports, "standing": count})).unwrap_or_default());
@@ -102,7 +113,7 @@ mod tests {
use raea_core_facts::Level;
fn entry(id: &str, fs: Vec<Finding>) -> Entry {
- Entry { id: id.into(), at: 0, by: "raea render".into(), of: "edit.tsx".into(), out: None, commit: None, findings: fs, despite: vec![] }
+ Entry { id: id.into(), at: 0, by: "raea render".into(), of: "edit.tsx".into(), out: None, kind: "video".into(), commit: None, findings: fs, despite: vec![] }
}
#[test]
@@ -123,4 +134,20 @@ mod tests {
let lamp = |f: &Finding| f.about.iter().any(|a| a.name == "lamp");
assert_eq!(compare(&refs, None, &lamp, false).unwrap()["carried"].as_array().map(Vec::len), Some(0));
}
+
+ #[test]
+ fn a_renamed_part_or_an_error_let_through_is_never_read_as_fixed() {
+ let crate_ = Finding::new("clips", Level::Error, "crate in pillar", "raea render").about("crate", None).about("pillar", None).frames(0, 30).measure("depth", 0.241, "m", None);
+ let mut boxed = crate_.clone();
+ boxed.about[0].name = "box".into();
+ boxed.says = "box in pillar".into();
+ let mut let_through = entry("b", vec![boxed]);
+ let_through.despite = vec![record::Despite { check: "clips".into(), why: "posed through it".into() }];
+ let es = [entry("a", vec![crate_]), let_through];
+ let r = compare(&es.iter().collect::<Vec<_>>(), None, &|_: &Finding| true, false).unwrap();
+ assert_eq!((r["fixed"].as_array().map(Vec::len), r["new"].as_array().map(Vec::len), r["renamed"][0]["was"][0].as_str()), (Some(0), Some(0), Some("crate")));
+ let text = lines(&r).join("\n");
+ assert!(text.contains(" renamed error clips frames 0-29 box, pillar") && text.contains(" despite clips: posed through it"), "{text}");
+ assert_eq!(finding::count(&standing(&[r])), "1 error, 0 warns, 0 notes");
+ }
}
diff --git a/apps/direction/src/rendered.rs b/apps/direction/src/rendered.rs
index 0c216cc0..b6956098 100644
--- a/apps/direction/src/rendered.rs
+++ b/apps/direction/src/rendered.rs
@@ -50,8 +50,9 @@ pub fn rendered(args: &[String]) -> i32 {
let _ = std::fs::write(&m, v.to_string());
}
}
- let file = args.get(1).filter(|a| !a.starts_with('-')).map(PathBuf::from);
- let out = raea_runtime_bundle::flag(args, "-o").map(PathBuf::from);
+ // a render that is part of another (a review's tiles, a quick check's stills) leaves the entry to that one
+ let file = args.get(1).filter(|a| !a.starts_with('-') && std::env::var("RAEA_RECORD").as_deref() != Ok("off")).map(PathBuf::from);
+ let out = raea_runtime_bundle::flag(args, "-o").or_else(|| raea_runtime_bundle::flag(args, "--review")).map(PathBuf::from);
if let Some(e) = file.and_then(|f| record::keep("raea render", &f, out.as_deref(), &found, excused, &raea_io_trace::utc(SystemTime::now()).1)) {
println!("raea render: kept in the project's record as {} (raea findings reads it)", e.id);
}
diff --git a/apps/solid/src/view.rs b/apps/solid/src/view.rs
index 50ff3e24..4d1e6f30 100644
--- a/apps/solid/src/view.rs
+++ b/apps/solid/src/view.rs
@@ -87,7 +87,8 @@ pub(crate) fn view(file: &Path, set: &Map<String, Value>, info: &Value, out: &Pa
let tsx = file.with_file_name(format!(".{}.view.tsx", file.file_stem().and_then(|s| s.to_str()).unwrap_or("solid")));
std::fs::write(&tsx, scene(file, set, lo, hi)).map_err(|e| format!("{}: {e}", tsx.display()))?;
let exe = std::env::current_exe().map_err(|e| e.to_string())?;
- let run = std::process::Command::new(exe).arg("render").arg(&tsx).arg("--review").arg(out).current_dir(tsx.parent().unwrap_or(Path::new("."))).output().map_err(|e| e.to_string())?;
+ // a scene made for this look and deleted after it: nothing for the project's record (DR3)
+ let run = std::process::Command::new(exe).arg("render").arg(&tsx).arg("--review").arg(out).current_dir(tsx.parent().unwrap_or(Path::new("."))).env("RAEA_RECORD", "off").output().map_err(|e| e.to_string())?;
let said = format!("{}{}", String::from_utf8_lossy(&run.stdout), String::from_utf8_lossy(&run.stderr));
if !run.status.success() || !out.join("colour.png").is_file() {
// the scene is left for a look: what failed is in it or in the file
diff --git a/apps/workspace/src/next.rs b/apps/workspace/src/next.rs
index 60a455d2..86253f7f 100644
--- a/apps/workspace/src/next.rs
+++ b/apps/workspace/src/next.rs
@@ -35,17 +35,23 @@ fn first_error(e: &Entry) -> Option<String> {
}
/// The step after a composition's latest render in the project's record (docs/direction.feature DR3): its errors,
-/// then its video's check (a `raea check` of what it wrote, kept after it) and what that found.
-fn after_render(c: &Path, record: &[Entry], i: usize) -> String {
+/// then its video (the newest render of it that wrote one: stills or a review since don't replace it, and one made
+/// before the composition's last change, at `changed` seconds, is stale), then the video's check (a `raea check` of
+/// it, kept after it) and what that found.
+fn after_render(c: &Path, record: &[Entry], i: usize, changed: u64) -> String {
let e = &record[i];
if let Some(err) = first_error(e) {
return format!("fix {}: {err} (its render {} found it; `raea findings {}` lists them all)", name(c), e.id, name(c));
}
- let Some(out) = e.out.as_deref().filter(|o| o.ends_with(".mp4")) else {
+ let video = record[..=i].iter().rposition(|k| k.by == "raea render" && k.of == e.of && k.out.as_deref().is_some_and(|o| o.ends_with(".mp4")));
+ let Some((v, out)) = video.and_then(|v| Some((v, record[v].out.as_deref()?))) else {
return format!("render the video: `raea render {} -o out/{}`", name(c), name(&c.with_extension("mp4")));
};
+ if record[v].at < changed {
+ return format!("render the video again: {} changed after {} made {out}", name(c), record[v].id);
+ }
let check = out.replace(".mp4", ".check.json");
- match record[i + 1..].iter().rev().find(|k| k.by == "raea check" && k.of == out) {
+ match record[v + 1..].iter().rev().find(|k| k.by == "raea check" && k.of == out) {
None => format!("check {out}: `raea check {out} -o {check}` (add --manifest when the render wrote one)"),
Some(k) => match first_error(k) {
Some(err) => format!("polish {out}: {err} (`raea guide polish`)"),
@@ -84,7 +90,7 @@ pub fn steps(dir: &Path, brief: &Brief, stale: usize) -> Vec<String> {
Some(c) => match kept.iter().rposition(|e| e.by == "raea render" && e.of == record::rel(&project, c)) {
None => out.push(format!("render {}: stills to look at first (`raea render {} --at 0,45,89 -o frames/`), then the video into out/", name(c), name(c))),
Some(i) if secs(c) > kept[i].at => out.push(format!("render again: {} changed after its render {}", name(c), kept[i].id)),
- Some(i) => out.push(after_render(c, &kept, i)),
+ Some(i) => out.push(after_render(c, &kept, i, secs(c))),
},
}
out.truncate(3);
diff --git a/apps/workspace/src/tests.rs b/apps/workspace/src/tests.rs
index 97c57464..ca1f0a05 100644
--- a/apps/workspace/src/tests.rs
+++ b/apps/workspace/src/tests.rs
@@ -61,8 +61,23 @@ fn next_walks_a_project_from_brief_to_show() {
assert_eq!(next::steps(&d, &shaped, 0)[0], "polish out/piece.mp4: clipped: text clipped at 2 s (`raea guide polish`)");
keep("raea check", &video, None, &[Finding::new("reading", Level::Note, "minor", "raea check")], vec![], "20261110-160003").unwrap();
assert!(next::steps(&d, &shaped, 0)[0].starts_with("show out/piece.mp4"));
- // stills alone: the video next
+ // stills (or a review) since the video don't replace it
keep("raea render", &piece, Some(&d.join("out")), &[], vec![], "20261110-160004").unwrap();
+ assert!(next::steps(&d, &shaped, 0)[0].starts_with("show out/piece.mp4"), "{:?}", next::steps(&d, &shaped, 0));
+ // the composition changed after the videos were made (their entries made old), before the stills: the video again
+ for id in ["20261110-160000-piece", "20261110-160001-piece"] {
+ let rec = d.join(format!(".raea/record/{id}.json"));
+ let mut v: serde_json::Value = serde_json::from_slice(&std::fs::read(&rec).unwrap()).unwrap();
+ v["at"] = 1.into();
+ std::fs::write(&rec, v.to_string()).unwrap();
+ }
+ let changed = std::time::UNIX_EPOCH + std::time::Duration::from_secs(100);
+ std::fs::File::options().write(true).open(&piece).unwrap().set_modified(changed).unwrap();
+ assert_eq!(next::steps(&d, &shaped, 0)[0], "render the video again: piece.tsx changed after 20261110-160001-piece made out/piece.mp4");
+ // no video at all: the video next
+ for id in ["20261110-160000-piece", "20261110-160001-piece"] {
+ std::fs::remove_file(d.join(format!(".raea/record/{id}.json"))).unwrap();
+ }
assert_eq!(next::steps(&d, &shaped, 0)[0], "render the video: `raea render piece.tsx -o out/piece.mp4`");
let _ = std::fs::remove_dir_all(&d);
}
diff --git a/core/facts/src/finding.rs b/core/facts/src/finding.rs
index ab1b8a30..7f2fd696 100644
--- a/core/facts/src/finding.rs
+++ b/core/facts/src/finding.rs
@@ -160,6 +160,21 @@ pub fn taken() -> Vec<Finding> {
std::mem::take(&mut *SAID.lock().unwrap_or_else(|e| e.into_inner()))
}
+/// The findings said so far, written to `to` (beside a video in the export cache, which is copied later instead of
+/// drawn and checked again): whether they were.
+pub fn keep_to(to: &std::path::Path) -> bool {
+ serde_json::to_vec(&*SAID.lock().unwrap_or_else(|e| e.into_inner())).is_ok_and(|b| std::fs::write(to, b).is_ok())
+}
+
+/// Findings kept by keep_to, said again as when they were found: printed, and counted at the end.
+pub fn replay(from: &std::path::Path) {
+ let fs: Vec<Finding> = std::fs::read(from).ok().and_then(|b| serde_json::from_slice(&b).ok()).unwrap_or_default();
+ for f in &fs {
+ eprintln!("raea: {}", f.line());
+ }
+ said(&fs);
+}
+
/// Findings worst first, each level in the order found.
pub fn ranked(mut fs: Vec<Finding>) -> Vec<Finding> {
fs.sort_by_key(|f| f.level);
diff --git a/core/facts/src/record.rs b/core/facts/src/record.rs
index a79fc145..b2f8a0f1 100644
--- a/core/facts/src/record.rs
+++ b/core/facts/src/record.rs
@@ -33,6 +33,9 @@ pub struct Entry {
/// what it wrote, relative to the project when it's in it
#[serde(default)]
pub out: Option<String>,
+ /// what it is set against others of: "video", "sound", "still", "frames", "review" or "check" (kind())
+ #[serde(default)]
+ pub kind: String,
/// the project's commit, "+" after it when the file it's of has changes not committed (None: no git repository)
#[serde(default)]
pub commit: Option<String>,
@@ -72,6 +75,22 @@ fn commit(project: &Path, of: &str) -> Option<String> {
Some(if changed { format!("{head}+") } else { head })
}
+/// What a run wrote, as what its entries are set against: a check, a review (a folder holding review.json), a video, a
+/// sound, a still or a folder of frames. A review's tiles against the video before it would read as fixed.
+pub fn kind(by: &str, out: Option<&Path>) -> String {
+ let ext = out.and_then(Path::extension).map(|x| x.to_string_lossy().to_lowercase()).unwrap_or_default();
+ let k = match ext.as_str() {
+ _ if by == "raea check" => "check",
+ _ if out.is_none() => "run",
+ _ if out.is_some_and(|o| o.join("review.json").is_file()) => "review",
+ "mp4" | "mov" | "webm" | "mkv" => "video",
+ "wav" => "sound",
+ "png" | "jpg" | "jpeg" => "still",
+ _ => "frames",
+ };
+ k.into()
+}
+
/// What `by` found of `file` (writing `out`) kept in its project's record, named by `stamp` (UTC, 20261110-161530)
/// and the file's name: the entry, or None outside a project.
pub fn keep(by: &str, file: &Path, out: Option<&Path>, findings: &[Finding], despite: Vec<Despite>, stamp: &str) -> Option<Entry> {
@@ -83,7 +102,7 @@ pub fn keep(by: &str, file: &Path, out: Option<&Path>, findings: &[Finding], des
let of = rel(&project, file);
let base = format!("{stamp}-{}", file.file_stem().map(|s| s.to_string_lossy().to_string()).unwrap_or_default());
let id = (1..100).map(|n| if n == 1 { base.clone() } else { format!("{base}-{n}") }).find(|id| !dir.join(format!("{id}.json")).exists())?;
- let entry = Entry { id: id.clone(), at, by: by.into(), commit: commit(&project, &of), of, out: out.map(|o| rel(&project, o)), findings: findings.to_vec(), despite };
+ let entry = Entry { id: id.clone(), at, by: by.into(), commit: commit(&project, &of), of, out: out.map(|o| rel(&project, o)), kind: kind(by, out), findings: findings.to_vec(), despite };
std::fs::write(dir.join(format!("{id}.json")), serde_json::to_vec_pretty(&entry).ok()?).ok()?;
// the oldest past KEEP go (the names sort by time)
let mut names: Vec<PathBuf> = std::fs::read_dir(&dir).into_iter().flatten().flatten().map(|e| e.path()).filter(|p| p.extension().is_some_and(|x| x == "json")).collect();
@@ -108,20 +127,29 @@ pub fn same(f: &Finding) -> String {
if about.is_empty() { format!("{} {}", f.check, f.says) } else { format!("{} {}", f.check, about.join(", ")) }
}
-/// Between two entries of one thing: what was fixed (found before, not now), what is new and what is carried.
+/// Between two entries of one thing: what was fixed (found before, not now), what is new, what is carried, and what
+/// was renamed (before, now): gone under one name and new under another with the same check, frames and measure.
pub struct Changes<'a> {
pub fixed: Vec<&'a Finding>,
pub new: Vec<&'a Finding>,
pub carried: Vec<&'a Finding>,
+ pub renamed: Vec<(&'a Finding, &'a Finding)>,
}
pub fn changes<'a>(before: &'a [Finding], now: &'a [Finding]) -> Changes<'a> {
let has = |fs: &[Finding], f: &Finding| fs.iter().any(|g| same(g) == same(f));
- Changes {
- fixed: before.iter().filter(|f| !has(now, f)).collect(),
- new: now.iter().filter(|f| !has(before, f)).collect(),
- carried: now.iter().filter(|f| has(before, f)).collect(),
- }
+ let mut fixed: Vec<&Finding> = before.iter().filter(|f| !has(now, f)).collect();
+ let mut renamed = Vec::new();
+ // a part renamed is no fix: the same finding, measured the same on the same frames, under a new name
+ let new = now.iter().filter(|f| !has(before, f)).filter(|n| match fixed.iter().position(|g| g.check == n.check && g.frames == n.frames && g.measure.is_some() && g.measure == n.measure) {
+ Some(at) => {
+ renamed.push((fixed.remove(at), *n));
+ false
+ }
+ None => true,
+ });
+ let new = new.collect();
+ Changes { fixed, new, carried: now.iter().filter(|f| has(before, f)).collect(), renamed }
}
#[cfg(test)]
@@ -142,6 +170,11 @@ mod tests {
// the same clip on other frames is the same finding
let b = keep("raea render", &root.join("edit.tsx"), None, &[clips.frames(12, 22)], vec![], "20261110-160000").unwrap();
assert_eq!((a.id.as_str(), b.id.as_str(), a.of.as_str(), a.out.as_deref()), ("20261110-160000-edit", "20261110-160000-edit-2", "edit.tsx", Some("out/edit.mp4")));
+ // what each run wrote is the kind it's set against: the video, frames, a review's folder, a check
+ std::fs::create_dir_all(root.join("review")).unwrap();
+ std::fs::write(root.join("review/review.json"), "{}").unwrap();
+ let k = |by: &str, o: &str| kind(by, Some(&root.join(o)));
+ assert_eq!((a.kind.as_str(), b.kind.as_str(), k("raea render", "review"), k("raea render", "frames/"), k("raea check", "out/edit.mp4")), ("video", "run", "review".into(), "frames".into(), "check".into()));
let all = read(&root);
assert_eq!(all.len(), 2);
let ch = changes(&all[0].findings, &all[1].findings);
@@ -149,6 +182,12 @@ mod tests {
assert_eq!(ch.fixed[0].check, "tilted");
// outside a project, nothing is kept
assert!(keep("raea render", &std::env::temp_dir().join("loose.tsx"), None, &[], vec![], "x").is_none());
+ // a video copied from the export cache says what was found when it was drawn (finding::keep_to, replay)
+ crate::finding::said(std::slice::from_ref(&tilt));
+ assert!(crate::finding::keep_to(&root.join("cached.findings")));
+ let _ = crate::finding::taken();
+ crate::finding::replay(&root.join("cached.findings"));
+ assert_eq!(crate::finding::taken(), vec![tilt]);
let _ = std::fs::remove_dir_all(&root);
}
}
diff --git a/core/review/src/lib.rs b/core/review/src/lib.rs
index e847bc02..92fe6d40 100644
--- a/core/review/src/lib.rs
+++ b/core/review/src/lib.rs
@@ -116,10 +116,18 @@ fn wanted() -> Option<&'static ([f64; 3], [f64; 3], Option<f64>)> {
/// A review's fixed camera in place of the scene's own: every frame's camera item is moved there, or one is added when
/// the scene has none. With RAEA_CAMERA unset, nothing changes.
pub fn camera_override(out: &mut Vec<Item>) {
- let Some((eye, at, fov)) = wanted() else { return };
+ if let Some((eye, at, fov)) = wanted() {
+ place_camera(out, *eye, *at, *fov);
+ }
+}
+
+/// The frame's camera put at `eye` looking at `at`. A Camera3d's Transform rotation goes: the engine places a camera
+/// by its rotation over its look-at point, so a review camera keeping the scene's would face the scene camera's way.
+fn place_camera(out: &mut Vec<Item>, eye: [f64; 3], at: [f64; 3], fov: Option<f64>) {
let set = |props: &mut Map<String, Value>| {
props.insert("position".into(), json!(eye));
props.insert("lookAt".into(), json!(at));
+ props.remove("rotation");
if let Some(f) = fov {
props.insert("fov".into(), json!(f));
}
@@ -162,4 +170,16 @@ mod tests {
}
assert!(ceiling(&boxes_of(&found), [0.0; 3], [1.0; 3]).is_none());
}
+
+ #[test]
+ fn a_review_camera_drops_the_scene_cameras_rotation_and_one_is_added_when_there_is_none() {
+ let props = json!({"position": [0, 2, 6], "lookAt": [0, 1, 0], "rotation": [0.0, 0.0, 0.0, 1.0]}).as_object().cloned().unwrap();
+ let mut its = vec![Item { kind: "camera", props: Arc::new(props), shape: None, material: None, world: Mat4::IDENTITY }];
+ place_camera(&mut its, [6.0, 1.7, 0.0], [0.5, 1.5, 0.0], Some(40.0));
+ let p = &its[0].props;
+ assert_eq!((p["position"].clone(), p["lookAt"].clone(), p["fov"].clone(), p.get("rotation")), (json!([6.0, 1.7, 0.0]), json!([0.5, 1.5, 0.0]), json!(40.0), None));
+ let mut none = Vec::new();
+ place_camera(&mut none, [0.0, 7.0, 0.0], [0.0; 3], None);
+ assert_eq!((none.len(), none[0].kind), (1, "camera"));
+ }
}
diff --git a/runtime/bundle/src/cache.rs b/runtime/bundle/src/cache.rs
index 348db2ba..9967ad90 100644
--- a/runtime/bundle/src/cache.rs
+++ b/runtime/bundle/src/cache.rs
@@ -218,6 +218,10 @@ pub fn prune_cache(dir: &Path, ext: &str, keep: usize) {
}
all.sort_by(|a, b| b.0.cmp(&a.0));
for (_, p) in all.into_iter().skip(keep) {
+ // with what an export keeps beside it: its message, manifest and findings
+ for side in ["said", "manifest", "findings"] {
+ let _ = std::fs::remove_file(p.with_extension(side));
+ }
let _ = std::fs::remove_file(p);
}
}
diff --git a/runtime/export/src/render.rs b/runtime/export/src/render.rs
index 808458df..1986af7e 100644
--- a/runtime/export/src/render.rs
+++ b/runtime/export/src/render.rs
@@ -89,8 +89,10 @@ pub fn render(args: &[String]) -> R<String> {
if let Some(c) = &cache {
// with --manifest, the manifest kept beside the export comes back too
let kept_manifest = manifest.as_ref().map(|m| (m, c.with_extension("manifest")));
- if let (Ok(said), true, true) = (std::fs::read_to_string(c.with_extension("said")), c.exists(), kept_manifest.as_ref().is_none_or(|(_, k)| k.exists())) {
+ // and what it found when it was drawn (one kept before findings were is drawn again, so its checks run)
+ if let (Ok(said), true, true, true) = (std::fs::read_to_string(c.with_extension("said")), c.exists(), kept_manifest.as_ref().is_none_or(|(_, k)| k.exists()), c.with_extension("findings").exists()) {
if std::fs::copy(c, &out).is_ok() && kept_manifest.as_ref().is_none_or(|(m, k)| std::fs::copy(k, m).is_ok()) {
+ raea_core_facts::finding::replay(&c.with_extension("findings"));
let _ = std::fs::File::options().append(true).open(c).and_then(|f| f.set_modified(std::time::SystemTime::now()));
let _ = std::fs::remove_file(&js);
return Ok(with_exposure(format!("{} (the same export as before: from the export cache)", said.replace("{OUT}", &out.display().to_string())), &out, manifest.as_deref()));
@@ -103,7 +105,7 @@ pub fn render(args: &[String]) -> R<String> {
if c.parent().is_some_and(|d| std::fs::create_dir_all(d).is_ok()) {
let tmp = c.with_extension(format!("{}.tmp", std::process::id()));
let manifest_kept = manifest.as_ref().is_none_or(|m| std::fs::copy(m, c.with_extension("manifest")).is_ok());
- if manifest_kept && std::fs::copy(&out, &tmp).is_ok() && std::fs::rename(&tmp, c).is_ok() && std::fs::write(c.with_extension("said"), s.replace(&out.display().to_string(), "{OUT}")).is_ok() {
+ if manifest_kept && std::fs::copy(&out, &tmp).is_ok() && std::fs::rename(&tmp, c).is_ok() && std::fs::write(c.with_extension("said"), s.replace(&out.display().to_string(), "{OUT}")).is_ok() && raea_core_facts::finding::keep_to(&c.with_extension("findings")) {
if let Some(d) = c.parent() {
prune_cache(d, "mp4", 16);
// this export is an output: later keys leave it out of the edit's folder
diff --git a/runtime/export/src/review.rs b/runtime/export/src/review.rs
index 66b75eda..99633b55 100644
--- a/runtime/export/src/review.rs
+++ b/runtime/export/src/review.rs
@@ -40,7 +40,8 @@ pub fn review(args: &[String], dir_out: &Path) -> R<String> {
let out = dir_out.join(format!("{view}-{mode}.png"));
let mut cmd = std::process::Command::new(&exe);
cmd.arg("render").arg(&tsx).args(&rest).args(["--frame", &frame.to_string(), "-o"]).arg(&out);
- cmd.env_remove("RAEA_CAMERA").env_remove("RAEA_CLAY");
+ // a tile is part of this render: the review keeps the one entry in the project's record (DR3)
+ cmd.env_remove("RAEA_CAMERA").env_remove("RAEA_CLAY").env("RAEA_RECORD", "off");
if let Some((e, t, f)) = cam {
cmd.env("RAEA_CAMERA", format!("{},{},{},{},{},{},{}", e[0], e[1], e[2], t[0], t[1], t[2], f));
}
@@ -55,9 +56,12 @@ pub fn review(args: &[String], dir_out: &Path) -> R<String> {
}
let colour = dir_out.join(format!("{view}-colour.png"));
let (_, ev) = raea_sys_light_meter::exposure::of_pngs(std::slice::from_ref(&colour))?;
- for f in ev["found"].as_array().into_iter().flatten() {
- said.push(json!({"check": "exposure", "level": f["level"], "says": format!("{view} tile: {}", f["says"].as_str().unwrap_or("").trim_start_matches("the frame: "))}));
- }
+ // what a tile's exposure found, counted with the render's findings (DR3)
+ let tile: Vec<raea_core_facts::Finding> = ev["found"].as_array().into_iter().flatten().filter_map(|f| {
+ raea_core_facts::Finding::of_value(&json!({"check": "exposure", "level": f["level"], "says": format!("{view} tile: {}", f["says"].as_str().unwrap_or("").trim_start_matches("the frame: "))}), "raea render")
+ }).collect();
+ raea_core_facts::finding::said(&tile);
+ said.extend(tile);
tiles.push(json!({"view": view, "colour": format!("{view}-colour.png"), "clay": format!("{view}-clay.png"), "exposure": ev["exposure"],
"camera": cam.map(|(e, t, f)| json!({"eye": e, "target": t, "fov": f}))}));
}
@@ -83,7 +87,7 @@ pub fn review(args: &[String], dir_out: &Path) -> R<String> {
std::fs::write(dir_out.join("review.json"), serde_json::to_string_pretty(&doc).unwrap_or_default()).map_err(|e| e.to_string())?;
let mut msg = format!("APPLIED review of frame {frame}: {} and {} (hero, front, right, top, iso, low), cameras and exposure in {}", dir_out.join("colour.png").display(), dir_out.join("clay.png").display(), dir_out.join("review.json").display());
for f in &said {
- msg.push_str(&format!("\n {}: {}", f["level"].as_str().unwrap_or(""), f["says"].as_str().unwrap_or("")));
+ msg.push_str(&format!("\n{}", f.line()));
}
Ok(msg)
}
diff --git a/systems/contact/src/found.rs b/systems/contact/src/found.rs
index 41ca82c1..8c09e4e6 100644
--- a/systems/contact/src/found.rs
+++ b/systems/contact/src/found.rs
@@ -37,8 +37,10 @@ pub fn clip_findings(found: &[Value], by: &str) -> Vec<Finding> {
.iter()
.map(|v| {
let at = |k: &str| v[k].as_i64().unwrap_or(0);
- // the check's "to" is the last frame it clips on; a finding's span ends one past it
- let mut f = Finding::new("clips", Level::Error, v["says"].as_str().unwrap_or_default(), by).frames(at("from"), at("to") + 1);
+ // the check's "to" is the last frame it clips on; a finding's span ends one past it. One no frame shows is a
+ // note: in the scene, not in the picture
+ let level = if v["seen"] == false { Level::Note } else { Level::Error };
+ let mut f = Finding::new("clips", level, v["says"].as_str().unwrap_or_default(), by).frames(at("from"), at("to") + 1);
for k in ["part", "into"] {
if let Some(name) = v[k].as_str() {
f = f.about(name, None);
@@ -81,5 +83,9 @@ mod tests {
let f = &clip_findings(&found, "raea render")[0];
// frames 40 to 52, the last included
assert_eq!(f.line(), "error clips frames 40-52 rider, seat: rider passes 40 mm into seat (fix: move it +0.050 m along y)");
+ // one no frame shows (the camera turned away) is still said, as a note about the same parts
+ let away = vec![json!({"from": 0, "to": 29, "part": "rider", "into": "seat", "seen": false, "says": "rider passes 40 mm into seat, where no frame shows it"})];
+ let n = &clip_findings(&away, "raea render")[0];
+ assert_eq!((n.level, raea_core_facts::record::same(n) == raea_core_facts::record::same(f)), (Level::Note, true));
}
}
diff --git a/systems/contact/src/lib.rs b/systems/contact/src/lib.rs
index 2955d584..9ecc554f 100644
--- a/systems/contact/src/lib.rs
+++ b/systems/contact/src/lib.rs
@@ -277,6 +277,8 @@ pub fn check(all: &[Vec<Item>], frames: &[i64], w: u32, h: u32, fps: f64) -> Vec
// neither part moves (the camera may still have)
let mut last: HashMap<(usize, usize), (Mat4, Mat4, Option<Hit>)> = HashMap::new();
let mut found: HashMap<(usize, usize), Vec<(usize, Hit)>> = HashMap::new();
+ // overlaps no frame shows (off frame, behind something): first and last frame, and the first frame's hit
+ let mut hidden: HashMap<(usize, usize), (usize, usize, Hit)> = HashMap::new();
for k in 0..frames.len() {
let mut boxes: Vec<(usize, Vec3, Vec3)> = Vec::new();
for (i, (_, tr)) in parts.iter().enumerate() {
@@ -329,11 +331,16 @@ pub fn check(all: &[Vec<Item>], frames: &[i64], w: u32, h: u32, fps: f64) -> Vec
let skip = 3.0 * (sa.cell * scale_of(&wa)).max(sb.cell * scale_of(&wb));
if shows(&all[k], &hit.seam, occ.get_or_insert_with(|| occluders(k)), skip, w as f32, h as f32) {
found.entry((i, j)).or_default().push((k, hit));
+ } else {
+ hidden.entry((i, j)).or_insert((k, k, hit)).1 = k;
}
}
}
}
}
+ // unseen on every frame: still said, so a clip turned away from reads as hidden, not fixed (DR3, DR9's cheats)
+ let mut unseen: Vec<_> = hidden.into_iter().filter(|(p, _)| !found.contains_key(p)).collect();
+ unseen.sort_by_key(|(p, (k, _, _))| (*k, *p));
let mut spans: Vec<((usize, usize), Vec<(usize, Hit)>)> = found.into_iter().collect();
spans.sort_by_key(|(p, g)| (g[0].0, *p));
let clock = |f: i64| {
@@ -341,6 +348,22 @@ pub fn check(all: &[Vec<Item>], frames: &[i64], w: u32, h: u32, fps: f64) -> Vec
format!("{}:{:04.1}", (s / 60.0) as i64, s % 60.0)
};
let mut out = Vec::new();
+ // one overlap said, over frames f0 to f1 (`seen`: its seam on screen, else said as standing in the scene unseen)
+ let mut say = |i: usize, j: usize, k: usize, hit: &Hit, f0: i64, f1: i64, seen: bool| {
+ let (pa, pb, sa, sb) = (parts[i].1[k].as_ref().unwrap(), parts[j].1[k].as_ref().unwrap(), solids[i].as_ref().unwrap(), solids[j].as_ref().unwrap());
+ let (la, lb) = (label(pa, &sa[hit.pieces.0].name), label(pb, &sb[hit.pieces.1].name));
+ let (small, big) = if hit.small_first { (la, lb) } else { (lb, la) };
+ // out the shortest way: the smallest move along a world axis (not down) that leaves no piece in the other's
+ let (axis, step) = clear_move(&sa[..], &placed[i][k].world, &sb[..], &placed[j][k].world, hit.small_first);
+ let axis_name = ["x", "y", "z"][axis];
+ let when = if f0 == f1 { clock(f0) } else { format!("{}–{}", clock(f0), clock(f1)) };
+ let shows = if seen { "and the seam shows" } else { "where no frame shows it (off frame or behind something), so it stands in the scene unseen" };
+ let says = format!(
+ "{when} {small} passes {:.2} m into {big} ({:.0}% of it inside), {shows}: move {small} {step:+.2} along world {axis_name} (or move {big}), or give it allowOverlap if it's meant to",
+ hit.depth, hit.share * 100.0
+ );
+ out.push(json!({"from": f0, "to": f1, "part": small, "into": big, "depth": (hit.depth * 1000.0).round() / 1000.0, "share": (hit.share * 1000.0).round() / 1000.0, "move": {"axis": axis_name, "by": (step * 1000.0).round() / 1000.0}, "seen": seen, "says": says}));
+ };
for ((i, j), got) in spans {
// a stretch is rendered frames in a row
let mut runs: Vec<Vec<&(usize, Hit)>> = Vec::new();
@@ -352,25 +375,12 @@ pub fn check(all: &[Vec<Item>], frames: &[i64], w: u32, h: u32, fps: f64) -> Vec
}
for run in runs {
let &&(k, ref hit) = run.iter().max_by(|x, y| x.1.depth.total_cmp(&y.1.depth)).unwrap();
- let (pa, pb) = (parts[i].1[k].as_ref().unwrap(), parts[j].1[k].as_ref().unwrap());
- let (sa, sb) = (solids[i].as_ref().unwrap(), solids[j].as_ref().unwrap());
- let (la, lb) = (label(pa, &sa[hit.pieces.0].name), label(pb, &sb[hit.pieces.1].name));
- let (small, big) = if hit.small_first { (la, lb) } else { (lb, la) };
- // out the shortest way: the smallest move along a world axis (not down) after which no piece of the one
- // passes into any piece of the other
- let (wa, wb) = (placed[i][k].world, placed[j][k].world);
- let small_is_a = hit.small_first;
- let (axis, step) = clear_move(&sa[..], &wa, &sb[..], &wb, small_is_a);
- let axis_name = ["x", "y", "z"][axis];
- let (f0, f1) = (frames[run.first().unwrap().0], frames[run.last().unwrap().0]);
- let when = if f0 == f1 { clock(f0) } else { format!("{}–{}", clock(f0), clock(f1)) };
- let says = format!(
- "{when} {small} passes {:.2} m into {big} ({:.0}% of it inside), and the seam shows: move {small} {step:+.2} along world {axis_name} (or move {big}), or give it allowOverlap if it's meant to",
- hit.depth, hit.share * 100.0
- );
- out.push(json!({"from": f0, "to": f1, "part": small, "into": big, "depth": (hit.depth * 1000.0).round() / 1000.0, "share": (hit.share * 1000.0).round() / 1000.0, "move": {"axis": axis_name, "by": (step * 1000.0).round() / 1000.0}, "says": says}));
+ say(i, j, k, hit, frames[run.first().unwrap().0], frames[run.last().unwrap().0], true);
}
}
+ for ((i, j), (k0, k1, hit)) in unseen {
+ say(i, j, k0, &hit, frames[k0], frames[k1], false);
+ }
out
}