From 88ca052ac86862f1d93fc6e6d7d53a331ae925e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Mon, 8 Aug 2022 21:58:20 +0000 Subject: [PATCH] don't render completely transparent UI nodes (#5537) # Objective - I often have UI nodes that are completely transparent and just for organisation - Don't render them - I doesn't bring a lot of improvements, but it doesn't add a lot of complexity either --- crates/bevy_render/src/color/mod.rs | 1 + crates/bevy_ui/src/render/mod.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/crates/bevy_render/src/color/mod.rs b/crates/bevy_render/src/color/mod.rs index a00481ffbb794..51c3a21a7cdc9 100644 --- a/crates/bevy_render/src/color/mod.rs +++ b/crates/bevy_render/src/color/mod.rs @@ -379,6 +379,7 @@ impl Color { } /// Get alpha. + #[inline(always)] pub fn a(&self) -> f32 { match self { Color::Rgba { alpha, .. } diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index 036aa51997e17..0a5a171ffccaa 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -197,6 +197,10 @@ pub fn extract_uinodes( if !images.contains(&image) { continue; } + // Skip completely transparent nodes + if color.0.a() == 0.0 { + continue; + } extracted_uinodes.uinodes.push(ExtractedUiNode { transform: transform.compute_matrix(), color: color.0,