Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stability improvements + remove cuda support #192

Merged
merged 9 commits into from
Apr 28, 2024
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Change Log

## Unreleased

### Modified

- Remove CUDA support to break free from the toolchain restriction required by cust.
- Rework internal edges resolution using normal cones. This implies the modification of the
`SimdCompositeShape::map_part_at`, `TypedSimdCompositeShape::map_typed_part`, and
`TypedSimdCompositeShape::map_untyped_part` trait functions so that the closure argument takes
an extra argument for the (optional) normal constraints. This argument can be safely ignored
by user code unless applying the normal collection is relevant to your use-case.
- Contact manifolds will now retain all contacts (including the ones further than the specified `prediction`
distance) whenever any contact is actually closer than this `prediction` distance.
- Typo fix: renamed `TopologyError::BadAdjascentTrianglesOrientation` to `BadAdjacentTrianglesOrientation`.

### Fixed

- Fix contacts between convex shapes being occasionally ignored due to some rounding errors.
- Remove crash when entering unreachable code in non-linear TOI calculation.
- Fix accuracy issue in triangle-mesh center-of-mass calculation when the mesh isn’t manifold.

### Added

- Add `SdpMatrix2::inverse_and_get_determinant_unchecked`. This is useful for computing the
inverse in a AoSoA SIMD setting.
- Add `Aabb::intersects_moving_aabb` to perform a swept test between two moving aabbs.

## v0.13.8
### Added

Expand Down
5 changes: 1 addition & 4 deletions crates/parry2d-f64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ bytemuck-serialize = ["bytemuck", "nalgebra/convert-bytemuck"]
simd-stable = ["simba/wide", "simd-is-enabled"]
simd-nightly = ["simba/packed_simd", "simd-is-enabled"]
enhanced-determinism = ["simba/libm_force", "indexmap"]
cuda = ["cust_core", "cust", "nalgebra/cuda"]
parallel = ["rayon"]

# Do not enable this feature directly. It is automatically
Expand Down Expand Up @@ -60,9 +59,7 @@ cust_core = { version = "0.1", optional = true }
spade = { version = "2", optional = true } # Make this optional?
rayon = { version = "1", optional = true }
bytemuck = { version = "1", features = ["derive"], optional = true }

[target.'cfg(not(target_os = "cuda"))'.dependencies]
cust = { version = "0.3", optional = true }
log = "0.4"

[dev-dependencies]
simba = { version = "0.8", default-features = false, features = ["partial_fixed_point_support"] }
Expand Down
5 changes: 1 addition & 4 deletions crates/parry2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ bytemuck-serialize = ["bytemuck", "nalgebra/convert-bytemuck"]
simd-stable = ["simba/wide", "simd-is-enabled"]
simd-nightly = ["simba/packed_simd", "simd-is-enabled"]
enhanced-determinism = ["simba/libm_force", "indexmap"]
cuda = ["cust_core", "cust", "nalgebra/cuda"]
parallel = ["rayon"]

# Do not enable this feature directly. It is automatically
Expand Down Expand Up @@ -60,9 +59,7 @@ cust_core = { version = "0.1", optional = true }
spade = { version = "2", optional = true }
rayon = { version = "1", optional = true }
bytemuck = { version = "1", features = ["derive"], optional = true }

[target.'cfg(not(target_os = "cuda"))'.dependencies]
cust = { version = "0.3", optional = true }
log = "0.4"

[dev-dependencies]
simba = { version = "0.8", default-features = false, features = ["partial_fixed_point_support"] }
Expand Down
10 changes: 9 additions & 1 deletion crates/parry2d/tests/geometry/epa2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ fn cuboids_large_size_ratio_issue_181() {
let pos_ab = pos_a.inv_mul(&pos_b);
let mut manifold: ContactManifold<(), ()> = ContactManifold::new();
dispatcher
.contact_manifold_convex_convex(&pos_ab, &cuboid_a, &cuboid_b, 0.0, &mut manifold)
.contact_manifold_convex_convex(
&pos_ab,
&cuboid_a,
&cuboid_b,
None,
None,
0.0,
&mut manifold,
)
.unwrap();

if let Some(deepest) = manifold.find_deepest_contact() {
Expand Down
5 changes: 1 addition & 4 deletions crates/parry3d-f64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ bytemuck-serialize = ["bytemuck", "nalgebra/convert-bytemuck"]
simd-stable = ["simba/wide", "simd-is-enabled"]
simd-nightly = ["simba/packed_simd", "simd-is-enabled"]
enhanced-determinism = ["simba/libm_force", "indexmap"]
cuda = ["cust_core", "cust", "nalgebra/cuda"]
parallel = ["rayon"]

# Do not enable this feature directly. It is automatically
Expand Down Expand Up @@ -60,9 +59,7 @@ cust_core = { version = "0.1", optional = true }
spade = { version = "2", optional = true } # Make this optional?
rayon = { version = "1", optional = true }
bytemuck = { version = "1", features = ["derive"], optional = true }

[target.'cfg(not(target_os = "cuda"))'.dependencies]
cust = { version = "0.3", optional = true }
log = "0.4"

[dev-dependencies]
oorandom = "11"
Expand Down
5 changes: 1 addition & 4 deletions crates/parry3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ bytemuck-serialize = ["bytemuck", "nalgebra/convert-bytemuck"]
simd-stable = ["simba/wide", "simd-is-enabled"]
simd-nightly = ["simba/packed_simd", "simd-is-enabled"]
enhanced-determinism = ["simba/libm_force", "indexmap"]
cuda = ["cust_core", "cust", "nalgebra/cuda"]
parallel = ["rayon"]

# Do not enable this feature directly. It is automatically
Expand Down Expand Up @@ -61,9 +60,7 @@ cust_core = { version = "0.1", optional = true }
spade = { version = "2", optional = true } # Make this optional?
rayon = { version = "1", optional = true }
bytemuck = { version = "1", features = ["derive"], optional = true }

[target.'cfg(not(target_os = "cuda"))'.dependencies]
cust = { version = "0.3", optional = true }
log = "0.4"

[dev-dependencies]
oorandom = "11"
Expand Down
16 changes: 15 additions & 1 deletion src/bounding_volume/aabb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use num::Bounded;
#[cfg(not(feature = "std"))]
use na::ComplexField; // for .abs()

use crate::query::{Ray, RayCast};
#[cfg(feature = "rkyv")]
use rkyv::{bytecheck, CheckBytes};

Expand All @@ -22,7 +23,6 @@ use rkyv::{bytecheck, CheckBytes};
derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize, CheckBytes),
archive(as = "Self")
)]
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
#[derive(Debug, PartialEq, Copy, Clone)]
#[repr(C)]
pub struct Aabb {
Expand Down Expand Up @@ -201,6 +201,7 @@ impl Aabb {
BoundingSphere::new(center, radius)
}

/// Does this AABB contains a point expressed in the same coordinate frame as `self`?
#[inline]
pub fn contains_local_point(&self, point: &Point<Real>) -> bool {
for i in 0..DIM {
Expand All @@ -212,6 +213,19 @@ impl Aabb {
true
}

/// Does this AABB intersects an AABB `aabb2` moving at velocity `vel12` relative to `self`?
#[inline]
pub fn intersects_moving_aabb(&self, aabb2: &Self, vel12: Vector<Real>) -> bool {
// Minkowski sum.
let msum = Aabb {
mins: self.mins - aabb2.maxs.coords,
maxs: self.maxs - aabb2.mins.coords,
};
let ray = Ray::new(Point::origin(), vel12);

msum.intersects_local_ray(&ray, 1.0)
}

/// Computes the intersection of this `Aabb` and another one.
pub fn intersection(&self, other: &Aabb) -> Option<Aabb> {
let result = Aabb {
Expand Down
4 changes: 2 additions & 2 deletions src/bounding_volume/aabb_heightfield.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::bounding_volume::Aabb;
use crate::math::{Isometry, Real};
use crate::shape::{GenericHeightField, HeightFieldStorage};
use crate::shape::HeightField;

impl<Storage: HeightFieldStorage> GenericHeightField<Storage> {
impl HeightField {
/// Computes the world-space [`Aabb`] of this heightfield, transformed by `pos`.
#[inline]
pub fn aabb(&self, pos: &Isometry<Real>) -> Aabb {
Expand Down
4 changes: 2 additions & 2 deletions src/bounding_volume/bounding_sphere_heightfield.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::bounding_volume::BoundingSphere;
use crate::math::{Isometry, Real};
use crate::shape::{GenericHeightField, HeightFieldStorage};
use crate::shape::HeightField;

impl<Storage: HeightFieldStorage> GenericHeightField<Storage> {
impl HeightField {
/// Computes the world-space bounding sphere of this height-field, transformed by `pos`.
#[inline]
pub fn bounding_sphere(&self, pos: &Isometry<Real>) -> BoundingSphere {
Expand Down
2 changes: 2 additions & 0 deletions src/bounding_volume/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ mod aabb_convex_polygon;
mod aabb_convex_polyhedron;
mod aabb_cuboid;
mod aabb_halfspace;
#[cfg(feature = "std")]
mod aabb_heightfield;
mod aabb_support_map;
mod aabb_triangle;
Expand All @@ -45,6 +46,7 @@ mod bounding_sphere_cuboid;
#[cfg(feature = "dim3")]
mod bounding_sphere_cylinder;
mod bounding_sphere_halfspace;
#[cfg(feature = "std")]
mod bounding_sphere_heightfield;
#[cfg(feature = "std")]
mod bounding_sphere_polyline;
Expand Down
1 change: 0 additions & 1 deletion src/bounding_volume/simd_aabb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use simba::simd::{SimdPartialOrd, SimdValue};
derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize),
archive(check_bytes)
)]
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
pub struct SimdAabb {
/// The min coordinates of the Aabbs.
pub mins: Point<SimdReal>,
Expand Down
2 changes: 1 addition & 1 deletion src/mass_properties/mass_properties_trimesh3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub fn trimesh_signed_volume_and_center_of_mass(
vertices: &[Point<Real>],
indices: &[[u32; DIM]],
) -> (Real, Point<Real>) {
let geometric_center = Point::new(-10.0, -10.0, -10.0); // utils::center(vertices);
let geometric_center = crate::utils::center(vertices);

let mut res = Point::origin();
let mut vol = 0.0;
Expand Down
8 changes: 4 additions & 4 deletions src/partitioning/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

#[cfg(feature = "std")]
pub use self::qbvh::{
CenterDataSplitter, QbvhDataGenerator, QbvhNonOverlappingDataSplitter, QbvhUpdateWorkspace,
};
pub use self::qbvh::{
GenericQbvh, IndexedData, NodeIndex, Qbvh, QbvhNode, QbvhProxy, QbvhStorage, SimdNodeIndex,
CenterDataSplitter, IndexedData, NodeIndex, Qbvh, QbvhDataGenerator, QbvhNode,
QbvhNonOverlappingDataSplitter, QbvhProxy, QbvhUpdateWorkspace, SimdNodeIndex,
};
#[cfg(feature = "parallel")]
pub use self::visitor::{ParallelSimdSimultaneousVisitor, ParallelSimdVisitor};
Expand All @@ -16,7 +14,9 @@ pub use self::visitor::{

/// A quaternary bounding-volume-hierarchy.
#[deprecated(note = "Renamed to Qbvh")]
#[cfg(feature = "std")]
pub type SimdQbvh<T> = Qbvh<T>;

#[cfg(feature = "std")]
mod qbvh;
mod visitor;
10 changes: 1 addition & 9 deletions src/partitioning/qbvh/mod.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
#[cfg(feature = "std")]
pub use self::{
build::{CenterDataSplitter, QbvhDataGenerator, QbvhNonOverlappingDataSplitter},
update::QbvhUpdateWorkspace,
};

pub use self::qbvh::{
GenericQbvh, IndexedData, NodeIndex, Qbvh, QbvhNode, QbvhNodeFlags, QbvhProxy, SimdNodeIndex,
IndexedData, NodeIndex, Qbvh, QbvhNode, QbvhNodeFlags, QbvhProxy, SimdNodeIndex,
};
pub use self::storage::QbvhStorage;

mod qbvh;
mod storage;
mod utils;

#[cfg(feature = "std")]
mod build;
#[cfg(feature = "std")]
mod traversal;
#[cfg(not(feature = "std"))]
mod traversal_no_std;
#[cfg(feature = "std")]
mod update;
Loading
Loading