dimforge / dimforge/nphysics

MultyBody with FixedJoint causes a panic when only one part is attached to it

Open
#208 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.6k
Forks
120
PR merge metrics
No merged PRs in 30d

Description

The following program panics with the message below:

```rust
let mut world = World::new();

let shape = ShapeHandle::new(Cuboid::new(Vector3::repeat(0.5)));
let collider = ColliderDesc::new(shape)
.density(1.0);

let top_joint = FixedJoint::new(Isometry3::identity());
let mut body_desc = MultibodyDesc::new(top_joint)
.collider(&collider)
.parent_shift(Vector3::repeat(1.0));

/*let sub_joint = PrismaticJoint::new(Vector3::x_axis(), 0.0);
body_desc.add_child(sub_joint)
.set_parent_shift(Vector3::repeat(1.0))
.add_collider(&collider);*/

body_desc.build(&mut world);

Testbed::new(world).run()
```

```
thread 'main' panicked at 'Matrix slicing out of bounds.', /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/nalgebra-0.18.0/src/base/matrix_slice.rs:227:9
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
1: std::sys_common::backtrace::print
2: std::panicking::default_hook::{{closure}}
3: std::panicking::default_hook
4: std::panicking::rust_panic_with_hook
5: std::panicking::begin_panic
at /usr/src/rustc-1.34.2/src/libstd/panicking.rs:412
6: nalgebra::base::matrix_slice::>::assert_slice_index
at ./<::std::macros::panic macros>:3
7: nalgebra::base::matrix_slice::>::columns_generic
at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/nalgebra-0.18.0/src/base/matrix_slice.rs:410
8: nalgebra::base::matrix_slice::>::fixed_columns
at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/nalgebra-0.18.0/src/base/matrix_slice.rs:391
9: nalgebra::base::matrix_slice::>::column
at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/nalgebra-0.18.0/src/base/matrix_slice.rs:360
10: nalgebra::base::blas::>::quadform_with_workspace
at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/nalgebra-0.18.0/src/base/blas.rs:1487
11: nalgebra::base::blas::>::quadform
at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/nalgebra-0.18.0/src/base/blas.rs:1532
12: >::update_inertias
at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/nphysics3d-0.11.1/src/object/multibody.rs:465
13: >::update_dynamics
at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/nphysics3d-0.11.1/src/object/multibody.rs:381
14: as nphysics3d::object::body::Body>::update_dynamics
at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/nphysics3d-0.11.1/src/object/multibody.rs:841
15: >::step
at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/nphysics3d-0.11.1/src/world/world.rs:238
16: ::step
at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/nphysics_testbed3d-0.5.0/src/testbed.rs:552
17: kiss3d::window::window::Window::do_render_with_state
at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/kiss3d-0.19.0/src/window/window.rs:597
18: kiss3d::window::window::Window::render_loop::{{closure}}
at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/kiss3d-0.19.0/src/window/window.rs:581
19: ::render_loop
at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/kiss3d-0.19.0/src/window/gl_canvas.rs:67
20: kiss3d::window::canvas::Canvas::render_loop
at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/kiss3d-0.19.0/src/window/canvas.rs:31
21: kiss3d::window::window::Window::render_loop
at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/kiss3d-0.19.0/src/window/window.rs:581
22: nphysics_testbed3d::testbed::Testbed::run
at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/nphysics_testbed3d-0.5.0/src/testbed.rs:243
23: reproduce::main
at src/reproduce.rs:27
24: std::rt::lang_start::{{closure}}
at /usr/src/rustc-1.34.2/src/libstd/rt.rs:64
25: std::panicking::try::do_call
26: __rust_maybe_catch_panic
27: std::rt::lang_start_internal
28: std::rt::lang_start
at /usr/src/rustc-1.34.2/src/libstd/rt.rs:64
29: main
30: __libc_start_main
31: _start
```

When I comment in the part that adds the sub part on a `PrismaticJoint` the panic goes away. I guess having a `FixedJoint` with only one part below it isn't really useful, as it could also be achieved by mounting a `RigidBody` to the ground, but I think at least the panic should give a proper message about the problem, as this is quite hard to debug.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.