aboutsummaryrefslogtreecommitdiff
path: root/src/dynamics
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2020-10-27 10:36:49 +0100
committerCrozet Sébastien <developer@crozet.re>2020-10-27 10:48:31 +0100
commitb5a1aaa4e5267da0f8b5b5fabb61d39cdb0e7a4e (patch)
treee69db1729a0a55b1af4b88da841cf2d3331efc7b /src/dynamics
parent93153f5d93358e83c8a4ca2b7195bf9aae95ffb9 (diff)
downloadrapier-b5a1aaa4e5267da0f8b5b5fabb61d39cdb0e7a4e.tar.gz
rapier-b5a1aaa4e5267da0f8b5b5fabb61d39cdb0e7a4e.tar.bz2
rapier-b5a1aaa4e5267da0f8b5b5fabb61d39cdb0e7a4e.zip
Add a 128-bits user-data attached to colliders and rigid-bodies.
Diffstat (limited to 'src/dynamics')
-rw-r--r--src/dynamics/rigid_body.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs
index 9fa5a8e..f4d47ce 100644
--- a/src/dynamics/rigid_body.rs
+++ b/src/dynamics/rigid_body.rs
@@ -54,6 +54,8 @@ pub struct RigidBody {
pub(crate) active_set_timestamp: u32,
/// The status of the body, governing how it is affected by external forces.
pub body_status: BodyStatus,
+ /// User-defined associated to this rigid-body.
+ pub user_data: u128,
}
impl Clone for RigidBody {
@@ -90,6 +92,7 @@ impl RigidBody {
active_set_offset: 0,
active_set_timestamp: 0,
body_status: BodyStatus::Dynamic,
+ user_data: 0,
}
}
@@ -342,6 +345,7 @@ pub struct RigidBodyBuilder {
angvel: AngVector<f32>,
body_status: BodyStatus,
can_sleep: bool,
+ user_data: u128,
}
impl RigidBodyBuilder {
@@ -353,6 +357,7 @@ impl RigidBodyBuilder {
angvel: na::zero(),
body_status,
can_sleep: true,
+ user_data: 0,
}
}
@@ -400,6 +405,12 @@ impl RigidBodyBuilder {
self
}
+ /// An arbitrary user-defined 128-bit integer associated to the rigid-bodies built by this builder.
+ pub fn user_data(mut self, data: u128) -> Self {
+ self.user_data = data;
+ self
+ }
+
/// Sets the initial linear velocity of the rigid-body to be created.
#[cfg(feature = "dim2")]
pub fn linvel(mut self, x: f32, y: f32) -> Self {
@@ -434,6 +445,7 @@ impl RigidBodyBuilder {
rb.linvel = self.linvel;
rb.angvel = self.angvel;
rb.body_status = self.body_status;
+ rb.user_data = self.user_data;
if !self.can_sleep {
rb.activation.threshold = -1.0;