gdritter repos thermidor / 526efa1
Switched to using references for models Getty Ritter 8 years ago
1 changed file(s) with 9 addition(s) and 7 deletion(s). Collapse all Expand all
1 use cgmath::{Matrix4,SquareMatrix,Vector3,Vector4};
1 use cgmath::{Matrix4,SquareMatrix,Vector3};
22 use model::Model;
33
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>>),
88 }
99
10 impl SceneGraph {
10 impl<'a> SceneGraph<'a> {
11 /// Call the supplied callback on every element of a scene graph
12 /// along with its calculated transform matrix
1113 pub fn traverse<F>(&self, callback: &mut F)
1214 where F: FnMut(&Model, &[[f32;4];4]) -> ()
1315 {
1517 }
1618
1719 fn go<F>(&self, callback: &mut F, mat: Matrix4<f32>)
18 where F: FnMut(&Model, &[[f32;4];4]) -> ()
20 where F: FnMut(&'a Model, &[[f32;4];4]) -> ()
1921 {
2022 match self {
2123 &SceneGraph::Model(ref m) => callback(m, &mat.into()),