diff options
| author | Crozet Sébastien <developer@crozet.re> | 2021-06-01 14:55:50 +0200 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2021-06-01 14:55:50 +0200 |
| commit | 5ef81cda406d796c5d188542b5bd9fbf4aefd4cf (patch) | |
| tree | 283ac6079bd1b51396bfc228addb23e5c38c07cb /src | |
| parent | 826ce5f014281fd04b7a18238f102f2591d0b255 (diff) | |
| download | rapier-5ef81cda406d796c5d188542b5bd9fbf4aefd4cf.tar.gz rapier-5ef81cda406d796c5d188542b5bd9fbf4aefd4cf.tar.bz2 rapier-5ef81cda406d796c5d188542b5bd9fbf4aefd4cf.zip | |
Add velocity-based kinematic bodies
Diffstat (limited to 'src')
| -rw-r--r-- | src/dynamics/rigid_body.rs | 15 | ||||
| -rw-r--r-- | src/dynamics/rigid_body_components.rs | 14 |
2 files changed, 21 insertions, 8 deletions
diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs index 07e362d..63c2221 100644 --- a/src/dynamics/rigid_body.rs +++ b/src/dynamics/rigid_body.rs @@ -275,7 +275,7 @@ impl RigidBody { /// /// A kinematic body can move freely but is not affected by forces. pub fn is_kinematic(&self) -> bool { - self.rb_type == RigidBodyType::Kinematic + self.rb_type.is_kinematic() } /// Is this rigid body static? @@ -527,9 +527,9 @@ impl RigidBody { } /// If this rigid body is kinematic, sets its future orientation after the next timestep integration. - pub fn set_next_kinematic_translation(&mut self, rotation: Rotation<Real>) { + pub fn set_next_kinematic_translation(&mut self, translation: Vector<Real>) { if self.is_kinematic() { - self.rb_pos.next_position.rotation = rotation; + self.rb_pos.next_position.translation = translation.into(); } } @@ -748,8 +748,13 @@ impl RigidBodyBuilder { } /// Initializes the builder of a new kinematic rigid body. - pub fn new_kinematic() -> Self { - Self::new(RigidBodyType::Kinematic) + pub fn new_kinematic_velocity_based() -> Self { + Self::new(RigidBodyType::KinematicVelocityBased) + } + + /// Initializes the builder of a new kinematic rigid body. + pub fn new_kinematic_position_based() -> Self { + Self::new(RigidBodyType::KinematicPositionBased) } /// Initializes the builder of a new dynamic rigid body. diff --git a/src/dynamics/rigid_body_components.rs b/src/dynamics/rigid_body_components.rs index b536d07..d1a00ce 100644 --- a/src/dynamics/rigid_body_components.rs +++ b/src/dynamics/rigid_body_components.rs @@ -57,13 +57,20 @@ pub enum RigidBodyType { Dynamic, /// A `RigidBodyType::Static` body cannot be affected by external forces. Static, - /// A `RigidBodyType::Kinematic` body cannot be affected by any external forces but can be controlled + /// A `RigidBodyType::KinematicPositionBased` body cannot be affected by any external forces but can be controlled /// by the user at the position level while keeping realistic one-way interaction with dynamic bodies. /// /// One-way interaction means that a kinematic body can push a dynamic body, but a kinematic body /// cannot be pushed by anything. In other words, the trajectory of a kinematic body can only be /// modified by the user and is independent from any contact or joint it is involved in. - Kinematic, + KinematicPositionBased, + /// A `RigidBodyType::KinematicVelocityBased` body cannot be affected by any external forces but can be controlled + /// by the user at the velocity level while keeping realistic one-way interaction with dynamic bodies. + /// + /// One-way interaction means that a kinematic body can push a dynamic body, but a kinematic body + /// cannot be pushed by anything. In other words, the trajectory of a kinematic body can only be + /// modified by the user and is independent from any contact or joint it is involved in. + KinematicVelocityBased, // Semikinematic, // A kinematic that performs automatic CCD with the static environment to avoid traversing it? // Disabled, } @@ -81,7 +88,8 @@ impl RigidBodyType { /// Is this rigid-body kinematic (i.e. can move but is unaffected by forces)? pub fn is_kinematic(self) -> bool { - self == RigidBodyType::Kinematic + self == RigidBodyType::KinematicPositionBased + || self == RigidBodyType::KinematicVelocityBased } } |
