From e47769b81e091f1b90eedee59cc8895a6f972b4f Mon Sep 17 00:00:00 2001 From: "Tormod G. Hellen" Date: Mon, 18 Sep 2023 22:24:24 +0200 Subject: [PATCH] Improve logical_viewport_size. Addresses https://github.com/bevyengine/bevy/pull/9770#discussion_r1329126220 --- crates/bevy_render/src/camera/camera.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/crates/bevy_render/src/camera/camera.rs b/crates/bevy_render/src/camera/camera.rs index 686a3ba4932ad5..5169a00fc4fefb 100644 --- a/crates/bevy_render/src/camera/camera.rs +++ b/crates/bevy_render/src/camera/camera.rs @@ -180,19 +180,15 @@ impl Camera { #[inline] pub fn logical_viewport_size(&self) -> Result { let viewport = self.viewport.as_ref(); - let logical_viewport_size = viewport.and_then(|v| self.to_logical(v.physical_size)); - if let Some(size) = logical_viewport_size { + if let Some(size) = viewport.and_then(|v| self.to_logical(v.physical_size)) { + Ok(size) + } else if let Some(size) = self.logical_target_size() { Ok(size) } else { - let logical_target_size = self.logical_target_size(); - if let Some(size) = logical_target_size { - Ok(size) - } else { - Err(LogicalViewportSizeError { - viewport_is_set: viewport.is_some(), - target_info_is_set: self.computed.target_info.is_some(), - }) - } + Err(LogicalViewportSizeError { + viewport_is_set: viewport.is_some(), + target_info_is_set: self.computed.target_info.is_some(), + }) } }