mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Remove timings and commented code (separate from the previous commit so we can keep these notes in the git history), add potentially better version of the straight up/down case for to_horizontal as a comment for testing in the future, remove fine grained spans
This commit is contained in:
parent
b0bd8cdb45
commit
aa1ffa9f61
@ -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,
|
||||
|
@ -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<Dir> 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+
|
||||
|
@ -388,7 +388,6 @@ pub fn handle_orientation(
|
||||
efficiency: f32,
|
||||
dir_override: Option<Dir>,
|
||||
) {
|
||||
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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user