From 1af86ef2f85748689906c6da24133e3c158c7b3c Mon Sep 17 00:00:00 2001
From: Joshua Barretto <joshua.s.barretto@gmail.com>
Date: Sat, 13 Mar 2021 16:43:01 +0000
Subject: [PATCH] Removed unnecessary matrix mul

---
 common/src/states/glide.rs |  3 +--
 common/sys/src/phys.rs     | 16 ++++++++--------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs
index 6655e5b440..04bfbb8fe6 100644
--- a/common/src/states/glide.rs
+++ b/common/src/states/glide.rs
@@ -9,8 +9,7 @@ use vek::Vec2;
 
 // Gravity is 9.81 * 4, so this makes gravity equal to .15
 const GLIDE_ANTIGRAV: f32 = crate::consts::GRAVITY * 0.90;
-const GLIDE_ACCEL: f32 = 6.0;
-const GLIDE_SPEED: f32 = 16.0;
+const GLIDE_ACCEL: f32 = 5.0;
 
 #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
 pub struct Data;
diff --git a/common/sys/src/phys.rs b/common/sys/src/phys.rs
index 041ad1b992..a7e10c92d1 100644
--- a/common/sys/src/phys.rs
+++ b/common/sys/src/phys.rs
@@ -411,7 +411,6 @@ impl<'a> PhysicsData<'a> {
                 )| {
                     // defer the writes of positions to allow an inner loop over terrain-like
                     // entities
-                    let mut pos = *pos;
                     let mut vel = *vel;
                     if sticky.is_some() && physics_state.on_surface().is_some() {
                         vel.0 = physics_state.ground_vel;
@@ -494,7 +493,7 @@ impl<'a> PhysicsData<'a> {
                             let radius = collider.get_radius() * scale * 0.1;
                             let (z_min, z_max) = collider.get_z_limits(scale);
 
-                            let mut cpos = pos;
+                            let mut cpos = *pos;
                             let cylinder = (radius, z_min, z_max);
                             cylinder_voxel_collision(
                                 cylinder,
@@ -522,7 +521,7 @@ impl<'a> PhysicsData<'a> {
                             let z_max = z_max.clamped(1.2, 1.95) * scale;
 
                             let cylinder = (radius, z_min, z_max);
-                            let mut cpos = pos;
+                            let mut cpos = *pos;
                             cylinder_voxel_collision(
                                 cylinder,
                                 &*read.terrain,
@@ -539,7 +538,7 @@ impl<'a> PhysicsData<'a> {
                             tgt_pos = cpos.0;
                         },
                         Collider::Point => {
-                            let mut pos = pos;
+                            let mut pos = *pos;
 
                             let (dist, block) = read
                                 .terrain
@@ -651,7 +650,7 @@ impl<'a> PhysicsData<'a> {
                                 let mut physics_state_delta = physics_state.clone();
                                 // deliberately don't use scale yet here, because the 11.0/0.8
                                 // thing is in the comp::Scale for visual reasons
-                                let mut cpos = pos;
+                                let mut cpos = *pos;
                                 let wpos = cpos.0;
                                 let transform_from =
                                     Mat4::<f32>::translation_3d(pos_other.0 - wpos)
@@ -691,10 +690,11 @@ impl<'a> PhysicsData<'a> {
                                 }
                                 physics_state.on_ground |= physics_state_delta.on_ground;
                                 physics_state.on_ceiling |= physics_state_delta.on_ceiling;
-                                physics_state.on_wall =
-                                    physics_state.on_wall.or(physics_state_delta
+                                physics_state.on_wall = physics_state.on_wall.or_else(|| {
+                                    physics_state_delta
                                         .on_wall
-                                        .map(|dir| ori_from.mul_direction(dir)));
+                                        .map(|dir| ori_from.mul_direction(dir))
+                                });
                                 physics_state
                                     .touch_entities
                                     .append(&mut physics_state_delta.touch_entities);