use rapier2d::prelude::*;
#[test]
fn empty_polyline_collider_steps_and_queries_without_panicking() {
let mut world = PhysicsWorld::new();
world.insert_collider(ColliderBuilder::polyline(vec![], None), None);
let (ball, _) = world.insert(
RigidBodyBuilder::dynamic().translation(Vector::new(0.0, 1.0)),
ColliderBuilder::ball(0.5),
);
for _ in 0..10 {
world.step();
}
assert!(
world.bodies[ball].translation().y < 1.0,
"ball should fall freely"
);
let ray = Ray::new(Vector::new(0.0, 10.0), Vector::new(0.0, -1.0));
let hit = world.cast_ray(&ray, Real::MAX, true, QueryFilter::default());
if let Some((handle, _)) = hit {
assert_eq!(world.colliders[handle].parent(), Some(ball));
}
}