From 8062de7e21cc258ddb890c1788f387919b1744ec Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Wed, 13 Jun 2018 14:55:41 +0200 Subject: [PATCH] Added frustum function, back to rc --- src/camera.rs | 5 +++++ src/scene.rs | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/camera.rs b/src/camera.rs index 44c79f7..e620354 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -131,6 +131,11 @@ impl Camera { aspect_ratio: 16.0 / 9.0 } } + + /// Returns the frustum of the camera. + pub fn frustum(&self) -> Frustum { + RenderCamera::frustum(self) + } } impl RenderCamera for Camera { diff --git a/src/scene.rs b/src/scene.rs index 2972ffe..abd1d65 100644 --- a/src/scene.rs +++ b/src/scene.rs @@ -2,13 +2,13 @@ use std::slice::{Iter, IterMut}; use std::vec::IntoIter; -use std::sync::Arc; +use std::rc::Rc; use std::cell::RefCell; use model::Model; /// Represents a 3D scene with models. pub struct Scene { - models: Vec>>, + models: Vec>>, } impl Scene { @@ -20,29 +20,29 @@ impl Scene { } /// Adds a model to the scene. - pub fn push(&mut self, model: Arc>) { + pub fn push(&mut self, model: Rc>) { self.models.push(model); } - /// Converts the model to a Arc> and adds it to the scene. + /// Converts the model to a Rc> and adds it to the scene. pub fn emplace(&mut self, model: Model) { - self.models.push(Arc::new(RefCell::new(model))); + self.models.push(Rc::new(RefCell::new(model))); } /// Returns an iterator to the models of the scene. - pub fn iter(&self) -> Iter>> { + pub fn iter(&self) -> Iter>> { self.models.iter() } /// Returns a mutable iterator to the model of the scene. - pub fn iter_mut(&mut self) -> IterMut>> { + pub fn iter_mut(&mut self) -> IterMut>> { self.models.iter_mut() } } impl IntoIterator for Scene { - type IntoIter = IntoIter>>; - type Item = Arc>; + type IntoIter = IntoIter>>; + type Item = Rc>; fn into_iter(self) -> Self::IntoIter { self.models.into_iter() @@ -52,7 +52,7 @@ impl IntoIterator for Scene { impl From> for Scene { fn from(input: Vec) -> Scene { Scene { - models: input.into_iter().map(|x| Arc::new(RefCell::new(x))).collect(), + models: input.into_iter().map(|x| Rc::new(RefCell::new(x))).collect(), } } }