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

Panic with SpringJoint #497

Closed
brookman opened this issue May 3, 2024 · 2 comments
Closed

Panic with SpringJoint #497

brookman opened this issue May 3, 2024 · 2 comments

Comments

@brookman
Copy link

brookman commented May 3, 2024

Hi. I'm new to rapier and tried to start with a simple example where I add a single SpringJoint between two bodies. However the application immediately panics.

How I set up the bodies:

    commands
            .spawn(SpriteBundle {
                sprite: Sprite {
                    color: Color::rgb(0.5, 0.5, 1.0),
                    custom_size: Some(Vec2::new(10.0, 10.0)),
                    ..default()
                },
                transform: Transform::from_xyz(
                    rand::random::<f32>() * 100.0,
                    rand::random::<f32>() * 100.0,
                    0.0,
                ),
                ..default()
            })
            .insert(RigidBody::Dynamic)
            .insert(Collider::ball(5.0));

How I tried to add the joint:

let joint = SpringJointBuilder::new(1.0, 1.0, 1.0)
    .build();
 commands
    .entity(entity_a)
   .insert(ImpulseJoint::new(entity_b, joint));

The panic

thread 'Compute Task Pool (0)' panicked at /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rapier2d-0.18.0/src/dynamics/solver/joint_constraint/joint_velocity_constraint.rs:335:31:
index out of bounds: the len is 4 but the index is 18446744073709551615
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy_rapier2d::plugin::systems::step_simulation<()>`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!

Am I doing something wrong?

@sebcrozet
Copy link
Member

Hi! This will be fixed by dimforge/rapier#603 (merged but not released yet).

@brookman
Copy link
Author

brookman commented May 4, 2024

Thank you for the quick reply. 👍

In case anyone else runs into the same issue before the fix is released: I could get it working by overriding the transitive dependency in my Cargo.toml like this:

[dependencies]
bevy = "0.13.2"
bevy_rapier2d = "0.25.0"
rand = "0.8.5"

[patch.crates-io]
rapier2d = { git = 'https://github.com/dimforge/rapier', rev = "81f05f26b056247e21c6cd0b8cb187a64f181131"}

I had to use the specific commit ID because there are other, incompatible changes on the main branch.

@brookman brookman closed this as completed May 4, 2024
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

2 participants