Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiBody with FreeJoint causes a panic when it has no Collider with a set density #207

Open
Kritzefitz opened this issue Jun 29, 2019 · 0 comments

Comments

@Kritzefitz
Copy link

Kritzefitz commented Jun 29, 2019

While experimenting with MultiBodies I discovered that FreeJoints and FixedJoints apparently cause a panic when the MultiBodies attached to the joint don't have colliders with a set density. Specifically this program runs fine:

let mut world = World::new();

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

// Using FixedJoint instead seems to have the same problems.
let top_joint = FreeJoint::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()

But when I remove the call to density(1.0) or one any of the calls to add_collider(&collider) I get the following panic right after I run the executable:

thread 'main' panicked at 'assertion failed: self.inv_augmented_mass.solve_mut(&mut self.accelerations)', /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/nphysics3d-0.11.1/src/object/multibody.rs:324: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: <nphysics3d::object::multibody::Multibody<N>>::update_acceleration
             at ./<::std::macros::panic macros>:3
   7: <nphysics3d::object::multibody::Multibody<N> as nphysics3d::object::body::Body<N>>::update_acceleration
             at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/nphysics3d-0.11.1/src/object/multibody.rs:845
   8: <nphysics3d::world::world::World<N>>::step
             at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/nphysics3d-0.11.1/src/world/world.rs:248
   9: <nphysics_testbed3d::testbed::Testbed as kiss3d::window::state::State>::step
             at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/nphysics_testbed3d-0.5.0/src/testbed.rs:552
  10: 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
  11: 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
  12: <kiss3d::window::gl_canvas::GLCanvas as kiss3d::window::canvas::AbstractCanvas>::render_loop
             at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/kiss3d-0.19.0/src/window/gl_canvas.rs:67
  13: kiss3d::window::canvas::Canvas::render_loop
             at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/kiss3d-0.19.0/src/window/canvas.rs:31
  14: kiss3d::window::window::Window::render_loop
             at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/kiss3d-0.19.0/src/window/window.rs:581
  15: nphysics_testbed3d::testbed::Testbed::run
             at /home/sven/.cargo/registry/src/github.com-1ecc6299db9ec823/nphysics_testbed3d-0.5.0/src/testbed.rs:243
  16: reproduce::main
             at src/reproduce.rs:26
  17: std::rt::lang_start::{{closure}}
             at /usr/src/rustc-1.34.2/src/libstd/rt.rs:64
  18: std::panicking::try::do_call
  19: __rust_maybe_catch_panic
  20: std::rt::lang_start_internal
  21: std::rt::lang_start
             at /usr/src/rustc-1.34.2/src/libstd/rt.rs:64
  22: main
  23: __libc_start_main
  24: _start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant