From a9666062eca5ff79cec5da0f530b2e0e4ce7c231 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Fri, 27 Jan 2023 22:41:33 +0100 Subject: [PATCH] refactor part of the cube frustum culling code --- src/camera/frustum.rs | 43 +++++++------------------------------------ 1 file changed, 7 insertions(+), 36 deletions(-) diff --git a/src/camera/frustum.rs b/src/camera/frustum.rs index af0d483..8143215 100644 --- a/src/camera/frustum.rs +++ b/src/camera/frustum.rs @@ -96,42 +96,13 @@ impl Frustum { } // check frustum outside/inside box - let mut out: u8 = 0; - for point in self.points { - out += (point.x > maxp.x) as u8; - } - if out == 8 { return false } - - let mut out: u8 = 0; - for point in self.points { - out += (point.x < minp.x) as u8; - } - if out == 8 { return false } - - let mut out: u8 = 0; - for point in self.points { - out += (point.y > maxp.y) as u8; - } - if out == 8 { return false } - - let mut out: u8 = 0; - for point in self.points { - out += (point.y < minp.y) as u8; - } - if out == 8 { return false } - - let mut out: u8 = 0; - for point in self.points { - out += (point.z > maxp.z) as u8; - } - if out == 8 { return false } - - let mut out: u8 = 0; - for point in self.points { - out += (point.z < minp.z) as u8; - } - if out == 8 { return false } - + if self.points.iter().all(|point| point.x > maxp.x) { return false } + if self.points.iter().all(|point| point.x < minp.x) { return false } + if self.points.iter().all(|point| point.y > maxp.y) { return false } + if self.points.iter().all(|point| point.y < minp.y) { return false } + if self.points.iter().all(|point| point.z > maxp.z) { return false } + if self.points.iter().all(|point| point.z < minp.z) { return false } + true } }