Skip to content

Commit

Permalink
Don't panic on NaN when sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk authored and asny committed May 21, 2022
1 parent 7ac4f3e commit bf65c3e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ pub fn cmp_render_order(
if obj0.is_transparent() == obj1.is_transparent() {
let distance_a = camera.position().distance2(obj0.aabb().center());
let distance_b = camera.position().distance2(obj1.aabb().center());
if obj0.is_transparent() {
if distance_a.is_nan() || distance_b.is_nan() {
distance_a.is_nan().cmp(&distance_b.is_nan()) // whatever - just save us from panicing on unwrap below
} else if obj0.is_transparent() {
distance_b.partial_cmp(&distance_a).unwrap()
} else {
distance_a.partial_cmp(&distance_b).unwrap()
Expand Down

0 comments on commit bf65c3e

Please sign in to comment.