feat: reduce the amount of duplicate work the broad-phase is doing for user changes and CCD + release v0.28.0 (#872)

* feat: reduce the amount of duplicate work the broad-phase is doing for user changes and CCD

* Release v0.28.0

* chore: fix warnings

* chore: clippy fixes

* chore: more clippy fixes
This commit is contained in:
Sébastien Crozet
2025-08-08 18:15:34 +02:00
committed by GitHub
parent 038eb34aba
commit 317322b31b
43 changed files with 351 additions and 328 deletions

View File

@@ -1,4 +1,4 @@
use crate::dynamics::{CoefficientCombineRule, MassProperties, RigidBodyHandle};
use crate::dynamics::{CoefficientCombineRule, MassProperties, RigidBodyHandle, RigidBodySet};
#[cfg(feature = "dim3")]
use crate::geometry::HeightFieldFlags;
use crate::geometry::{
@@ -9,7 +9,7 @@ use crate::geometry::{
use crate::math::{AngVector, DIM, Isometry, Point, Real, Rotation, Vector};
use crate::parry::transformation::vhacd::VHACDParameters;
use crate::pipeline::{ActiveEvents, ActiveHooks};
use crate::prelude::ColliderEnabled;
use crate::prelude::{ColliderEnabled, IntegrationParameters};
use na::Unit;
use parry::bounding_volume::{Aabb, BoundingVolume};
use parry::shape::{Shape, TriMeshBuilderError, TriMeshFlags};
@@ -457,6 +457,40 @@ impl Collider {
self.shape.compute_swept_aabb(&self.pos, next_position)
}
// TODO: we have a lot of different AABB computation functions
// We should group them somehow.
/// Computes the colliders AABB for usage in a broad-phase.
///
/// It takes into account soft-ccd, the contact skin, and the contact prediction.
pub fn compute_broad_phase_aabb(
&self,
params: &IntegrationParameters,
bodies: &RigidBodySet,
) -> Aabb {
// Take soft-ccd into account by growing the aabb.
let next_pose = self.parent.and_then(|p| {
let parent = bodies.get(p.handle)?;
(parent.soft_ccd_prediction() > 0.0).then(|| {
parent.predict_position_using_velocity_and_forces_with_max_dist(
params.dt,
parent.soft_ccd_prediction(),
) * p.pos_wrt_parent
})
});
let prediction_distance = params.prediction_distance();
let mut aabb = self.compute_collision_aabb(prediction_distance / 2.0);
if let Some(next_pose) = next_pose {
let next_aabb = self
.shape
.compute_aabb(&next_pose)
.loosened(self.contact_skin() + prediction_distance / 2.0);
aabb.merge(&next_aabb);
}
aabb
}
/// Compute the local-space mass properties of this collider.
pub fn mass_properties(&self) -> MassProperties {
self.mprops.mass_properties(&*self.shape)