diff --git a/crates/bevy_asset/src/handle.rs b/crates/bevy_asset/src/handle.rs index c51bc60f159e07..e3170b660a095e 100644 --- a/crates/bevy_asset/src/handle.rs +++ b/crates/bevy_asset/src/handle.rs @@ -1,4 +1,5 @@ use std::{ + cmp::Ordering, fmt::Debug, hash::{Hash, Hasher}, }; @@ -13,7 +14,9 @@ pub(crate) const DEFAULT_HANDLE_ID: HandleId = HandleId(Uuid::from_u128(240940089166493627844978703213080810552)); /// A unique id that corresponds to a specific asset in the [Assets](crate::Assets) collection. -#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Serialize, Deserialize, Property)] +#[derive( + Debug, Clone, Copy, Eq, PartialOrd, Ord, PartialEq, Hash, Serialize, Deserialize, Property, +)] pub struct HandleId(pub Uuid); impl HandleId { @@ -133,6 +136,18 @@ impl PartialEq for Handle { impl Eq for Handle {} +impl PartialOrd for Handle { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.id.cmp(&other.id)) + } +} + +impl Ord for Handle { + fn cmp(&self, other: &Self) -> Ordering { + self.id.cmp(&other.id) + } +} + impl Debug for Handle { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> { let name = std::any::type_name::().split("::").last().unwrap(); diff --git a/crates/bevy_sprite/Cargo.toml b/crates/bevy_sprite/Cargo.toml index ea63713746a3bc..d6480c71e1800c 100644 --- a/crates/bevy_sprite/Cargo.toml +++ b/crates/bevy_sprite/Cargo.toml @@ -25,6 +25,6 @@ bevy_type_registry = { path = "../bevy_type_registry", version = "0.2.1" } bevy_utils = { path = "../bevy_utils", version = "0.2.1" } # other -rectangle-pack = "0.1" +rectangle-pack = "0.2" thiserror = "1.0" guillotiere = "0.6.0" diff --git a/crates/bevy_sprite/src/texture_atlas_builder.rs b/crates/bevy_sprite/src/texture_atlas_builder.rs index e8ee29ae55c2a6..d7a3c6b0c6d023 100644 --- a/crates/bevy_sprite/src/texture_atlas_builder.rs +++ b/crates/bevy_sprite/src/texture_atlas_builder.rs @@ -89,7 +89,7 @@ impl TextureAtlasBuilder { rect_placements = None; break; } - let mut target_bins = std::collections::HashMap::new(); + let mut target_bins = std::collections::BTreeMap::new(); target_bins.insert(0, TargetBin::new(current_width, current_height, 1)); atlas_texture = Texture::new_fill( Vec2::new(current_width as f32, current_height as f32),