Eliminated some unnecessary left drift in BVH4 code.
IMO this is much easier to read.
This commit is contained in:
parent
92fd83a766
commit
725bbca6a1
|
@ -83,12 +83,12 @@ impl<'a> BVH4<'a> {
|
||||||
pub fn traverse<T, F>(&self, rays: &mut [AccelRay], objects: &[T], mut obj_ray_test: F)
|
pub fn traverse<T, F>(&self, rays: &mut [AccelRay], objects: &[T], mut obj_ray_test: F)
|
||||||
where F: FnMut(&T, &mut [AccelRay])
|
where F: FnMut(&T, &mut [AccelRay])
|
||||||
{
|
{
|
||||||
match self.root {
|
if self.root.is_none() {
|
||||||
None => {}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Some(root) => {
|
|
||||||
// +2 of max depth for root and last child
|
// +2 of max depth for root and last child
|
||||||
let mut node_stack = [Some(root); BVH_MAX_DEPTH + 2];
|
let mut node_stack = [self.root; BVH_MAX_DEPTH + 2];
|
||||||
let mut ray_i_stack = [rays.len(); BVH_MAX_DEPTH + 2];
|
let mut ray_i_stack = [rays.len(); BVH_MAX_DEPTH + 2];
|
||||||
let mut stack_ptr = 1;
|
let mut stack_ptr = 1;
|
||||||
let mut first_loop = true;
|
let mut first_loop = true;
|
||||||
|
@ -147,8 +147,7 @@ impl<'a> BVH4<'a> {
|
||||||
for i in 0..children.len() {
|
for i in 0..children.len() {
|
||||||
let inv_i = (children.len() - 1) - i;
|
let inv_i = (children.len() - 1) - i;
|
||||||
let child_i = ((node_order_code >> (inv_i * 2)) & 3) as usize;
|
let child_i = ((node_order_code >> (inv_i * 2)) & 3) as usize;
|
||||||
node_stack[stack_ptr + i] = if ((all_hits >> child_i) & 1) ==
|
node_stack[stack_ptr + i] = if ((all_hits >> child_i) & 1) == 0 {
|
||||||
0 {
|
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(&children[child_i])
|
Some(&children[child_i])
|
||||||
|
@ -164,8 +163,7 @@ impl<'a> BVH4<'a> {
|
||||||
|
|
||||||
Some(&BVH4Node::Leaf { object_range }) => {
|
Some(&BVH4Node::Leaf { object_range }) => {
|
||||||
let part = if !first_loop {
|
let part = if !first_loop {
|
||||||
partition(&mut rays[..ray_i_stack[stack_ptr]],
|
partition(&mut rays[..ray_i_stack[stack_ptr]], |r| r.trav_stack.pop())
|
||||||
|r| r.trav_stack.pop())
|
|
||||||
} else {
|
} else {
|
||||||
ray_i_stack[stack_ptr]
|
ray_i_stack[stack_ptr]
|
||||||
};
|
};
|
||||||
|
@ -190,8 +188,6 @@ impl<'a> BVH4<'a> {
|
||||||
first_loop = false;
|
first_loop = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn construct_from_base(arena: &'a MemArena,
|
fn construct_from_base(arena: &'a MemArena,
|
||||||
base: &BVHBase,
|
base: &BVHBase,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user