feat: rename collision_skin to contact_skin

This commit is contained in:
Sébastien Crozet
2024-04-28 15:53:49 +02:00
committed by Sébastien Crozet
parent 97f7c1b4b2
commit 929aa6b925
6 changed files with 26 additions and 26 deletions

View File

@@ -362,7 +362,7 @@ impl BroadPhaseMultiSap {
let next_aabb = collider
.shape
.compute_aabb(next_position)
.loosened(collider.collision_skin() + prediction_distance / 2.0);
.loosened(collider.contact_skin() + prediction_distance / 2.0);
aabb.merge(&next_aabb);
}

View File

@@ -30,7 +30,7 @@ pub struct Collider {
pub(crate) material: ColliderMaterial,
pub(crate) flags: ColliderFlags,
pub(crate) bf_data: ColliderBroadPhaseData,
collision_skin: Real,
contact_skin: Real,
contact_force_event_threshold: Real,
/// User-defined data associated to this collider.
pub user_data: u128,
@@ -110,7 +110,7 @@ impl Collider {
bf_data: _bf_data, // Internal ids must not be overwritten.
contact_force_event_threshold,
user_data,
collision_skin,
contact_skin,
} = other;
if self.parent.is_none() {
@@ -125,7 +125,7 @@ impl Collider {
self.user_data = *user_data;
self.flags = *flags;
self.changes = ColliderChanges::all();
self.collision_skin = *collision_skin;
self.contact_skin = *contact_skin;
}
/// The physics hooks enabled for this collider.
@@ -159,13 +159,13 @@ impl Collider {
}
/// The collision skin of this collider.
pub fn collision_skin(&self) -> Real {
self.collision_skin
pub fn contact_skin(&self) -> Real {
self.contact_skin
}
/// Sets the collision skin of this collider.
pub fn set_collision_skin(&mut self, skin_thickness: Real) {
self.collision_skin = skin_thickness;
pub fn set_contact_skin(&mut self, skin_thickness: Real) {
self.contact_skin = skin_thickness;
}
/// The friction coefficient of this collider.
@@ -452,17 +452,17 @@ impl Collider {
/// Compute the axis-aligned bounding box of this collider.
///
/// This AABB doesnt take into account the colliders collision skin.
/// [`Collider::collision_skin`].
/// [`Collider::contact_skin`].
pub fn compute_aabb(&self) -> Aabb {
self.shape.compute_aabb(&self.pos)
}
/// Compute the axis-aligned bounding box of this collider, taking into account the
/// [`Collider::collision_skin`] and prediction distance.
/// [`Collider::contact_skin`] and prediction distance.
pub fn compute_collision_aabb(&self, prediction: Real) -> Aabb {
self.shape
.compute_aabb(&self.pos)
.loosened(self.collision_skin + prediction)
.loosened(self.contact_skin + prediction)
}
/// Compute the axis-aligned bounding box of this collider moving from its current position
@@ -520,7 +520,7 @@ pub struct ColliderBuilder {
/// The total force magnitude beyond which a contact force event can be emitted.
pub contact_force_event_threshold: Real,
/// An extract thickness around the collider shape to keep them further apart when in collision.
pub collision_skin: Real,
pub contact_skin: Real,
}
impl ColliderBuilder {
@@ -543,7 +543,7 @@ impl ColliderBuilder {
active_events: ActiveEvents::empty(),
enabled: true,
contact_force_event_threshold: 0.0,
collision_skin: 0.0,
contact_skin: 0.0,
}
}
@@ -982,8 +982,8 @@ impl ColliderBuilder {
/// it creates a small gap between colliding object (equal to the sum of their skin). If the
/// skin is sufficiently small, this might not be visually significant or can be hidden by the
/// rendering assets.
pub fn collision_skin(mut self, skin_thickness: Real) -> Self {
self.collision_skin = skin_thickness;
pub fn contact_skin(mut self, skin_thickness: Real) -> Self {
self.contact_skin = skin_thickness;
self
}
@@ -1034,7 +1034,7 @@ impl ColliderBuilder {
flags,
coll_type,
contact_force_event_threshold: self.contact_force_event_threshold,
collision_skin: self.collision_skin,
contact_skin: self.contact_skin,
user_data: self.user_data,
}
}

View File

@@ -117,7 +117,7 @@ pub struct ContactPair {
///
/// All contact manifold contain themselves contact points between the colliders.
/// Note that contact points in the contact manifold do not take into account the
/// [`Collider::collision_skin`] which only affects the constraint solver and the
/// [`Collider::contact_skin`] which only affects the constraint solver and the
/// [`SolverContact`].
pub manifolds: Vec<ContactManifold>,
/// Is there any active contact in this contact pair?

View File

@@ -898,7 +898,7 @@ impl NarrowPhase {
let pos12 = co1.pos.inv_mul(&co2.pos);
let collision_skin_sum = co1.collision_skin() + co2.collision_skin();
let contact_skin_sum = co1.contact_skin() + co2.contact_skin();
let soft_ccd_prediction1 = rb1.map(|rb| rb.soft_ccd_prediction()).unwrap_or(0.0);
let soft_ccd_prediction2 = rb2.map(|rb| rb.soft_ccd_prediction()).unwrap_or(0.0);
let effective_prediction_distance = if soft_ccd_prediction1 > 0.0 || soft_ccd_prediction2 > 0.0 {
@@ -918,9 +918,9 @@ impl NarrowPhase {
prediction_distance.max(
dt * (linvel1 - linvel2).norm()) + collision_skin_sum
dt * (linvel1 - linvel2).norm()) + contact_skin_sum
} else {
prediction_distance + collision_skin_sum
prediction_distance + contact_skin_sum
};
let _ = query_dispatcher.contact_manifolds(
@@ -969,7 +969,7 @@ impl NarrowPhase {
break;
}
let effective_contact_dist = contact.dist - co1.collision_skin() - co2.collision_skin();
let effective_contact_dist = contact.dist - co1.contact_skin() - co2.contact_skin();
let keep_solver_contact = effective_contact_dist < prediction_distance || {
let world_pt1 = world_pos1 * contact.local_p1;