meirbon / rtbvh

BVH library for Rust
Apache License 2.0
17 stars 0 forks source link

Panic on "Leaf nodes should not be attempted to be split!" #3

Open stijn-ucrowds opened 3 years ago

stijn-ucrowds commented 3 years ago

During MBVH construction the algorithm panics.

let bvh = (Builder {
    aabbs: None,
    primitives: triangles.as_slice(),
    primitives_per_leaf: None,
})
    .construct_binned_sah()
    .unwrap_or_default();

let bvh = Mbvh::from(bvh);
thread 'main' panicked at 'Leaf nodes should not be attempted to be split!', C:\Users\User\.cargo\registry\src\github.com-1ecc6299db9ec823\rtbvh-0.5.3\src\mbvh_node.rs:307:13
stack backtrace:
   0: std::panicking::begin_panic<str>
             at C:\Users\User\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:519
   1: rtbvh::mbvh_node::MbvhNode::merge_nodes
             at C:\Users\User\.cargo\registry\src\github.com-1ecc6299db9ec823\rtbvh-0.5.3\src\mbvh_node.rs:307
   2: rtbvh::bvh::Mbvh::construct
             at C:\Users\User\.cargo\registry\src\github.com-1ecc6299db9ec823\rtbvh-0.5.3\src\bvh.rs:373
   3: rtbvh::bvh::{{impl}}::from
             at C:\Users\User\.cargo\registry\src\github.com-1ecc6299db9ec823\rtbvh-0.5.3\src\bvh.rs:419

With the following input triangles.

128.79
-1422.82
0.16
128.5
-1426.88
0.16
128.79
-1426.9067
0.16
129.8
-1422.8629
0.16
128.79
-1422.82
0.16
128.79
-1426.9067
0.16
129.8
-1422.8629
0.16
128.79
-1426.9067
0.16
129.8
-1427
0.16
130.2
-1422.88
0.16
129.8
-1422.8629
0.16
129.8
-1427
0.16
130.2
-1422.88
0.16
129.8
-1427
0.16
130.2
-1423.13
0.16

This being 5 triangles composed of 3 points each composed of 3 components, so:

p0.x
p0.y
p0.z
p1.x
p1.y
p1.z
p2.x
p2.y
p2.z

And then repeat

stijn-ucrowds commented 3 years ago

The newest version (0.5.5) does not crash on the same panic! anymore, but now has an index out of bounds issue.

thread 'main' panicked at 'Index 121 is out of bounds!', C:\Users\User\.cargo\registry\src\github.com-1ecc6299db9ec823\rtbvh-0.5.5\src\mbvh_node.rs:315:13
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53\/library\std\src\panicking.rs:493
   1: std::panicking::begin_panic_fmt
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53\/library\std\src\panicking.rs:435
   2: rtbvh::mbvh_node::MbvhNode::merge_nodes
             at C:\Users\User\.cargo\registry\src\github.com-1ecc6299db9ec823\rtbvh-0.5.5\src\mbvh_node.rs:315
   3: rtbvh::mbvh_node::MbvhNode::merge_nodes
             at C:\Users\User\.cargo\registry\src\github.com-1ecc6299db9ec823\rtbvh-0.5.5\src\mbvh_node.rs:334
   4: rtbvh::mbvh_node::MbvhNode::merge_nodes
             at C:\Users\User\.cargo\registry\src\github.com-1ecc6299db9ec823\rtbvh-0.5.5\src\mbvh_node.rs:334
   5: rtbvh::mbvh_node::MbvhNode::merge_nodes
             at C:\Users\User\.cargo\registry\src\github.com-1ecc6299db9ec823\rtbvh-0.5.5\src\mbvh_node.rs:334
   6: rtbvh::mbvh_node::MbvhNode::merge_nodes
             at C:\Users\User\.cargo\registry\src\github.com-1ecc6299db9ec823\rtbvh-0.5.5\src\mbvh_node.rs:334
   7: rtbvh::mbvh_node::MbvhNode::merge_nodes
             at C:\Users\User\.cargo\registry\src\github.com-1ecc6299db9ec823\rtbvh-0.5.5\src\mbvh_node.rs:334
   8: rtbvh::mbvh_node::MbvhNode::merge_nodes
             at C:\Users\User\.cargo\registry\src\github.com-1ecc6299db9ec823\rtbvh-0.5.5\src\mbvh_node.rs:334
   9: rtbvh::bvh::Mbvh::construct
             at C:\Users\User\.cargo\registry\src\github.com-1ecc6299db9ec823\rtbvh-0.5.5\src\bvh.rs:373
  10: rtbvh::bvh::{{impl}}::from
             at C:\Users\User\.cargo\registry\src\github.com-1ecc6299db9ec823\rtbvh-0.5.5\src\bvh.rs:419