diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 8c312489d9..d34b4624e3 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -50,7 +50,6 @@ impl<'a> OutputEvents<'a> { impl From<&JoinData<'_>> for StateUpdate { fn from(data: &JoinData) -> Self { - common_base::prof_span!("StateUpdate::from"); StateUpdate { pos: *data.pos, vel: *data.vel, diff --git a/common/src/comp/ori.rs b/common/src/comp/ori.rs index 0ff078e40d..e042ccf695 100644 --- a/common/src/comp/ori.rs +++ b/common/src/comp/ori.rs @@ -165,13 +165,25 @@ impl Ori { Self(quat) } else { - // TODO: optimize this more (see asm) // if the direction is straight down, pitch up, or if straight up, pitch down if fw.z < 0.0 { self.pitched_up(FRAC_PI_2) } else { self.pitched_down(FRAC_PI_2) } + // TODO: test this alternative for speed and correctness compared to + // current impl + // + // removes a branch + // + // use core::f32::consts::FRAC_1_SQRT_2; + // let cos = FRAC_1_SQRT_2; + // let sin = -FRAC_1_SQRT_2 * fw.z.signum(); + // let axis = Vec3::unit_x(); + // let scalar = cos; + // let vector = sin * axis; + // Self((self.0 * Quaternion::from_scalar_and_vec3((scalar, + // vector))).normalized()) } } @@ -291,26 +303,8 @@ impl From for Ori { // Check that dir is not straight up/down // Uses a multiple of EPSILON to be safe let quat = if 1.0 - dir.z.abs() > f32::EPSILON * 4.0 { - // handle_orientation: mean: 168, median: 121 - // move_dir(no subspans): mean: 74, median: 42 - // move_dir: mean: 226, median: 197 - // mean: 105, median: 90 - // Compute rotation that will give an "upright" orientation (no rolling): - /* - // Rotation to get to this projected point from the default direction of y+ - let yaw = dir.xy().normalized().y.acos() * dir.x.signum() * -1.0; - // Rotation to then rotate up/down to the match the input direction - let pitch = dir.z.asin(); - - (Quaternion::rotation_z(yaw) * Quaternion::rotation_x(pitch)).normalized() - - // handle_orientation: mean: 167, median: 151 - // move_dir(no subspans): mean: 83, median: 83 - // move_dir: mean: 209, median: 186 - // mean: 60, median: 46 // Compute rotation that will give an "upright" orientation (no // rolling): - */ let xy_len = dir.xy().magnitude(); let xy_norm = dir.xy() / xy_len; // Rotation to get to this projected point from the default direction of y+ diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 5e35f043a5..6bfe1a8885 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -388,7 +388,6 @@ pub fn handle_orientation( efficiency: f32, dir_override: Option, ) { - common_base::prof_span!("handle_orientation"); // Direction is set to the override if one is provided, else if entity is // strafing or attacking the horiontal component of the look direction is used, // else the current horizontal movement direction is used diff --git a/common/systems/src/character_behavior.rs b/common/systems/src/character_behavior.rs index 2cdc3b602f..7f0db06778 100644 --- a/common/systems/src/character_behavior.rs +++ b/common/systems/src/character_behavior.rs @@ -17,7 +17,6 @@ use common::{ terrain::TerrainGrid, uid::Uid, }; -use common_base::prof_span; use common_ecs::{Job, Origin, Phase, System}; use std::time::Duration; @@ -129,7 +128,6 @@ impl<'a> System<'a> for Sys { ) .join() { - prof_span!("entity"); // Being dead overrides all other states if health.map_or(false, |h| h.is_dead) { // Do nothing