Index out of bounds panic with "Extrude faces" node
FedericoStra opened this issue Β· comments
Problem
The program panics with an "index out of bounds" in src/mesh/halfedge.rs:714:73
.
How to reproduce
Chain the following nodes:
- Box
- Bevel edges 1, 4
- Extrude face 8
In the image below, as soon as 7 is changed into 8 in the "Extrude faces" node the panic occurs.
Backtrace
thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 2', src/mesh/halfedge.rs:714:73
stack backtrace:
0: rust_begin_unwind
at /rustc/e012a191d768adeda1ee36a99ef8b92d51920154/library/std/src/panicking.rs:498:5
1: core::panicking::panic_fmt
at /rustc/e012a191d768adeda1ee36a99ef8b92d51920154/library/core/src/panicking.rs:107:14
2: core::panicking::panic_bounds_check
at /rustc/e012a191d768adeda1ee36a99ef8b92d51920154/library/core/src/panicking.rs:75:5
3: <usize as core::slice::index::SliceIndex<[T]>>::index
at /rustc/e012a191d768adeda1ee36a99ef8b92d51920154/library/core/src/slice/index.rs:189:10
4: core::slice::index::<impl core::ops::index::Index<I> for [T]>::index
at /rustc/e012a191d768adeda1ee36a99ef8b92d51920154/library/core/src/slice/index.rs:15:9
5: <smallvec::SmallVec<A> as core::ops::index::Index<I>>::index
at /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/smallvec-1.8.0/src/lib.rs:1703:10
6: blackjack_nodes::mesh::halfedge::HalfEdgeMesh::face_normal
at ./src/mesh/halfedge.rs:714:73
7: blackjack_nodes::mesh::halfedge::edit_ops::extrude_faces
at ./src/mesh/halfedge/edit_ops.rs:871:24
8: blackjack_nodes::graph::poly_asm::PolyAsmProgram::execute_instruction
at ./src/graph/poly_asm.rs:285:17
9: blackjack_nodes::graph::poly_asm::PolyAsmProgram::execute
at ./src/graph/poly_asm.rs:332:13
10: blackjack_nodes::app_window::AppWindow::compile_and_execute_program
at ./src/app_window.rs:154:20
11: blackjack_nodes::app_window::AppWindow::on_main_events_cleared
at ./src/app_window.rs:199:32
12: blackjack_nodes::app_window::AppWindow::run_app::{{closure}}
at ./src/app_window.rs:255:45
13: winit::platform_impl::platform::sticky_exit_callback
at /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/linux/mod.rs:753:5
14: winit::platform_impl::platform::x11::EventLoop<T>::run_return
at /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/linux/x11/mod.rs:293:17
15: winit::platform_impl::platform::x11::EventLoop<T>::run
at /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/linux/x11/mod.rs:392:9
16: winit::platform_impl::platform::EventLoop<T>::run
at /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/linux/mod.rs:669:56
17: winit::event_loop::EventLoop<T>::run
at /home/.../.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/event_loop.rs:154:9
18: blackjack_nodes::app_window::AppWindow::run_app
at ./src/app_window.rs:229:9
19: blackjack_nodes::main
at ./src/main.rs:33:5
20: core::ops::function::FnOnce::call_once
at /rustc/e012a191d768adeda1ee36a99ef8b92d51920154/library/core/src/ops/function.rs:227:5
Thanks for reporting! π
I only added the extrude node very recently, so this is probably hitting some untested edge case. I'll have a look at this soon π
Sorry for my very rudimentary crash report. I just discovered the project yesterday, played a bit with it, and didn't have time to actually read any source code, otherwise I would have tried to debug it a bit to help you out better.
Really nice project by the way!
Sorry for my very rudimentary crash report.
It really helps, so don't apologise! π I'm glad you took your time to try this out at such an early stage.
I pushed a fix that should prevent the panic, but the root cause still needs to be addressed. In case you're curious: There are some 2-vertex faces that are created during the bevel operation that should have been removed. 8
is one such face, so when you tried to extrude it, the code crashed because a face with 2 vertices doesn't have a normal.