diff --git a/Cargo.toml b/Cargo.toml index 8647e981..4b08551e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,5 +9,5 @@ parry2d-f64 = { path = "crates/parry2d-f64" } parry3d-f64 = { path = "crates/parry3d-f64" } #simba = { path = "../simba" } -simba = { git = "https://github.com/dimforge/simba", rev = "45a5266eb36ed9d25907e9bf9130cd4ac846a748" } -nalgebra = { git = "https://github.com/dimforge/nalgebra", rev = "0cf79aef0e6155befc3279a3145f1940822b8377" } \ No newline at end of file +#simba = { git = "https://github.com/dimforge/simba", rev = "45a5266eb36ed9d25907e9bf9130cd4ac846a748" } +#nalgebra = { git = "https://github.com/dimforge/nalgebra", rev = "0cf79aef0e6155befc3279a3145f1940822b8377" } \ No newline at end of file diff --git a/crates/parry2d-f64/Cargo.toml b/crates/parry2d-f64/Cargo.toml index a4b59558..5c3124f6 100644 --- a/crates/parry2d-f64/Cargo.toml +++ b/crates/parry2d-f64/Cargo.toml @@ -48,8 +48,8 @@ num-traits = { version = "0.2", default-features = false } smallvec = "1" slab = { version = "0.4", optional = true } arrayvec = { version = "0.7", default-features = false } -simba = { version = "^0.7.3", default-features = false } -nalgebra = { version = "0.31", default-features = false, features = [ "libm" ] } +simba = { version = "0.8", default-features = false } +nalgebra = { version = "0.32", default-features = false, features = [ "libm" ] } approx = { version = "0.5", default-features = false } serde = { version = "1.0", optional = true, features = ["derive"] } rkyv = { version = "0.7", optional = true } @@ -65,5 +65,5 @@ bytemuck = { version = "1", features = [ "derive" ], optional = true } cust = { version = "0.3", optional = true } [dev-dependencies] -simba = { version = "0.7", default-features = false, features = [ "partial_fixed_point_support" ] } +simba = { version = "0.8", default-features = false, features = [ "partial_fixed_point_support" ] } oorandom = "11" diff --git a/crates/parry2d/Cargo.toml b/crates/parry2d/Cargo.toml index a7a5b4d6..317a2bd8 100644 --- a/crates/parry2d/Cargo.toml +++ b/crates/parry2d/Cargo.toml @@ -48,8 +48,8 @@ num-traits = { version = "0.2", default-features = false } smallvec = "1" slab = { version = "0.4", optional = true } arrayvec = { version = "0.7", default-features = false } -simba = { version = "^0.7.3", default-features = false } -nalgebra = { version = "0.31", default-features = false, features = [ "libm" ] } +simba = { version = "0.8", default-features = false } +nalgebra = { version = "0.32", default-features = false, features = [ "libm" ] } approx = { version = "0.5", default-features = false } serde = { version = "1.0", optional = true, features = ["derive"] } rkyv = { version = "0.7", optional = true } @@ -65,5 +65,5 @@ bytemuck = { version = "1", features = [ "derive" ], optional = true } cust = { version = "0.3", optional = true } [dev-dependencies] -simba = { version = "0.7", default-features = false, features = [ "partial_fixed_point_support" ] } +simba = { version = "0.8", default-features = false, features = [ "partial_fixed_point_support" ] } oorandom = "11" diff --git a/crates/parry3d-f64/Cargo.toml b/crates/parry3d-f64/Cargo.toml index d415ae01..2c5e18fd 100644 --- a/crates/parry3d-f64/Cargo.toml +++ b/crates/parry3d-f64/Cargo.toml @@ -48,8 +48,8 @@ num-traits = { version = "0.2", default-features = false } smallvec = "1" slab = { version = "0.4", optional = true } arrayvec = { version = "0.7", default-features = false } -simba = { version = "^0.7.3", default-features = false } -nalgebra = { version = "0.31", default-features = false, features = [ "libm" ] } +simba = { version = "0.8", default-features = false } +nalgebra = { version = "0.32", default-features = false, features = [ "libm" ] } approx = { version = "0.5", default-features = false } serde = { version = "1.0", optional = true, features = ["derive", "rc"]} rkyv = { version = "0.7", optional = true } diff --git a/crates/parry3d/Cargo.toml b/crates/parry3d/Cargo.toml index b9f90434..9bb825c5 100644 --- a/crates/parry3d/Cargo.toml +++ b/crates/parry3d/Cargo.toml @@ -49,8 +49,8 @@ num-traits = { version = "0.2", default-features = false } smallvec = "1" slab = { version = "0.4", optional = true } arrayvec = { version = "0.7", default-features = false } -simba = { version = "^0.7.3", default-features = false } -nalgebra = { version = "0.31", default-features = false, features = [ "libm" ] } +simba = { version = "0.8", default-features = false } +nalgebra = { version = "0.32", default-features = false, features = [ "libm" ] } approx = { version = "0.5", default-features = false } serde = { version = "1.0", optional = true, features = ["derive", "rc"]} rkyv = { version = "0.7", optional = true } diff --git a/crates/parry3d/tests/geometry/mod.rs b/crates/parry3d/tests/geometry/mod.rs index 575d50a4..912181ca 100644 --- a/crates/parry3d/tests/geometry/mod.rs +++ b/crates/parry3d/tests/geometry/mod.rs @@ -6,5 +6,6 @@ mod cylinder_cuboid_contact; mod epa3; mod still_objects_toi; mod time_of_impact3; +mod trimesh_connected_components; mod trimesh_intersection; mod trimesh_trimesh_toi; diff --git a/crates/parry3d/tests/geometry/trimesh_connected_components.rs b/crates/parry3d/tests/geometry/trimesh_connected_components.rs new file mode 100644 index 00000000..bfaf5789 --- /dev/null +++ b/crates/parry3d/tests/geometry/trimesh_connected_components.rs @@ -0,0 +1,31 @@ +use parry3d::math::Point; +use parry3d::shape::{TriMesh, TriMeshFlags}; + +#[test] +// From https://github.com/dimforge/parry/issues/115 +fn mesh_connected_components_grouped_faces() { + let verts = vec![ + // Face 0 + Point::new(15.82, 6.455, -0.15), // <- Vertex shared with face 1. + Point::new(9.915, 6.455, -0.15), + Point::new(9.915, 6.4, 0.0), // <- Vertex shared with face 1. + // Face1 + Point::new(15.82, 6.455, -0.15), // <- Vertex shared with face 0. + Point::new(9.915, 6.4, 0.0), // <- Vertex shared with face 0. + Point::new(15.82, 6.4, 0.0), + ]; + + let mut roof = TriMesh::new(verts, vec![[0, 1, 2], [3, 4, 5]]); + + if let Err(e) = + roof.set_flags(TriMeshFlags::MERGE_DUPLICATE_VERTICES | TriMeshFlags::CONNECTED_COMPONENTS) + { + dbg!(e); + assert!(false); + } + + let components = roof.connected_components().unwrap(); + println!("components: {:?}", components); + assert_eq!(components.ranges.len(), 2); // Only one connected-component (two range values). + assert_eq!(components.grouped_faces.len(), 2); // Only two faces in the connected-component. +} diff --git a/src/shape/trimesh.rs b/src/shape/trimesh.rs index d51f91ce..faa38080 100644 --- a/src/shape/trimesh.rs +++ b/src/shape/trimesh.rs @@ -921,20 +921,22 @@ impl TriMesh { // NOTE: we can only compute connected components if the topology // has been computed too. So instead of making this method // public, the `.compute_topology` method has a boolean to - // compute the connected componets too. + // compute the connected components too. fn compute_connected_components(&mut self) { let topo = self.topology.as_ref().unwrap(); let mut face_colors = vec![u32::MAX; topo.faces.len()]; let mut grouped_faces = Vec::new(); let mut ranges = vec![0]; + let mut stack = vec![]; for i in 0..topo.faces.len() { if face_colors[i] == u32::MAX { - let mut stack = vec![i as u32]; let color = ranges.len() as u32 - 1; + face_colors[i] = color; + grouped_faces.push(i as u32); + stack.push(i as u32); while let Some(tri_id) = stack.pop() { - grouped_faces.push(tri_id); let eid = topo.faces[tri_id as usize].half_edge; let edge_a = &topo.half_edges[eid as usize]; let edge_b = &topo.half_edges[edge_a.next as usize];