Added frustum function, back to rc

This commit is contained in:
Thomas Forgione 2018-06-13 14:55:41 +02:00
parent 4544acad88
commit 8062de7e21
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
2 changed files with 15 additions and 10 deletions

View File

@ -131,6 +131,11 @@ impl Camera {
aspect_ratio: 16.0 / 9.0 aspect_ratio: 16.0 / 9.0
} }
} }
/// Returns the frustum of the camera.
pub fn frustum(&self) -> Frustum {
RenderCamera::frustum(self)
}
} }
impl RenderCamera for Camera { impl RenderCamera for Camera {

View File

@ -2,13 +2,13 @@
use std::slice::{Iter, IterMut}; use std::slice::{Iter, IterMut};
use std::vec::IntoIter; use std::vec::IntoIter;
use std::sync::Arc; use std::rc::Rc;
use std::cell::RefCell; use std::cell::RefCell;
use model::Model; use model::Model;
/// Represents a 3D scene with models. /// Represents a 3D scene with models.
pub struct Scene { pub struct Scene {
models: Vec<Arc<RefCell<Model>>>, models: Vec<Rc<RefCell<Model>>>,
} }
impl Scene { impl Scene {
@ -20,29 +20,29 @@ impl Scene {
} }
/// Adds a model to the scene. /// Adds a model to the scene.
pub fn push(&mut self, model: Arc<RefCell<Model>>) { pub fn push(&mut self, model: Rc<RefCell<Model>>) {
self.models.push(model); self.models.push(model);
} }
/// Converts the model to a Arc<RefCell<Model>> and adds it to the scene. /// Converts the model to a Rc<RefCell<Model>> and adds it to the scene.
pub fn emplace(&mut self, model: Model) { 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. /// Returns an iterator to the models of the scene.
pub fn iter(&self) -> Iter<Arc<RefCell<Model>>> { pub fn iter(&self) -> Iter<Rc<RefCell<Model>>> {
self.models.iter() self.models.iter()
} }
/// Returns a mutable iterator to the model of the scene. /// Returns a mutable iterator to the model of the scene.
pub fn iter_mut(&mut self) -> IterMut<Arc<RefCell<Model>>> { pub fn iter_mut(&mut self) -> IterMut<Rc<RefCell<Model>>> {
self.models.iter_mut() self.models.iter_mut()
} }
} }
impl IntoIterator for Scene { impl IntoIterator for Scene {
type IntoIter = IntoIter<Arc<RefCell<Model>>>; type IntoIter = IntoIter<Rc<RefCell<Model>>>;
type Item = Arc<RefCell<Model>>; type Item = Rc<RefCell<Model>>;
fn into_iter(self) -> Self::IntoIter { fn into_iter(self) -> Self::IntoIter {
self.models.into_iter() self.models.into_iter()
@ -52,7 +52,7 @@ impl IntoIterator for Scene {
impl From<Vec<Model>> for Scene { impl From<Vec<Model>> for Scene {
fn from(input: Vec<Model>) -> Scene { fn from(input: Vec<Model>) -> Scene {
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(),
} }
} }
} }