diff options
| author | Sébastien Crozet <developer@crozet.re> | 2022-10-02 17:55:23 +0200 |
|---|---|---|
| committer | Sébastien Crozet <developer@crozet.re> | 2022-10-02 17:55:23 +0200 |
| commit | a8865296695db04969e9dbe806c489187ba20d0d (patch) | |
| tree | 6475d8bdd327d26ff576577e3d2a01018d887864 | |
| parent | 36e85d0708e53a01731dfa95a9a2b4792ef03fe2 (diff) | |
| download | rapier-a8865296695db04969e9dbe806c489187ba20d0d.tar.gz rapier-a8865296695db04969e9dbe806c489187ba20d0d.tar.bz2 rapier-a8865296695db04969e9dbe806c489187ba20d0d.zip | |
Fix warnings
| -rw-r--r-- | examples2d/character_controller2.rs | 2 | ||||
| -rw-r--r-- | src/control/character_controller.rs | 16 | ||||
| -rw-r--r-- | src_testbed/testbed.rs | 7 |
3 files changed, 21 insertions, 4 deletions
diff --git a/examples2d/character_controller2.rs b/examples2d/character_controller2.rs index 6f1ed92..ff500e9 100644 --- a/examples2d/character_controller2.rs +++ b/examples2d/character_controller2.rs @@ -131,7 +131,7 @@ pub fn init_world(testbed: &mut Testbed) { (run_state.time * 2.0).sin() * 2.0, (run_state.time * 5.0).sin() * 1.5 ]; - let angvel = run_state.time.sin() * 0.5; + // let angvel = run_state.time.sin() * 0.5; // Update the velocity-based kinematic body by setting its velocity. if let Some(platform) = physics.bodies.get_mut(platform_handle) { diff --git a/src/control/character_controller.rs b/src/control/character_controller.rs index 049aef8..b8f73bc 100644 --- a/src/control/character_controller.rs +++ b/src/control/character_controller.rs @@ -26,6 +26,8 @@ pub enum CharacterLength { } impl CharacterLength { + /// Returns `self` with its value changed by the closure `f` if `self` is the `Self::Absolute` + /// variant. pub fn map_absolute(self, f: impl FnOnce(Real) -> Real) -> Self { if let Self::Absolute(value) = self { Self::Absolute(f(value)) @@ -34,6 +36,16 @@ impl CharacterLength { } } + /// Returns `self` with its value changed by the closure `f` if `self` is the `Self::Relative` + /// variant. + pub fn map_relative(self, f: impl FnOnce(Real) -> Real) -> Self { + if let Self::Relative(value) = self { + Self::Relative(f(value)) + } else { + self + } + } + fn eval(self, value: Real) -> Real { match self { Self::Relative(x) => value * x, @@ -647,6 +659,10 @@ impl KinematicCharacterController { false } + /// For a given collision between a character and its environment, this method will apply + /// impulses to the rigid-bodies surrounding the character shape at the time of the collision. + /// Note that the impulse calculation is only approximate as it is not based on a global + /// constraints resolution scheme. pub fn solve_character_collision_impulses( &self, dt: Real, diff --git a/src_testbed/testbed.rs b/src_testbed/testbed.rs index 7de339c..b79175c 100644 --- a/src_testbed/testbed.rs +++ b/src_testbed/testbed.rs @@ -8,8 +8,8 @@ use crate::plugin::TestbedPlugin; use crate::{debug_render, ui}; use crate::{graphics::GraphicsManager, harness::RunState}; -use na::{self, Point2, Point3, Quaternion, Unit, Vector3}; -use rapier::control::{CharacterAutostep, CharacterLength, KinematicCharacterController}; +use na::{self, Point2, Point3, Vector3}; +use rapier::control::KinematicCharacterController; use rapier::dynamics::{ ImpulseJointSet, IntegrationParameters, MultibodyJointSet, RigidBodyActivation, RigidBodyHandle, RigidBodySet, @@ -135,6 +135,7 @@ pub struct TestbedGraphics<'a, 'b, 'c, 'd, 'e, 'f> { meshes: &'a mut Assets<Mesh>, materials: &'a mut Assets<BevyMaterial>, components: &'a mut Query<'b, 'f, (&'c mut Transform,)>, + #[allow(dead_code)] // Dead in 2D but not in 3D. camera_transform: GlobalTransform, camera: &'a mut OrbitCamera, } @@ -662,7 +663,7 @@ impl<'a, 'b, 'c, 'd, 'e, 'f> Testbed<'a, 'b, 'c, 'd, 'e, 'f> { .unwrap() .camera_transform .to_scale_rotation_translation(); - let rot = Unit::new_unchecked(Quaternion::new(rot.w, rot.x, rot.y, rot.z)); + let rot = na::Unit::new_unchecked(na::Quaternion::new(rot.w, rot.x, rot.y, rot.z)); let mut rot_x = rot * Vector::x(); let mut rot_z = rot * Vector::z(); rot_x.y = 0.0; |
