Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

Tests: the near-plane check tests for the flip, and loopOut compares within float tolerance (#572, #456 follow-up)

Claude9495810ff503
diff --git a/crates/expr/src/tests.rs b/crates/expr/src/tests.rs
index 3d5acb2dd..133d32b53 100644
--- a/crates/expr/src/tests.rs
+++ b/crates/expr/src/tests.rs
@@ -588,7 +588,8 @@ fn loop_on_two_dimensional_position() {
let mut f = fx();
f.layer_mut(f.a).props.prop_mut(POS).unwrap().keys =
vec![Keyframe::new(secs(0.0), Value::Vec3([0.0, 0.0, 0.0])), Keyframe::new(secs(1.0), Value::Vec3([100.0, 50.0, 0.0]))];
- assert_eq!(f.pos("loopOut('offset')", 1.5), [150.0, 75.0, 0.0]);
+ let p = f.pos("loopOut('offset')", 1.5);
+ assert!(p.iter().zip([150.0, 75.0, 0.0]).all(|(a, b)| (a - b).abs() < 1e-9), "{p:?}");
}
#[test]
diff --git a/crates/ui-egui/src/panels/viewer.rs b/crates/ui-egui/src/panels/viewer.rs
index 2c5d47f34..a532cdebb 100644
--- a/crates/ui-egui/src/panels/viewer.rs
+++ b/crates/ui-egui/src/panels/viewer.rs
@@ -2358,8 +2358,10 @@ mod tests {
assert_eq!(front.len(), 4);
let crossing = project_clipped(&m, &box_corners([-50.0, -150.0, 50.0, 50.0]));
assert_eq!(crossing.len(), 4, "{crossing:?}");
- // Every point is in front: none flipped to the other side (y < 0 here means behind).
- assert!(crossing.iter().all(|p| p[0].is_finite() && p[1].abs() < 1e4 && p[0].abs() < 1e4), "{crossing:?}");
+ // Nothing flipped through infinity: a corner behind the camera (y = −150, w = −50) would
+ // land at y = +300 if it were projected as is; clipped at the near plane it runs off far
+ // above (negative y) instead, and the front corners stay where they were.
+ assert!(crossing.iter().all(|p| p[0].is_finite() && p[1].is_finite() && p[1] < 34.0), "{crossing:?}");
assert!(project_clipped(&m, &box_corners([-50.0, -400.0, 50.0, -200.0])).is_empty(), "wholly behind");
}