Skip to content

Commit

Permalink
Merge branch 'dimforge:master' into fix-voxel-dim-calc
Browse files Browse the repository at this point in the history
  • Loading branch information
robtfm authored Sep 10, 2023
2 parents 4ea142f + aefe2a6 commit 0a116a9
Show file tree
Hide file tree
Showing 20 changed files with 24 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/partitioning/qbvh/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ impl<LeafData: IndexedData> Qbvh<LeafData> {
workspace.to_sort.extend(0..workspace.orig_ids.len());
let root_id = NodeIndex::new(0, 0);

let mut indices = std::mem::replace(&mut workspace.to_sort, vec![]);
let mut indices = std::mem::take(&mut workspace.to_sort);
let (id, aabb) = self.do_recurse_rebalance(&mut indices, workspace, root_id, margin);
workspace.to_sort = indices;

Expand Down
2 changes: 1 addition & 1 deletion src/query/contact_manifolds/contact_manifold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl<ManifoldData, ContactData: Default + Copy> ContactManifold<ManifoldData, Co
#[cfg(feature = "dim2")]
let points = self.points.clone();
#[cfg(feature = "dim3")]
let points = std::mem::replace(&mut self.points, Vec::new());
let points = std::mem::take(&mut self.points);
self.points.clear();

ContactManifold {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub fn contact_manifolds_composite_shape_composite_shape<'a, ManifoldData, Conta

// Traverse qbvh1 first.
let ls_aabb2_1 = ls_aabb2.transform_by(&pos12).loosened(prediction);
let mut old_manifolds = std::mem::replace(manifolds, Vec::new());
let mut old_manifolds = std::mem::take(manifolds);

let mut leaf_fn1 = |leaf1: &u32| {
composite1.map_part_at(*leaf1, &mut |part_pos1, part_shape1| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub fn contact_manifolds_composite_shape_shape<ManifoldData, ContactData>(

// Traverse qbvh1 first.
let ls_aabb2_1 = shape2.compute_aabb(&pos12).loosened(prediction);
let mut old_manifolds = std::mem::replace(manifolds, Vec::new());
let mut old_manifolds = std::mem::take(manifolds);

let mut leaf1_fn = |leaf1: &u32| {
composite1.map_part_at(*leaf1, &mut |part_pos1, part_shape1| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn contact_manifold_halfspace_pfm<'a, ManifoldData, ContactData, S2>(

// We do this clone to perform contact tracking and transfer impulses.
// FIXME: find a more efficient way of doing this.
let old_manifold_points = std::mem::replace(&mut manifold.points, Default::default());
let old_manifold_points = std::mem::take(&mut manifold.points);

for i in 0..feature2.num_vertices {
let vtx2 = feature2.vertices[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub fn contact_manifolds_heightfield_composite_shape<ManifoldData, ContactData>(
let qbvh2 = composite2.qbvh();
let mut stack2 = Vec::new();
let ls_aabb2_1 = qbvh2.root_aabb().transform_by(pos12).loosened(prediction);
let mut old_manifolds = std::mem::replace(manifolds, Vec::new());
let mut old_manifolds = std::mem::take(manifolds);

heightfield1.map_elements_in_local_aabb(&ls_aabb2_1, &mut |leaf1, part1| {
#[cfg(feature = "dim2")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub fn contact_manifolds_heightfield_shape<ManifoldData, ContactData>(
*/
// TODO: somehow precompute the Aabb and reuse it?
let ls_aabb2 = shape2.compute_aabb(pos12).loosened(prediction);
let mut old_manifolds = std::mem::replace(manifolds, Vec::new());
let mut old_manifolds = std::mem::take(manifolds);

heightfield1.map_elements_in_local_aabb(&ls_aabb2, &mut |i, part1| {
#[cfg(feature = "dim2")]
Expand Down
2 changes: 1 addition & 1 deletion src/query/epa/epa2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ impl EPA {

let best_face = &self.faces[best_face_id.id];
let cpts = best_face.closest_points(&self.vertices);
return Some((cpts.0, cpts.1, best_face.normal));
Some((cpts.0, cpts.1, best_face.normal))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/query/epa/epa3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ impl EPA {

let best_face = &self.faces[best_face_id.id];
let points = best_face.closest_points(&self.vertices);
return Some((points.0, points.1, best_face.normal));
Some((points.0, points.1, best_face.normal))
}

fn compute_silhouette(&mut self, point: usize, id: usize, opp_pt_id: usize) {
Expand Down
2 changes: 1 addition & 1 deletion src/query/gjk/voronoi_simplex2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl VoronoiSimplex {

self.dim += 1;
self.vertices[self.dim] = pt;
return true;
true
}

/// Retrieves the barycentric coordinate associated to the `i`-th by the last call to `project_origin_and_reduce`.
Expand Down
2 changes: 1 addition & 1 deletion src/query/gjk/voronoi_simplex3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl VoronoiSimplex {

self.dim += 1;
self.vertices[self.dim] = pt;
return true;
true
}

/// Retrieves the barycentric coordinate associated to the `i`-th by the last call to `project_origin_and_reduce`.
Expand Down
4 changes: 2 additions & 2 deletions src/query/point/point_cylinder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ impl PointQuery for Cylinder {
if pt.y > self.half_height {
if planar_dist_from_basis_center <= self.radius {
let projection_on_top = Point::new(pt.coords.x, self.half_height, pt.coords.z);
return PointProjection::new(false, projection_on_top);
PointProjection::new(false, projection_on_top)
} else {
let projection_on_top_circle =
Point::new(proj2d[0], self.half_height, proj2d[1]);
return PointProjection::new(false, projection_on_top_circle);
PointProjection::new(false, projection_on_top_circle)
}
} else if pt.y < -self.half_height {
// Project on the bottom plane or the bottom circle.
Expand Down
4 changes: 2 additions & 2 deletions src/query/point/point_tetrahedron.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ impl PointQueryWithLocation for Tetrahedron {
return Some((proj, TetrahedronPointLocation::OnFace(i as u32, bcoords)));
}
}
return None;
None
}

// Face abc.
Expand Down Expand Up @@ -343,6 +343,6 @@ impl PointQueryWithLocation for Tetrahedron {
}

let proj = PointProjection::new(true, *pt);
return (proj, TetrahedronPointLocation::OnSolid);
(proj, TetrahedronPointLocation::OnSolid)
}
}
4 changes: 2 additions & 2 deletions src/query/point/point_triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl PointQueryWithLocation for Triangle {
return ProjectionInfo::OnBC;
}

return ProjectionInfo::OnFace(0, va, vb, vc);
ProjectionInfo::OnFace(0, va, vb, vc)
}
#[cfg(feature = "dim3")]
{
Expand Down Expand Up @@ -173,7 +173,7 @@ impl PointQueryWithLocation for Triangle {

let clockwise = if n.dot(ap) >= 0.0 { 0 } else { 1 };

return ProjectionInfo::OnFace(clockwise, va, vb, vc);
ProjectionInfo::OnFace(clockwise, va, vb, vc)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/shape/polyline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl Polyline {

if indices.len() == 0 {
// Polyline is empty, return empty Vec
return Vec::new();
Vec::new()
} else {
let mut components = Vec::new();

Expand Down
6 changes: 1 addition & 5 deletions src/shape/triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,7 @@ impl Triangle {
let c = vp.dot(&nb) * signed_clim.signum();
let clim = signed_clim.abs();

return c >= 0.0
&& c <= clim
&& b >= 0.0
&& b <= blim
&& c * blim + b * clim <= blim * clim;
c >= 0.0 && c <= clim && b >= 0.0 && b <= blim && c * blim + b * clim <= blim * clim
}

/// The normal of the given feature of this shape.
Expand Down
4 changes: 2 additions & 2 deletions src/shape/trimesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,8 @@ impl TriMesh {
.map(|idx| [idx[0] + base_id, idx[1] + base_id, idx[2] + base_id]),
);

let vertices = std::mem::replace(&mut self.vertices, Vec::new());
let indices = std::mem::replace(&mut self.indices, Vec::new());
let vertices = std::mem::take(&mut self.vertices);
let indices = std::mem::take(&mut self.indices);
*self = TriMesh::with_flags(vertices, indices, self.flags);
}

Expand Down
2 changes: 1 addition & 1 deletion src/transformation/convex_hull3/convex_hull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ fn fix_silhouette_topology(
}

let mut removing = None;
let old_facets_and_idx = std::mem::replace(out_facets_and_idx, Vec::new());
let old_facets_and_idx = std::mem::take(out_facets_and_idx);

for i in 0..old_facets_and_idx.len() {
let facet_id = (loop_start + i) % old_facets_and_idx.len();
Expand Down
2 changes: 1 addition & 1 deletion src/utils/point_in_poly2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ pub fn point_in_poly2d(pt: &Point2<Real>, poly: &[Point2<Real>]) -> bool {
}
}

return true;
true
}
}
2 changes: 1 addition & 1 deletion src/utils/segments_intersection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ fn parallel_intersection(
});
}

return None;
None
}

// Checks that `c` is in-between `a` and `b`.
Expand Down

0 comments on commit 0a116a9

Please sign in to comment.