Some minor code formatting cleanup and debug printing.

This commit is contained in:
Nathan Vegdahl 2016-05-28 14:35:37 -07:00
parent ef31093dcb
commit 848d0afd40
4 changed files with 11 additions and 6 deletions

View File

@ -122,8 +122,6 @@ impl AssemblyBuilder {
pub fn build(mut self) -> Assembly { pub fn build(mut self) -> Assembly {
// Shrink storage to minimum. // 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.instances.shrink_to_fit();
self.xforms.shrink_to_fit(); self.xforms.shrink_to_fit();
self.objects.shrink_to_fit(); self.objects.shrink_to_fit();
@ -135,6 +133,8 @@ impl AssemblyBuilder {
1, 1,
|inst| &bbs[bis[inst.id]..bis[inst.id + 1]]); |inst| &bbs[bis[inst.id]..bis[inst.id + 1]]);
println!("Assembly BVH Depth: {}", object_accel.tree_depth());
Assembly { Assembly {
instances: self.instances, instances: self.instances,
xforms: self.xforms, xforms: self.xforms,

View File

@ -47,11 +47,13 @@ impl BVH {
bvh.bounds_cache.clear(); bvh.bounds_cache.clear();
bvh.bounds_cache.shrink_to_fit(); bvh.bounds_cache.shrink_to_fit();
println!("BVH Depth: {}", bvh.depth);
bvh bvh
} }
pub fn tree_depth(&self) -> usize {
self.depth
}
fn acc_bounds<'a, T, F>(&mut self, objects1: &mut [T], bounder: &F) fn acc_bounds<'a, T, F>(&mut self, objects1: &mut [T], bounder: &F)
where F: 'a + Fn(&T) -> &'a [BBox] where F: 'a + Fn(&T) -> &'a [BBox]
{ {

View File

@ -183,7 +183,7 @@ impl<'a> Iterator for DataTreeFilterInternalIter<'a> {
fn next(&mut self) -> Option<(&'a str, Option<&'a str>, &'a Vec<DataTree<'a>>)> { fn next(&mut self) -> Option<(&'a str, Option<&'a str>, &'a Vec<DataTree<'a>>)> {
loop { loop {
match self.iter.next() { match self.iter.next() {
Some(&DataTree::Internal{type_name, ident, ref children}) => { Some(&DataTree::Internal{type_name, ident, ref children}) => {
if type_name == self.type_name { if type_name == self.type_name {
return Some((type_name, ident, children)); return Some((type_name, ident, children));

View File

@ -60,7 +60,10 @@ pub fn parse_assembly(tree: &DataTree) -> Result<Assembly, PsyParseError> {
// MeshSurface // MeshSurface
"MeshSurface" => { "MeshSurface" => {
if let &DataTree::Internal {ident: Some(ident), ..} = child { 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 { } else {
// TODO: error condition of some kind, because no ident // TODO: error condition of some kind, because no ident
panic!(); panic!();