diff options
| author | Crozet Sébastien <developer@crozet.re> | 2021-01-21 16:29:05 +0100 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2021-01-21 16:29:05 +0100 |
| commit | 800b35b103c60a3f13dffdfe1c20561074041cea (patch) | |
| tree | fdedf5109816f7790278c0ab40403f7b646db7f2 /examples3d | |
| parent | 98d3980db7a9803f4ee965237599a87771a417d1 (diff) | |
| download | rapier-800b35b103c60a3f13dffdfe1c20561074041cea.tar.gz rapier-800b35b103c60a3f13dffdfe1c20561074041cea.tar.bz2 rapier-800b35b103c60a3f13dffdfe1c20561074041cea.zip | |
Add collider constructors for shapes obtained from convex decomposition.
Diffstat (limited to 'examples3d')
| -rw-r--r-- | examples3d/convex_decomposition3.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/examples3d/convex_decomposition3.rs b/examples3d/convex_decomposition3.rs index abd2fe0..c06a450 100644 --- a/examples3d/convex_decomposition3.rs +++ b/examples3d/convex_decomposition3.rs @@ -45,7 +45,7 @@ pub fn init_world(testbed: &mut Testbed) { let deltas = na::one(); let mtl_path = Path::new(""); - let mut compound_parts = Vec::new(); + let mut shapes = Vec::new(); println!("Parsing and decomposing: {}", obj_path); let obj = obj::parse_file(&Path::new(&obj_path), &mtl_path, ""); @@ -81,13 +81,9 @@ pub fn init_world(testbed: &mut Testbed) { .into_iter() .map(|idx| [idx.x, idx.y, idx.z]) .collect(); - let vhacd = VHACD::decompose(¶ms, &vertices, &indices, true); - for (vertices, indices) in vhacd.compute_exact_convex_hulls(&vertices, &indices) { - if let Some(convex) = ColliderShape::convex_mesh(vertices, &indices) { - compound_parts.push(convex); - } - } + let decomposed_shape = ColliderShape::convex_decomposition(&vertices, &indices); + shapes.push(decomposed_shape); } // let compound = ColliderShape::compound(compound_parts); @@ -100,8 +96,8 @@ pub fn init_world(testbed: &mut Testbed) { let body = RigidBodyBuilder::new_dynamic().translation(x, y, z).build(); let handle = bodies.insert(body); - for part in &compound_parts { - let collider = ColliderBuilder::new(part.clone()).build(); + for shape in &shapes { + let collider = ColliderBuilder::new(shape.clone()).build(); colliders.insert(collider, handle, &mut bodies); } } |
