Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide better debug_asserts for ray intersections #5504

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions crates/emath/src/rect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,11 @@ impl Rect {
///
/// A ray that starts inside the rect will return `true`.
pub fn intersects_ray(&self, o: Pos2, d: Vec2) -> bool {
debug_assert!(d.is_normalized(), "expected normalized direction");
debug_assert!(
d.is_normalized(),
"expected normalized direction, but `d` has length {}",
d.length()
);

let mut tmin = -f32::INFINITY;
let mut tmax = f32::INFINITY;
Expand Down Expand Up @@ -677,7 +681,11 @@ impl Rect {
///
/// `d` is the direction of the ray and assumed to be normalized.
pub fn intersects_ray_from_center(&self, d: Vec2) -> Pos2 {
debug_assert!(d.is_normalized(), "expected normalized direction");
debug_assert!(
d.is_normalized(),
"expected normalized direction, but `d` has length {}",
d.length()
);

let mut tmin = f32::NEG_INFINITY;
let mut tmax = f32::INFINITY;
Expand Down
Loading