From e0d85820e3bb16918f988780f34c41773c63d843 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Sun, 15 Mar 2015 23:21:07 +0300 Subject: [PATCH] Fixed the frustum/bound relation. --- src/frustum.rs | 13 +++++-------- src/lib.rs | 1 - 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/frustum.rs b/src/frustum.rs index 2dc6c1d..e9e4468 100644 --- a/src/frustum.rs +++ b/src/frustum.rs @@ -71,15 +71,12 @@ Frustum { pub fn contains>(&self, bound: &B) -> Relation { [&self.left, &self.right, &self.top, &self.bottom, &self.near, &self.far] .iter().fold(Relation::In, |cur, p| { + use std::cmp::max; let r = bound.relate_plane(p); - // if we see Cross, then the result is Cross - // if we see In, then we keep the old result - // otherwise, take the current result - if cur == Relation::Cross || r == Relation::In { - cur - }else { - r - } + // If any of the planes are `Out`, the bound is outside. + // Otherwise, if any are `Cross`, the bound is crossing. + // Otherwise, the bound is fully inside. + max(cur, r) }) } } diff --git a/src/lib.rs b/src/lib.rs index c0c7df8..f1eb8ef 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,7 +16,6 @@ #![crate_type = "rlib"] #![crate_type = "dylib"] #![feature(old_impl_check, plugin, core, std_misc, custom_derive)] -#![plugin(rand_macros)] //! Computer graphics-centric math. //!