Provide better `debug_assert`s for ray intersections (#5504)
<!-- Please read the "Making a PR" section of [`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md) before opening a Pull Request! * Keep your PR:s small and focused. * The PR title is what ends up in the changelog, so make it descriptive! * If applicable, add a screenshot or gif. * If it is a non-trivial addition, consider adding a demo for it to `egui_demo_lib`, or a new example. * Do NOT open PR:s from your `master` branch, as that makes it hard for maintainers to test and add commits to your PR. * Remember to run `cargo fmt` and `cargo clippy`. * Open the PR as a draft until you have self-reviewed it and run `./scripts/check.sh`. * When you have addressed a PR comment, mark it as resolved. Please be patient! I will review your PR, but my time is limited! --> Title. This would have helped me debug bugs quicker. * [x] I have followed the instructions in the PR template
This commit is contained in:
parent
27a5803dd3
commit
7f711668b4
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue