bevy/crates/bevy_sprite/src
JoshValjosh 8d78c37ce9
Use FloatOrd for sprite Z comparison and ignore sprites with NaN (#15267)
# Objective

Fixes #15258

## Solution

If my understanding is correct, sprites with NaN anywhere in their
transform won't even get onto the screen, so should not generate pick
events. This PR filters sprites with NaN in their transforms before
sorting by depth, then uses `FloatOrd` to simplify the comparison. Since
we're guaranteed to not have NaN values, it's technically unnecessary,
and we could instead sort with `a.partial_cmp(&b).unwrap()`, or even
`unwrap_unchecked()`.

## Testing

I ran the picking example to ensure Z sorting was working as intended.
2024-09-17 23:27:53 +00:00
..
mesh2d Reflect derived traits on all components and resources: bevy_sprite (#15227) 2024-09-15 17:10:53 +00:00
render Add 2d opaque phase with depth buffer (#13069) 2024-08-07 00:22:09 +00:00
texture_slice fix asymmetrical 9-slicing (#14148) 2024-08-01 20:03:23 +00:00
bundle.rs Remove deprecated SpriteSheetBundle and AtlasImageBundle (#15062) 2024-09-09 15:36:09 +00:00
dynamic_texture_atlas_builder.rs Uncouple DynamicTextureAtlasBuilder from assets (#13717) 2024-06-08 12:38:03 +00:00
lib.rs Reflect derived traits on all components and resources: bevy_sprite (#15227) 2024-09-15 17:10:53 +00:00
picking_backend.rs Use FloatOrd for sprite Z comparison and ignore sprites with NaN (#15267) 2024-09-17 23:27:53 +00:00
sprite.rs Reflect derived traits on all components and resources: bevy_sprite (#15227) 2024-09-15 17:10:53 +00:00
texture_atlas_builder.rs More idiomatic texture atlas builder (#13238) 2024-06-03 12:43:50 +00:00
texture_atlas.rs Reflect derived traits on all components and resources: bevy_sprite (#15227) 2024-09-15 17:10:53 +00:00