From 9495810ff50352f27a70d0a2cf0f96f95ac93d00 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 10 Oct 2026 21:48:52 +0000 Subject: [PATCH] Tests: the near-plane check tests for the flip, and loopOut compares within float tolerance (#572, #456 follow-up) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01QiAJeFttZp83Fh7YuzAR5f --- crates/expr/src/tests.rs | 3 ++- crates/ui-egui/src/panels/viewer.rs | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/expr/src/tests.rs b/crates/expr/src/tests.rs index 3d5acb2d..133d32b5 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 2c5d47f3..a532cdeb 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"); }