I'm observing an issue where balls with CCD enabled are penetrating a heightfield collider attached to fixed body.
I'm able to reproduce the issue using the examples3d/trimesh3.rs example on master with this patch:
- let heightfield = HeightField::new(heights, ground_size);
- let (vertices, indices) = heightfield.to_trimesh();
let rigid_body = RigidBodyBuilder::fixed();
+
let handle = bodies.insert(rigid_body);
- let collider = ColliderBuilder::trimesh_with_flags(
- vertices,
- indices,
- TriMeshFlags::MERGE_DUPLICATE_VERTICES,
- );
+ let collider = ColliderBuilder::heightfield(heights, ground_size);
colliders.insert_with_parent(collider, handle, &mut bodies);
/*
* Create the cubes
*/
let num = 8;
- let rad = 1.0;
+ let rad = 0.1;
- let shift = rad * 2.0 + rad;
+ let shift = rad * 3.0 + rad;
let centerx = shift * (num / 2) as f32;
let centery = shift / 2.0;
let centerz = shift * (num / 2) as f32;
- for j in 0usize..20 {
+ for j in 0usize..2 {
for i in 0..num {
for k in 0usize..num {
let x = i as f32 * shift - centerx;
- let y = j as f32 * shift + centery + 3.0;
+ let y = j as f32 * shift + centery + 6.0;
let z = k as f32 * shift - centerz;
// Build the rigid body.
- let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
+ let rigid_body = RigidBodyBuilder::dynamic()
+ .translation(vector![x, y, z])
+ .ccd_enabled(true);
let handle = bodies.insert(rigid_body);
- let collider = match j % 6 {
+ let collider = match 1 { // just balls
0 => ColliderBuilder::cuboid(rad, rad, rad),
1 => ColliderBuilder::ball(rad),
// Rounded cylinders are much more efficient that cylinder, even if the
I'm observing an issue where balls with CCD enabled are penetrating a heightfield collider attached to fixed body.
I'm able to reproduce the issue using the
examples3d/trimesh3.rs
example on master with this patch: