Replays in full HD with shader effects driven by the recording (#56), recorded clock survives gaps (#57), cinematic intercepts: layered sound with travel delay, big flash, light burst, exposure punch, shock ring (#51) (fork patch 31)
build / mod (push) Successful in 3m21s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 03:59:47 +03:00
parent 4bab572293
commit 8a12225ba1
40 changed files with 1185 additions and 105 deletions
+75
View File
@@ -534,6 +534,81 @@ fn recordings_keep_the_time_of_day() {
}
}
// #57: a clock missing at the start, in the middle, or later recovering never loses or shifts the samples.
#[test]
fn recorded_clock_survives_gaps() {
let mut sim = Sim::new(1);
sim.add_drone(DroneKind::Geran3, DVec3::new(0.0, 80.0, 0.0), DVec3::Z, DVec3::new(0.0, 70.0, 500.0));
let mut g = Ground::default();
let mut out = Out::default();
for i in 0..100u64 {
// Unknown at the start (ticks 0-19) and for a stretch in the middle (50-69).
sim.day_time = if i < 20 || (50..70).contains(&i) { None } else { Some(1000 + i) };
sim.step(&mut g, None, &mut out);
}
let r = sim.rec.as_ref().unwrap();
assert_eq!(r.day_time(5.0), None, "before the first sample: unknown, not the current time");
let v = r.day_time(30.0).expect("recovered after a missing start");
assert!((1020..1040).contains(&v), "{v}");
// Inside the gap the last known time holds; nothing is invented.
let held = r.day_time(60.0).unwrap();
assert!((1030..1050).contains(&held), "{held}");
// After the gap the new samples land at their own ticks (seek forward and back alike).
let after = r.day_time(85.0).unwrap();
assert!((1080..1100).contains(&after), "{after}");
assert!(r.day_time(30.0).unwrap() < r.day_time(85.0).unwrap());
assert!(r.day_time(85.0).unwrap() > r.day_time(60.0).unwrap());
assert!(r.day_time(25.0).unwrap() <= r.day_time(35.0).unwrap());
}
// #56: a replay's fires and blasts are pure functions of its time: they end with their life,
// merge as the live ones do, and a seek back shows the same frame.
#[test]
fn replay_fires_and_blasts_follow_the_recording() {
use record::{Event, EventKind};
let mut sim = Sim::new(1);
sim.day_time = Some(1000);
sim.add_drone(DroneKind::Geran3, DVec3::new(0.0, 80.0, 0.0), DVec3::Z, DVec3::new(0.0, 70.0, 500.0));
let mut g = Ground::default();
let mut out = Out::default();
sim.step(&mut g, None, &mut out);
let mut rec = sim.rec.take().unwrap();
let at = DVec3::new(5.0, 70.0, 5.0);
let crash = |power| EventKind::Crash { drone: 1, kind: DroneKind::Geran3, power };
let life = fires::life_for(1);
rec.events = vec![
Event { at: 10, pos: at, kind: crash(1) },
// The same spot while it burns: one fire, burning longer.
Event { at: 500, pos: at + DVec3::X, kind: crash(3) },
// The same spot long after it died: a new fire.
Event { at: 500 + 4000 + fires::life_for(3), pos: at, kind: crash(1) },
];
assert!(record::replay_fires(&rec, 0.0).is_empty(), "before the first event");
let f = record::replay_fires(&rec, 600.0);
assert_eq!(f.len(), 1);
assert_eq!(f[0].start, 10);
assert!(f[0].life >= 490 + fires::life_for(3) && f[0].size >= fires::size_for(3), "fed: {:?}", f[0]);
// Past its life it is gone: no flames, no smoke.
let end = f[0].start + f[0].life;
assert!(record::replay_fires(&rec, end as f64 - 1.0).len() == 1);
assert!(record::replay_fires(&rec, end as f64 + 1.0).is_empty());
assert_eq!(fires::replay_fire(1, life as f64 + 10.0), (0.0, 0.0));
assert_eq!(fires::replay_fire(1, 1.0e5), (0.0, 0.0));
assert!(fires::replay_fire(1, 100.0).1 > 0.0);
// The later event lights a new one.
let f = record::replay_fires(&rec, (500 + 4000 + fires::life_for(3) + 5) as f64);
assert_eq!(f.len(), 1);
assert_eq!(f[0].start, 500 + 4000 + fires::life_for(3));
// Seeking back and forth gives the same blasts.
let a = record::replay_blasts(&rec, 20.0);
let _ = record::replay_blasts(&rec, 510.0);
let b = record::replay_blasts(&rec, 20.0);
assert_eq!(a.len(), 1);
assert_eq!((a[0].id, a[0].start, a[0].life), (b[0].id, b[0].start, b[0].life));
assert!(record::replay_blasts(&rec, 5.0).is_empty());
assert!(record::replay_blasts(&rec, 10.0 + a[0].life as f64).is_empty(), "burnt out");
}
fn sim_first(r: &record::Recording) -> u64 {
r.tracks.first().map_or(0, |t| t.first as u64)
}