diff options
| author | Jan Nils Ferner <contact@jnferner.com> | 2023-01-27 23:10:14 +0100 |
|---|---|---|
| committer | Jan Nils Ferner <contact@jnferner.com> | 2023-01-27 23:10:14 +0100 |
| commit | f0563521a327811b5c09fdd194f115fcb2b928fc (patch) | |
| tree | 2ca7a4e334f500b705cf87ba46db5e29b9334fb8 /src/control | |
| parent | e25b61b4bb573e999b6dfe1102c5c0d157a0dfde (diff) | |
| download | rapier-f0563521a327811b5c09fdd194f115fcb2b928fc.tar.gz rapier-f0563521a327811b5c09fdd194f115fcb2b928fc.tar.bz2 rapier-f0563521a327811b5c09fdd194f115fcb2b928fc.zip | |
Remove redundant ground assignment
Diffstat (limited to 'src/control')
| -rw-r--r-- | src/control/character_controller.rs | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/control/character_controller.rs b/src/control/character_controller.rs index 6108487..876714f 100644 --- a/src/control/character_controller.rs +++ b/src/control/character_controller.rs @@ -409,12 +409,7 @@ impl KinematicCharacterController { .filter(|rb| rb.is_kinematic()); for m in &manifolds { - let normal1 = character_pos * m.local_n1; - let normal2 = -normal1; - - if normal1.dot(&self.up) <= -1.0e-5 { - grounded = true; - } + let normal = -(character_pos * m.local_n1); if let Some(kinematic_parent) = kinematic_parent { let mut num_active_contacts = 0; @@ -427,12 +422,12 @@ impl KinematicCharacterController { let target_vel = kinematic_parent.velocity_at_point(&contact_point); - let normal_target_mvt = target_vel.dot(&normal2) * dt; + let normal_target_mvt = target_vel.dot(&normal) * dt; let normal_current_mvt = - translation_remaining.dot(&normal2); + translation_remaining.dot(&normal); manifold_center += contact_point.coords; - *translation_remaining += normal2 + *translation_remaining += normal * (normal_target_mvt - normal_current_mvt).max(0.0); } } @@ -442,7 +437,7 @@ impl KinematicCharacterController { &(manifold_center / num_active_contacts as Real), ); let tangent_platform_mvt = - (target_vel - normal2 * target_vel.dot(&normal2)) * dt; + (target_vel - normal * target_vel.dot(&normal)) * dt; kinematic_friction_translation.zip_apply( &tangent_platform_mvt, |y, x| { |
