Skip to content

Commit

Permalink
Prevent ImageBundles from causing constant layout recalculations (bev…
Browse files Browse the repository at this point in the history
…yengine#1299)

Prevent ImageBundles from causing constant layout recalculations
  • Loading branch information
Davier authored and rparrett committed Jan 27, 2021
1 parent f223a47 commit d58a969
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/bevy_ui/src/widget/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ pub fn image_node_system(
.and_then(|material| material.texture.as_ref())
.and_then(|texture_handle| textures.get(texture_handle))
{
calculated_size.size = Size {
let size = Size {
width: texture.size.width as f32,
height: texture.size.height as f32,
};
// Update only if size has changed to avoid needless layout calculations
if size != calculated_size.size {
calculated_size.size = size;
}
}
}
}

0 comments on commit d58a969

Please sign in to comment.