rtiow: print BVH stats.
This commit is contained in:
parent
63975bad96
commit
9188ce17fa
@ -136,6 +136,44 @@ where
|
|||||||
"BVHTriangles build time {:0.3}s",
|
"BVHTriangles build time {:0.3}s",
|
||||||
now.elapsed().as_secs_f32()
|
now.elapsed().as_secs_f32()
|
||||||
);
|
);
|
||||||
|
struct Stats {
|
||||||
|
nodes: usize,
|
||||||
|
leafs: usize,
|
||||||
|
min_tris: u32,
|
||||||
|
max_tris: u32,
|
||||||
|
}
|
||||||
|
impl Default for Stats {
|
||||||
|
fn default() -> Self {
|
||||||
|
Stats {
|
||||||
|
nodes: 0,
|
||||||
|
leafs: 0,
|
||||||
|
min_tris: u32::MAX,
|
||||||
|
max_tris: u32::MIN,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let stats = bvh.bvh_nodes.iter().fold(Stats::default(), |mut stats, n| {
|
||||||
|
stats.nodes += 1;
|
||||||
|
if n.is_leaf() {
|
||||||
|
stats.leafs += 1;
|
||||||
|
stats.min_tris = n.tri_count.min(stats.min_tris);
|
||||||
|
stats.max_tris = n.tri_count.max(stats.max_tris);
|
||||||
|
}
|
||||||
|
stats
|
||||||
|
});
|
||||||
|
info!("BVHTriangles build stats:");
|
||||||
|
info!(" Nodes: {}", stats.nodes);
|
||||||
|
info!(" Leaves: {}", stats.leafs);
|
||||||
|
info!(" Min Tri: {}", stats.min_tris);
|
||||||
|
info!(" Max Tri: {}", stats.max_tris);
|
||||||
|
info!(" Avg Tri: {}", bvh.triangles.len() / stats.leafs);
|
||||||
|
info!(" Predict: {}", bvh.bvh_nodes.capacity());
|
||||||
|
info!(" Actual: {}", bvh.bvh_nodes.len());
|
||||||
|
info!(
|
||||||
|
" Savings: {}",
|
||||||
|
(bvh.bvh_nodes.capacity() - bvh.bvh_nodes.len()) * std::mem::size_of::<BVHNode>()
|
||||||
|
);
|
||||||
|
bvh.bvh_nodes.shrink_to_fit();
|
||||||
bvh
|
bvh
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +231,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Stop subdividing if it isn't getting any better.
|
// Stop subdividing if it isn't getting any better.
|
||||||
if best_cost <= parent_cost {
|
if best_cost >= parent_cost {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user