diff --git a/src/assembly.rs b/src/assembly.rs index 9af78ae..b3b8e1a 100644 --- a/src/assembly.rs +++ b/src/assembly.rs @@ -122,8 +122,6 @@ impl AssemblyBuilder { pub fn build(mut self) -> Assembly { // Shrink storage to minimum. - // However, don't shrink shader storage, because there are pointers to - // that data that could get invalidated. self.instances.shrink_to_fit(); self.xforms.shrink_to_fit(); self.objects.shrink_to_fit(); @@ -135,6 +133,8 @@ impl AssemblyBuilder { 1, |inst| &bbs[bis[inst.id]..bis[inst.id + 1]]); + println!("Assembly BVH Depth: {}", object_accel.tree_depth()); + Assembly { instances: self.instances, xforms: self.xforms, diff --git a/src/bvh.rs b/src/bvh.rs index 1719f96..3b5b392 100644 --- a/src/bvh.rs +++ b/src/bvh.rs @@ -47,11 +47,13 @@ impl BVH { bvh.bounds_cache.clear(); bvh.bounds_cache.shrink_to_fit(); - println!("BVH Depth: {}", bvh.depth); - bvh } + pub fn tree_depth(&self) -> usize { + self.depth + } + fn acc_bounds<'a, T, F>(&mut self, objects1: &mut [T], bounder: &F) where F: 'a + Fn(&T) -> &'a [BBox] { diff --git a/src/parse/data_tree.rs b/src/parse/data_tree.rs index 3220533..834eda1 100644 --- a/src/parse/data_tree.rs +++ b/src/parse/data_tree.rs @@ -183,7 +183,7 @@ impl<'a> Iterator for DataTreeFilterInternalIter<'a> { fn next(&mut self) -> Option<(&'a str, Option<&'a str>, &'a Vec>)> { loop { - match self.iter.next() { + match self.iter.next() { Some(&DataTree::Internal{type_name, ident, ref children}) => { if type_name == self.type_name { return Some((type_name, ident, children)); diff --git a/src/parse/psy_assembly.rs b/src/parse/psy_assembly.rs index 3298504..90f0b92 100644 --- a/src/parse/psy_assembly.rs +++ b/src/parse/psy_assembly.rs @@ -60,7 +60,10 @@ pub fn parse_assembly(tree: &DataTree) -> Result { // MeshSurface "MeshSurface" => { if let &DataTree::Internal {ident: Some(ident), ..} = child { - builder.add_object(ident, Object::Surface(Box::new(try!(parse_mesh_surface(&child))))); + builder.add_object( + ident, + Object::Surface(Box::new(try!(parse_mesh_surface(&child)))) + ); } else { // TODO: error condition of some kind, because no ident panic!();