Skip to content

Commit

Permalink
upgrade rectangle pack (bevyengine#673)
Browse files Browse the repository at this point in the history
  • Loading branch information
cart authored and joshuajbouw committed Oct 24, 2020
1 parent eac9466 commit 08b6d78
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
17 changes: 16 additions & 1 deletion crates/bevy_asset/src/handle.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{
cmp::Ordering,
fmt::Debug,
hash::{Hash, Hasher},
};
Expand All @@ -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 {
Expand Down Expand Up @@ -133,6 +136,18 @@ impl<T> PartialEq for Handle<T> {

impl<T> Eq for Handle<T> {}

impl<T> PartialOrd for Handle<T> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.id.cmp(&other.id))
}
}

impl<T> Ord for Handle<T> {
fn cmp(&self, other: &Self) -> Ordering {
self.id.cmp(&other.id)
}
}

impl<T> Debug for Handle<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
let name = std::any::type_name::<T>().split("::").last().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_sprite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion crates/bevy_sprite/src/texture_atlas_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 08b6d78

Please sign in to comment.