Prevent ImageBundles from causing constant layout recalculations (#1299)

Prevent ImageBundles from causing constant layout recalculations
This commit is contained in:
davier 2021-01-25 05:00:20 +00:00 committed by GitHub
parent 32acbfb632
commit 5edf2d2395
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}
}
}
}