-
-
Notifications
You must be signed in to change notification settings - Fork 303
Open
Labels
Description
I have an app that gives the following error (or similar with different indices, depending on the exact situation):
thread 'main' panicked at /home/nate/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rapier2d-0.26.1/src/dynamics/solver/interaction_groups.rs:278:54:
index out of bounds: the len is 1 but the index is 1
Relatively minimal repro:
use rapier2d::prelude::*;
#[derive(Default)]
struct GamePhysics {
physics: PhysicsPipeline,
island_manager: IslandManager,
broad_phase: DefaultBroadPhase,
narrow_phase: NarrowPhase,
bodies: RigidBodySet,
colliders: ColliderSet,
impulse_joints: ImpulseJointSet,
multibody_joints: MultibodyJointSet,
ccd_solver: CCDSolver,
}
impl GamePhysics {
fn step(&mut self) {
self.physics.step(&Vector::new(0.0, 9.8), &Default::default(), &mut self.island_manager, &mut self.broad_phase, &mut self.narrow_phase, &mut self.bodies, &mut self.colliders, &mut self.impulse_joints, &mut self.multibody_joints, &mut self.ccd_solver, None, &(), &());
}
}
fn main() {
let mut physics = GamePhysics::default();
let a = physics.bodies.insert(RigidBodyBuilder::dynamic());
let b = physics.bodies.insert(RigidBodyBuilder::dynamic());
physics.impulse_joints.insert(a, b, RevoluteJointBuilder::new(), true);
physics.step();
physics.bodies[b].set_body_type(RigidBodyType::Fixed, true);
physics.step();
}simd-stable must be enabled or it doesn't crash:
[package]
name = "physics-crash"
version = "0.1.0"
edition = "2024"
[dependencies]
rapier2d = { version = "*", features = ["simd-stable"] }This might be the same as this issue, but I'm not sure. It also happens with the latest git version of rapier2d. Most (maybe all) other combinations of dynamic/fixed don't crash. Setting a to fixed instead of b doesn't crash.