aboutsummaryrefslogtreecommitdiff
path: root/src/geometry/collider.rs
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2021-02-23 15:49:23 +0100
committerCrozet Sébastien <developer@crozet.re>2021-02-23 15:49:23 +0100
commitbabcab0bed23fadd23181ccc58aae34fb80d01d8 (patch)
treedcdb17f061860a93873659c55f029a8fbf5cbccc /src/geometry/collider.rs
parentf8bf96fdc8a0cfd7324d589736d41057a6c1bfe8 (diff)
downloadrapier-babcab0bed23fadd23181ccc58aae34fb80d01d8.tar.gz
rapier-babcab0bed23fadd23181ccc58aae34fb80d01d8.tar.bz2
rapier-babcab0bed23fadd23181ccc58aae34fb80d01d8.zip
Update the testbed to use PhysicsHooks.
Diffstat (limited to 'src/geometry/collider.rs')
-rw-r--r--src/geometry/collider.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/geometry/collider.rs b/src/geometry/collider.rs
index ce263f8..4be6d29 100644
--- a/src/geometry/collider.rs
+++ b/src/geometry/collider.rs
@@ -1,5 +1,5 @@
use crate::dynamics::{CoefficientCombineRule, MassProperties, RigidBodyHandle};
-use crate::geometry::{InteractionGroups, SharedShape};
+use crate::geometry::{InteractionGroups, SharedShape, SolverFlags};
use crate::math::{AngVector, Isometry, Point, Real, Rotation, Vector, DIM};
use crate::parry::transformation::vhacd::VHACDParameters;
use parry::bounding_volume::AABB;
@@ -50,6 +50,7 @@ pub struct Collider {
shape: SharedShape,
density: Real,
pub(crate) flags: ColliderFlags,
+ pub(crate) solver_flags: SolverFlags,
pub(crate) parent: RigidBodyHandle,
pub(crate) delta: Isometry<Real>,
pub(crate) position: Isometry<Real>,
@@ -159,6 +160,9 @@ pub struct ColliderBuilder {
pub delta: Isometry<Real>,
/// Is this collider a sensor?
pub is_sensor: bool,
+ /// Do we have to always call the contact modifier
+ /// on this collider?
+ pub modify_contacts: bool,
/// The user-data of the collider being built.
pub user_data: u128,
/// The collision groups for the collider being built.
@@ -182,6 +186,7 @@ impl ColliderBuilder {
solver_groups: InteractionGroups::all(),
friction_combine_rule: CoefficientCombineRule::Average,
restitution_combine_rule: CoefficientCombineRule::Average,
+ modify_contacts: false,
}
}
@@ -456,6 +461,13 @@ impl ColliderBuilder {
self
}
+ /// If set to `true` then the physics hooks will always run to modify
+ /// contacts involving this collider.
+ pub fn modify_contacts(mut self, modify_contacts: bool) -> Self {
+ self.modify_contacts = modify_contacts;
+ self
+ }
+
/// Sets the friction coefficient of the collider this builder will build.
pub fn friction(mut self, friction: Real) -> Self {
self.friction = friction;
@@ -534,6 +546,8 @@ impl ColliderBuilder {
flags = flags
.with_friction_combine_rule(self.friction_combine_rule)
.with_restitution_combine_rule(self.restitution_combine_rule);
+ let mut solver_flags = SolverFlags::default();
+ solver_flags.set(SolverFlags::MODIFY_SOLVER_CONTACTS, self.modify_contacts);
Collider {
shape: self.shape.clone(),
@@ -542,6 +556,7 @@ impl ColliderBuilder {
restitution: self.restitution,
delta: self.delta,
flags,
+ solver_flags,
parent: RigidBodyHandle::invalid(),
position: Isometry::identity(),
predicted_position: Isometry::identity(),