aboutsummaryrefslogtreecommitdiff
path: root/src/geometry/collider.rs
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2020-09-01 18:21:11 +0200
committerGitHub <noreply@github.com>2020-09-01 18:21:11 +0200
commitfef3a367d143bddde94e4f919a341cbf8d205293 (patch)
treec66a9aa0f8a4a0b6c54f069e291fa2f12cc16ea3 /src/geometry/collider.rs
parentcc05bad0410128b163e81e9f703ccb841f6a9a08 (diff)
parent763b9092422fd5677ffd47ec1b081951dc1c63e4 (diff)
downloadrapier-fef3a367d143bddde94e4f919a341cbf8d205293.tar.gz
rapier-fef3a367d143bddde94e4f919a341cbf8d205293.tar.bz2
rapier-fef3a367d143bddde94e4f919a341cbf8d205293.zip
Merge pull request #6 from dimforge/collider_removal
Add collider removal + fix rigid-bodies with multiple colliders
Diffstat (limited to 'src/geometry/collider.rs')
-rw-r--r--src/geometry/collider.rs42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/geometry/collider.rs b/src/geometry/collider.rs
index 2457212..aed76c8 100644
--- a/src/geometry/collider.rs
+++ b/src/geometry/collider.rs
@@ -3,7 +3,7 @@ use crate::geometry::{
Ball, Capsule, ColliderGraphIndex, Contact, Cuboid, HeightField, InteractionGraph, Polygon,
Proximity, Triangle, Trimesh,
};
-use crate::math::{Isometry, Point, Vector};
+use crate::math::{AngVector, Isometry, Point, Rotation, Vector};
use na::Point3;
use ncollide::bounding_volume::{HasBoundingVolume, AABB};
use num::Zero;
@@ -150,6 +150,7 @@ impl Collider {
}
/// The position of this collider expressed in the local-space of the rigid-body it is attached to.
+ #[deprecated(note = "use `.position_wrt_parent()` instead.")]
pub fn delta(&self) -> &Isometry<f32> {
&self.delta
}
@@ -159,6 +160,11 @@ impl Collider {
&self.position
}
+ /// The position of this collider wrt the body it is attached to.
+ pub fn position_wrt_parent(&self) -> &Isometry<f32> {
+ &self.delta
+ }
+
/// The density of this collider.
pub fn density(&self) -> f32 {
self.density
@@ -347,7 +353,41 @@ impl ColliderBuilder {
self
}
+ /// Sets the initial translation of the collider to be created,
+ /// relative to the rigid-body it is attached to.
+ #[cfg(feature = "dim2")]
+ pub fn translation(mut self, x: f32, y: f32) -> Self {
+ self.delta.translation.x = x;
+ self.delta.translation.y = y;
+ self
+ }
+
+ /// Sets the initial translation of the collider to be created,
+ /// relative to the rigid-body it is attached to.
+ #[cfg(feature = "dim3")]
+ pub fn translation(mut self, x: f32, y: f32, z: f32) -> Self {
+ self.delta.translation.x = x;
+ self.delta.translation.y = y;
+ self.delta.translation.z = z;
+ self
+ }
+
+ /// Sets the initial orientation of the collider to be created,
+ /// relative to the rigid-body it is attached to.
+ pub fn rotation(mut self, angle: AngVector<f32>) -> Self {
+ self.delta.rotation = Rotation::new(angle);
+ self
+ }
+
+ /// Sets the initial position (translation and orientation) of the collider to be created,
+ /// relative to the rigid-body it is attached to.
+ pub fn position(mut self, pos: Isometry<f32>) -> Self {
+ self.delta = pos;
+ self
+ }
+
/// Set the position of this collider in the local-space of the rigid-body it is attached to.
+ #[deprecated(note = "Use `.position` instead.")]
pub fn delta(mut self, delta: Isometry<f32>) -> Self {
self.delta = delta;
self