dimforge / rapier

2D and 3D physics engines focused on performance.
https://rapier.rs
Apache License 2.0
3.77k stars 235 forks source link

Very large 2d cuboid "ground" destabilizes simulation #629

Open taslater opened 1 month ago

taslater commented 1 month ago

A GROUND_WIDTH greater than or equal to about 1e8 causes the simulation to become unstable. Collisions with this very large "ground" seem to impart a large energy to the other collider, which increases as the "ground" is larger. Other times, the object colliding with the ground falls right through.

const PHYSICS_SCALE: f32 = 1e0;
const GROUND_WIDTH: f32 = 1e6;
const GROUND_HEIGHT: f32 = 10.0;

let ground_collider =
    ColliderBuilder::cuboid(GROUND_WIDTH * PHYSICS_SCALE, GROUND_HEIGHT * PHYSICS_SCALE)
        .translation(vector![GROUND_X * PHYSICS_SCALE, GROUND_Y * PHYSICS_SCALE])
        .restitution(GROUND_RESTITUTION)
        .collision_groups(InteractionGroups::new(0b0001.into(), 0b1111.into()))
        .build();

I'm not sure if this is expected behavior for the collision of objects of very different sizes, but I wanted to raise the issue to attention. I should also mention that the height of the cuboid does not seem to improve the stability of the simulated collisions.