Switched to using references for models
Getty Ritter
8 years ago
1 |
use cgmath::{Matrix4,SquareMatrix,Vector3 |
|
1 | use cgmath::{Matrix4,SquareMatrix,Vector3}; | |
2 | 2 | use model::Model; |
3 | 3 | |
4 | pub enum SceneGraph { | |
5 | Translate(f32, f32, f32, Box<SceneGraph>), | |
6 | Model(Model), | |
7 | Many(Vec<SceneGraph>), | |
4 | pub enum SceneGraph<'a> { | |
5 | Translate(f32, f32, f32, Box<SceneGraph<'a>>), | |
6 | Model(&'a Model), | |
7 | Many(Vec<SceneGraph<'a>>), | |
8 | 8 | } |
9 | 9 | |
10 |
impl |
|
10 | impl<'a> SceneGraph<'a> { | |
11 | /// Call the supplied callback on every element of a scene graph | |
12 | /// along with its calculated transform matrix | |
11 | 13 | pub fn traverse<F>(&self, callback: &mut F) |
12 | 14 | where F: FnMut(&Model, &[[f32;4];4]) -> () |
13 | 15 | { |
15 | 17 | } |
16 | 18 | |
17 | 19 | fn go<F>(&self, callback: &mut F, mat: Matrix4<f32>) |
18 |
where F: FnMut(& |
|
20 | where F: FnMut(&'a Model, &[[f32;4];4]) -> () | |
19 | 21 | { |
20 | 22 | match self { |
21 | 23 | &SceneGraph::Model(ref m) => callback(m, &mat.into()), |