aboutsummaryrefslogtreecommitdiff
path: root/src/control/character_controller.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/control/character_controller.rs')
-rw-r--r--src/control/character_controller.rs16
1 files changed, 16 insertions, 0 deletions
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,