mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-13 23:17:30 +00:00
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QiAJeFttZp83Fh7YuzAR5f
This commit is contained in:
2 files changed
+6
-3
No files matched your search
@@ -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]
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user