From 33e4448542b7ddd6e6f35a3e82da9590619834fa Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 24 Nov 2020 18:28:24 -0600 Subject: [PATCH] Replaced every unnecssary powf in the entire codebase with either powi or sqrt. --- common/src/path.rs | 6 +- common/src/states/climb.rs | 2 +- common/src/states/glide.rs | 6 +- common/src/states/utils.rs | 18 +- common/src/sys/agent.rs | 167 +++++++++--------- common/src/sys/stats.rs | 2 +- server/src/events/inventory_manip.rs | 3 +- server/src/rtsim/entity.rs | 2 +- server/src/sys/entity_sync.rs | 2 +- voxygen/src/anim/src/biped_large/alpha.rs | 8 +- voxygen/src/anim/src/biped_large/beta.rs | 2 +- voxygen/src/anim/src/biped_large/charge.rs | 23 ++- voxygen/src/anim/src/biped_large/dash.rs | 6 +- voxygen/src/anim/src/biped_large/run.rs | 22 +-- voxygen/src/anim/src/biped_large/shoot.rs | 2 +- voxygen/src/anim/src/biped_large/spin.rs | 4 +- voxygen/src/anim/src/biped_large/spinmelee.rs | 2 +- voxygen/src/anim/src/biped_large/wield.rs | 16 +- voxygen/src/anim/src/character/alpha.rs | 17 +- voxygen/src/anim/src/character/beta.rs | 2 +- voxygen/src/anim/src/character/charge.rs | 23 ++- voxygen/src/anim/src/character/chargeswing.rs | 7 +- voxygen/src/anim/src/character/climb.rs | 7 +- voxygen/src/anim/src/character/dance.rs | 7 +- voxygen/src/anim/src/character/dash.rs | 11 +- voxygen/src/anim/src/character/run.rs | 12 +- voxygen/src/anim/src/character/shoot.rs | 2 +- voxygen/src/anim/src/character/sneak.rs | 15 +- voxygen/src/anim/src/character/spin.rs | 8 +- voxygen/src/anim/src/character/spinmelee.rs | 2 +- voxygen/src/anim/src/character/swim.rs | 8 +- voxygen/src/anim/src/character/swimwield.rs | 15 +- voxygen/src/anim/src/character/wield.rs | 11 +- voxygen/src/anim/src/dragon/run.rs | 4 +- voxygen/src/anim/src/golem/alpha.rs | 4 +- voxygen/src/anim/src/golem/run.rs | 16 +- voxygen/src/anim/src/golem/shockwave.rs | 3 +- voxygen/src/anim/src/quadruped_low/beta.rs | 4 +- voxygen/src/anim/src/quadruped_low/breathe.rs | 2 +- voxygen/src/anim/src/quadruped_low/dash.rs | 7 +- voxygen/src/anim/src/quadruped_low/run.rs | 25 +-- .../src/anim/src/quadruped_low/tailwhip.rs | 4 +- .../src/anim/src/quadruped_medium/alpha.rs | 2 +- voxygen/src/anim/src/quadruped_medium/beta.rs | 4 +- voxygen/src/anim/src/quadruped_medium/dash.rs | 15 +- voxygen/src/anim/src/quadruped_medium/hoof.rs | 2 +- .../anim/src/quadruped_medium/leapmelee.rs | 2 +- voxygen/src/anim/src/quadruped_medium/run.rs | 8 +- voxygen/src/anim/src/quadruped_small/alpha.rs | 4 +- voxygen/src/anim/src/theropod/alpha.rs | 4 +- voxygen/src/anim/src/theropod/beta.rs | 4 +- voxygen/src/anim/src/theropod/run.rs | 2 +- voxygen/src/audio/ambient.rs | 2 +- voxygen/src/scene/figure/mod.rs | 6 +- voxygen/src/scene/mod.rs | 4 +- voxygen/src/scene/terrain.rs | 12 +- world/examples/turb.rs | 2 +- world/src/block/mod.rs | 6 +- world/src/civ/mod.rs | 2 +- world/src/column/mod.rs | 6 +- world/src/layer/mod.rs | 6 +- world/src/lib.rs | 2 +- world/src/sim/erosion.rs | 2 +- world/src/sim/map.rs | 2 +- world/src/sim/mod.rs | 10 +- world/src/sim/way.rs | 4 +- world/src/site/dungeon/mod.rs | 11 +- .../settlement/building/archetype/keep.rs | 6 +- world/src/site/settlement/mod.rs | 4 +- world/src/util/fast_noise.rs | 2 +- 70 files changed, 276 insertions(+), 369 deletions(-) diff --git a/common/src/path.rs b/common/src/path.rs index 67de327692..07eb1da4c2 100644 --- a/common/src/path.rs +++ b/common/src/path.rs @@ -131,7 +131,7 @@ impl Route { // Determine whether we're close enough to the next to to consider it completed let dist_sqrd = pos.xy().distance_squared(closest_tgt.xy()); if dist_sqrd - < traversal_cfg.node_tolerance.powf(2.0) * if be_precise { 0.25 } else { 1.0 } + < traversal_cfg.node_tolerance.powi(2) * if be_precise { 0.25 } else { 1.0 } && (((pos.z - closest_tgt.z > 1.2 || (pos.z - closest_tgt.z > -0.2 && traversal_cfg.on_ground)) && (pos.z - closest_tgt.z < 1.2 || (pos.z - closest_tgt.z < 2.9 && vel.z < -0.05)) && vel.z <= 0.0 @@ -272,7 +272,7 @@ impl Route { let straight_factor = next_dir .dot(vel.xy().try_normalized().unwrap_or(next_dir)) .max(0.0) - .powf(2.0); + .powi(2); let bez = CubicBezier2 { start: pos.xy(), @@ -347,7 +347,7 @@ impl Chaser { .map(|e| e.map(|e| e as f32 + 0.5)) .unwrap_or(tgt); if ((pos - end) * Vec3::new(1.0, 1.0, 2.0)).magnitude_squared() - < traversal_cfg.min_tgt_dist.powf(2.0) + < traversal_cfg.min_tgt_dist.powi(2) { self.route = None; return None; diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index 4bf3cf71b2..cd8d928649 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -44,7 +44,7 @@ impl CharacterBehavior for Data { // Move player update.vel.0 += Vec2::broadcast(data.dt.0) * data.inputs.move_dir - * if update.vel.0.magnitude_squared() < CLIMB_SPEED.powf(2.0) { + * if update.vel.0.magnitude_squared() < CLIMB_SPEED.powi(2) { HUMANOID_CLIMB_ACCEL } else { 0.0 diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index 864dae2f20..249e65f8b8 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -41,7 +41,7 @@ impl CharacterBehavior for Data { // Move player according to movement direction vector update.vel.0 += Vec2::broadcast(data.dt.0) * data.inputs.move_dir - * if data.vel.0.magnitude_squared() < GLIDE_SPEED.powf(2.0) { + * if data.vel.0.magnitude_squared() < GLIDE_SPEED.powi(2) { GLIDE_ACCEL } else { 0.0 @@ -52,10 +52,10 @@ impl CharacterBehavior for Data { update.ori.0 = Dir::slerp_to_vec3(update.ori.0, ori_dir.into(), 2.0 * data.dt.0); // Apply Glide antigrav lift - if Vec2::::from(update.vel.0).magnitude_squared() < GLIDE_SPEED.powf(2.0) + if Vec2::::from(update.vel.0).magnitude_squared() < GLIDE_SPEED.powi(2) && update.vel.0.z < 0.0 { - let lift = GLIDE_ANTIGRAV + update.vel.0.z.abs().powf(2.0) * 0.15; + let lift = GLIDE_ANTIGRAV + update.vel.0.z.abs().powi(2) * 0.15; update.vel.0.z += data.dt.0 * lift * (Vec2::::from(update.vel.0).magnitude() * 0.075) diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 54a7bfbd95..a6b1844638 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -94,13 +94,13 @@ impl Body { // Note: we assume no air (this is fine, current physics // uses max(air_drag, ground_drag)). // Derived via... - // v = (v + dv / 30) * (1 - drag).powf(2) (accel cancels drag) - // => 1 = (1 + (dv / 30) / v) * (1 - drag).powf(2) - // => 1 / (1 - drag).powf(2) = 1 + (dv / 30) / v - // => 1 / (1 - drag).powf(2) - 1 = (dv / 30) / v - // => 1 / (1 / (1 - drag).powf(2) - 1) = v / (dv / 30) - // => (dv / 30) / (1 / (1 - drag).powf(2) - 1) = v - let v = (-self.base_accel() / 30.0) / ((1.0 - FRIC_GROUND).powf(2.0) - 1.0); + // v = (v + dv / 30) * (1 - drag).powi(2) (accel cancels drag) + // => 1 = (1 + (dv / 30) / v) * (1 - drag).powi(2) + // => 1 / (1 - drag).powi(2) = 1 + (dv / 30) / v + // => 1 / (1 - drag).powi(2) - 1 = (dv / 30) / v + // => 1 / (1 / (1 - drag).powi(2) - 1) = v / (dv / 30) + // => (dv / 30) / (1 / (1 - drag).powi(2) - 1) = v + let v = (-self.base_accel() / 30.0) / ((1.0 - FRIC_GROUND).powi(2) - 1.0); debug_assert!(v >= 0.0, "Speed must be positive!"); v } @@ -251,7 +251,7 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32, depth: // Update velocity update.vel.0 += Vec2::broadcast(data.dt.0) * data.inputs.move_dir - * if update.vel.0.magnitude_squared() < BASE_HUMANOID_WATER_SPEED.powf(2.0) { + * if update.vel.0.magnitude_squared() < BASE_HUMANOID_WATER_SPEED.powi(2) { BASE_HUMANOID_WATER_ACCEL } else { 0.0 @@ -268,7 +268,7 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32, depth: * data .inputs .move_z - .clamped(-1.0, depth.clamped(0.0, 1.0).powf(3.0))) + .clamped(-1.0, depth.clamped(0.0, 1.0).powi(3))) .min(BASE_HUMANOID_WATER_SPEED); } diff --git a/common/src/sys/agent.rs b/common/src/sys/agent.rs index e2b29aadaa..8d9335ac05 100644 --- a/common/src/sys/agent.rs +++ b/common/src/sys/agent.rs @@ -269,7 +269,7 @@ impl<'a> System<'a> for Sys { 0.0 }; - if bearing.magnitude_squared() > 0.5f32.powf(2.0) { + if bearing.magnitude_squared() > 0.5f32.powi(2) { inputs.move_dir = *bearing * 0.65; } @@ -471,7 +471,7 @@ impl<'a> System<'a> for Sys { controller.actions.push(ControlAction::Unwield); } } - if dist_sqrd < MAX_FLEE_DIST.powf(2.0) { + if dist_sqrd < MAX_FLEE_DIST.powi(2) { if let Some((bearing, speed)) = chaser.chase( &*terrain, pos.0, @@ -501,13 +501,13 @@ impl<'a> System<'a> for Sys { // depending on the distance from the agent to the target match tactic { Tactic::Melee => { - if dist_sqrd < (MIN_ATTACK_DIST * scale).powf(2.0) { + if dist_sqrd < (MIN_ATTACK_DIST * scale).powi(2) { inputs.primary.set_state(true); inputs.move_dir = Vec2::zero(); - } else if dist_sqrd < MAX_CHASE_DIST.powf(2.0) - || (dist_sqrd < SIGHT_DIST.powf(2.0) && !*been_close) + } else if dist_sqrd < MAX_CHASE_DIST.powi(2) + || (dist_sqrd < SIGHT_DIST.powi(2) && !*been_close) { - if dist_sqrd < MAX_CHASE_DIST.powf(2.0) { + if dist_sqrd < MAX_CHASE_DIST.powi(2) { *been_close = true; } if let Some((bearing, speed)) = chaser.chase( @@ -539,7 +539,7 @@ impl<'a> System<'a> for Sys { } }, Tactic::Axe => { - if dist_sqrd < (MIN_ATTACK_DIST * scale).powf(2.0) { + if dist_sqrd < (MIN_ATTACK_DIST * scale).powi(2) { inputs.move_dir = Vec2::zero(); if *powerup > 6.0 { inputs.secondary.set_state(false); @@ -556,10 +556,10 @@ impl<'a> System<'a> for Sys { inputs.primary.set_state(true); *powerup += dt.0; } - } else if dist_sqrd < MAX_CHASE_DIST.powf(2.0) - || (dist_sqrd < SIGHT_DIST.powf(2.0) && !*been_close) + } else if dist_sqrd < MAX_CHASE_DIST.powi(2) + || (dist_sqrd < SIGHT_DIST.powi(2) && !*been_close) { - if dist_sqrd < MAX_CHASE_DIST.powf(2.0) { + if dist_sqrd < MAX_CHASE_DIST.powi(2) { *been_close = true; } if let Some((bearing, speed)) = chaser.chase( @@ -580,7 +580,7 @@ impl<'a> System<'a> for Sys { inputs.jump.set_state(bearing.z > 1.5); inputs.move_z = bearing.z; } - if dist_sqrd < 16.0f32.powf(2.0) + if dist_sqrd < 16.0f32.powi(2) && thread_rng().gen::() < 0.02 { inputs.roll.set_state(true); @@ -590,7 +590,7 @@ impl<'a> System<'a> for Sys { } }, Tactic::Hammer => { - if dist_sqrd < (MIN_ATTACK_DIST * scale).powf(2.0) { + if dist_sqrd < (MIN_ATTACK_DIST * scale).powi(2) { inputs.move_dir = Vec2::zero(); if *powerup > 4.0 { inputs.secondary.set_state(false); @@ -605,10 +605,10 @@ impl<'a> System<'a> for Sys { inputs.primary.set_state(true); *powerup += dt.0; } - } else if dist_sqrd < MAX_CHASE_DIST.powf(2.0) - || (dist_sqrd < SIGHT_DIST.powf(2.0) && !*been_close) + } else if dist_sqrd < MAX_CHASE_DIST.powi(2) + || (dist_sqrd < SIGHT_DIST.powi(2) && !*been_close) { - if dist_sqrd < MAX_CHASE_DIST.powf(2.0) { + if dist_sqrd < MAX_CHASE_DIST.powi(2) { *been_close = true; } if let Some((bearing, speed)) = chaser.chase( @@ -643,7 +643,7 @@ impl<'a> System<'a> for Sys { inputs.move_z = bearing.z; } } - if dist_sqrd < 16.0f32.powf(2.0) + if dist_sqrd < 16.0f32.powi(2) && thread_rng().gen::() < 0.02 { inputs.roll.set_state(true); @@ -653,7 +653,7 @@ impl<'a> System<'a> for Sys { } }, Tactic::Sword => { - if dist_sqrd < (MIN_ATTACK_DIST * scale).powf(2.0) { + if dist_sqrd < (MIN_ATTACK_DIST * scale).powi(2) { inputs.move_dir = Vec2::zero(); if *powerup < 2.0 && energy.current() > 600 { inputs.ability3.set_state(true); @@ -664,10 +664,10 @@ impl<'a> System<'a> for Sys { inputs.primary.set_state(true); *powerup += dt.0; } - } else if dist_sqrd < MAX_CHASE_DIST.powf(2.0) - || (dist_sqrd < SIGHT_DIST.powf(2.0) && !*been_close) + } else if dist_sqrd < MAX_CHASE_DIST.powi(2) + || (dist_sqrd < SIGHT_DIST.powi(2) && !*been_close) { - if dist_sqrd < MAX_CHASE_DIST.powf(2.0) { + if dist_sqrd < MAX_CHASE_DIST.powi(2) { *been_close = true; } if let Some((bearing, speed)) = chaser.chase( @@ -702,7 +702,7 @@ impl<'a> System<'a> for Sys { inputs.move_z = bearing.z; } } - if dist_sqrd < 16.0f32.powf(2.0) + if dist_sqrd < 16.0f32.powi(2) && thread_rng().gen::() < 0.02 { inputs.roll.set_state(true); @@ -712,12 +712,12 @@ impl<'a> System<'a> for Sys { } }, Tactic::Bow => { - if dist_sqrd < (2.0 * MIN_ATTACK_DIST * scale).powf(2.0) { + if dist_sqrd < (2.0 * MIN_ATTACK_DIST * scale).powi(2) { inputs.roll.set_state(true); - } else if dist_sqrd < MAX_CHASE_DIST.powf(2.0) - || (dist_sqrd < SIGHT_DIST.powf(2.0) && !*been_close) + } else if dist_sqrd < MAX_CHASE_DIST.powi(2) + || (dist_sqrd < SIGHT_DIST.powi(2) && !*been_close) { - if dist_sqrd < MAX_CHASE_DIST.powf(2.0) { + if dist_sqrd < MAX_CHASE_DIST.powi(2) { *been_close = true; } if let Some((bearing, speed)) = chaser.chase( @@ -768,7 +768,7 @@ impl<'a> System<'a> for Sys { inputs.move_z = bearing.z; } } - if dist_sqrd < 16.0f32.powf(2.0) + if dist_sqrd < 16.0f32.powi(2) && thread_rng().gen::() < 0.02 { inputs.roll.set_state(true); @@ -778,10 +778,10 @@ impl<'a> System<'a> for Sys { } }, Tactic::Staff => { - if dist_sqrd < (MIN_ATTACK_DIST * scale).powf(2.0) { + if dist_sqrd < (MIN_ATTACK_DIST * scale).powi(2) { inputs.roll.set_state(true); } else if dist_sqrd - < (5.0 * MIN_ATTACK_DIST * scale).powf(2.0) + < (5.0 * MIN_ATTACK_DIST * scale).powi(2) { if *powerup < 1.5 { inputs.move_dir = (tgt_pos.0 - pos.0) @@ -809,10 +809,10 @@ impl<'a> System<'a> for Sys { } else { inputs.primary.set_state(true); } - } else if dist_sqrd < MAX_CHASE_DIST.powf(2.0) - || (dist_sqrd < SIGHT_DIST.powf(2.0) && !*been_close) + } else if dist_sqrd < MAX_CHASE_DIST.powi(2) + || (dist_sqrd < SIGHT_DIST.powi(2) && !*been_close) { - if dist_sqrd < MAX_CHASE_DIST.powf(2.0) { + if dist_sqrd < MAX_CHASE_DIST.powi(2) { *been_close = true; } if let Some((bearing, speed)) = chaser.chase( @@ -845,7 +845,7 @@ impl<'a> System<'a> for Sys { inputs.move_z = bearing.z; } } - if dist_sqrd < 16.0f32.powf(2.0) + if dist_sqrd < 16.0f32.powi(2) && thread_rng().gen::() < 0.02 { inputs.roll.set_state(true); @@ -855,13 +855,13 @@ impl<'a> System<'a> for Sys { } }, Tactic::StoneGolemBoss => { - if dist_sqrd < (MIN_ATTACK_DIST * scale).powf(2.0) { + if dist_sqrd < (MIN_ATTACK_DIST * scale).powi(2) { inputs.move_dir = Vec2::zero(); inputs.primary.set_state(true); - } else if dist_sqrd < MAX_CHASE_DIST.powf(2.0) - || (dist_sqrd < SIGHT_DIST.powf(2.0) && !*been_close) + } else if dist_sqrd < MAX_CHASE_DIST.powi(2) + || (dist_sqrd < SIGHT_DIST.powi(2) && !*been_close) { - if dist_sqrd < MAX_CHASE_DIST.powf(2.0) { + if dist_sqrd < MAX_CHASE_DIST.powi(2) { *been_close = true; } if let Some((bearing, speed)) = chaser.chase( @@ -904,13 +904,13 @@ impl<'a> System<'a> for Sys { radius, circle_time, } => { - if dist_sqrd < (MIN_ATTACK_DIST * scale).powf(2.0) + if dist_sqrd < (MIN_ATTACK_DIST * scale).powi(2) && thread_rng().gen_bool(0.5) { inputs.move_dir = Vec2::zero(); inputs.primary.set_state(true); } else if dist_sqrd - < (radius as f32 * MIN_ATTACK_DIST * scale).powf(2.0) + < (radius as f32 * MIN_ATTACK_DIST * scale).powi(2) { inputs.move_dir = (pos.0 - tgt_pos.0) .xy() @@ -918,10 +918,9 @@ impl<'a> System<'a> for Sys { .unwrap_or(Vec2::unit_y()); } else if dist_sqrd < ((radius as f32 + 1.0) * MIN_ATTACK_DIST * scale) - .powf(2.0) + .powi(2) && dist_sqrd - > (radius as f32 * MIN_ATTACK_DIST * scale) - .powf(2.0) + > (radius as f32 * MIN_ATTACK_DIST * scale).powi(2) { if *powerup < circle_time as f32 { inputs.move_dir = (tgt_pos.0 - pos.0) @@ -946,10 +945,10 @@ impl<'a> System<'a> for Sys { } else { *powerup = 0.0; } - } else if dist_sqrd < MAX_CHASE_DIST.powf(2.0) - || (dist_sqrd < SIGHT_DIST.powf(2.0) && !*been_close) + } else if dist_sqrd < MAX_CHASE_DIST.powi(2) + || (dist_sqrd < SIGHT_DIST.powi(2) && !*been_close) { - if dist_sqrd < MAX_CHASE_DIST.powf(2.0) { + if dist_sqrd < MAX_CHASE_DIST.powi(2) { *been_close = true; } if let Some((bearing, speed)) = chaser.chase( @@ -975,16 +974,16 @@ impl<'a> System<'a> for Sys { } }, Tactic::QuadLowRanged => { - if dist_sqrd < (5.0 * MIN_ATTACK_DIST * scale).powf(2.0) { + if dist_sqrd < (5.0 * MIN_ATTACK_DIST * scale).powi(2) { inputs.move_dir = (tgt_pos.0 - pos.0) .xy() .try_normalized() .unwrap_or(Vec2::unit_y()); inputs.primary.set_state(true); - } else if dist_sqrd < MAX_CHASE_DIST.powf(2.0) - || (dist_sqrd < SIGHT_DIST.powf(2.0) && !*been_close) + } else if dist_sqrd < MAX_CHASE_DIST.powi(2) + || (dist_sqrd < SIGHT_DIST.powi(2) && !*been_close) { - if dist_sqrd < MAX_CHASE_DIST.powf(2.0) { + if dist_sqrd < MAX_CHASE_DIST.powi(2) { *been_close = true; } if let Some((bearing, speed)) = chaser.chase( @@ -1028,7 +1027,7 @@ impl<'a> System<'a> for Sys { } }, Tactic::TailSlap => { - if dist_sqrd < (1.5 * MIN_ATTACK_DIST * scale).powf(2.0) { + if dist_sqrd < (1.5 * MIN_ATTACK_DIST * scale).powi(2) { if *powerup > 4.0 { inputs.primary.set_state(false); *powerup = 0.0; @@ -1044,10 +1043,10 @@ impl<'a> System<'a> for Sys { .try_normalized() .unwrap_or(Vec2::unit_y()) * 0.1; - } else if dist_sqrd < MAX_CHASE_DIST.powf(2.0) - || (dist_sqrd < SIGHT_DIST.powf(2.0) && !*been_close) + } else if dist_sqrd < MAX_CHASE_DIST.powi(2) + || (dist_sqrd < SIGHT_DIST.powi(2) && !*been_close) { - if dist_sqrd < MAX_CHASE_DIST.powf(2.0) { + if dist_sqrd < MAX_CHASE_DIST.powi(2) { *been_close = true; } if let Some((bearing, speed)) = chaser.chase( @@ -1073,12 +1072,12 @@ impl<'a> System<'a> for Sys { } }, Tactic::QuadLowQuick => { - if dist_sqrd < (1.5 * MIN_ATTACK_DIST * scale).powf(2.0) { + if dist_sqrd < (1.5 * MIN_ATTACK_DIST * scale).powi(2) { inputs.move_dir = Vec2::zero(); inputs.secondary.set_state(true); } else if dist_sqrd - < (3.0 * MIN_ATTACK_DIST * scale).powf(2.0) - && dist_sqrd > (2.0 * MIN_ATTACK_DIST * scale).powf(2.0) + < (3.0 * MIN_ATTACK_DIST * scale).powi(2) + && dist_sqrd > (2.0 * MIN_ATTACK_DIST * scale).powi(2) { inputs.primary.set_state(true); inputs.move_dir = (tgt_pos.0 - pos.0) @@ -1086,10 +1085,10 @@ impl<'a> System<'a> for Sys { .rotated_z(-0.47 * PI) .try_normalized() .unwrap_or(Vec2::unit_y()); - } else if dist_sqrd < MAX_CHASE_DIST.powf(2.0) - || (dist_sqrd < SIGHT_DIST.powf(2.0) && !*been_close) + } else if dist_sqrd < MAX_CHASE_DIST.powi(2) + || (dist_sqrd < SIGHT_DIST.powi(2) && !*been_close) { - if dist_sqrd < MAX_CHASE_DIST.powf(2.0) { + if dist_sqrd < MAX_CHASE_DIST.powi(2) { *been_close = true; } if let Some((bearing, speed)) = chaser.chase( @@ -1115,7 +1114,7 @@ impl<'a> System<'a> for Sys { } }, Tactic::QuadLowBasic => { - if dist_sqrd < (1.5 * MIN_ATTACK_DIST * scale).powf(2.0) { + if dist_sqrd < (1.5 * MIN_ATTACK_DIST * scale).powi(2) { inputs.move_dir = Vec2::zero(); if *powerup > 5.0 { *powerup = 0.0; @@ -1126,10 +1125,10 @@ impl<'a> System<'a> for Sys { inputs.primary.set_state(true); *powerup += dt.0; } - } else if dist_sqrd < MAX_CHASE_DIST.powf(2.0) - || (dist_sqrd < SIGHT_DIST.powf(2.0) && !*been_close) + } else if dist_sqrd < MAX_CHASE_DIST.powi(2) + || (dist_sqrd < SIGHT_DIST.powi(2) && !*been_close) { - if dist_sqrd < MAX_CHASE_DIST.powf(2.0) { + if dist_sqrd < MAX_CHASE_DIST.powi(2) { *been_close = true; } if let Some((bearing, speed)) = chaser.chase( @@ -1155,17 +1154,17 @@ impl<'a> System<'a> for Sys { } }, Tactic::QuadMedJump => { - if dist_sqrd < (1.5 * MIN_ATTACK_DIST * scale).powf(2.0) { + if dist_sqrd < (1.5 * MIN_ATTACK_DIST * scale).powi(2) { inputs.move_dir = Vec2::zero(); inputs.secondary.set_state(true); } else if dist_sqrd - < (5.0 * MIN_ATTACK_DIST * scale).powf(2.0) + < (5.0 * MIN_ATTACK_DIST * scale).powi(2) { inputs.ability3.set_state(true); - } else if dist_sqrd < MAX_CHASE_DIST.powf(2.0) - || (dist_sqrd < SIGHT_DIST.powf(2.0) && !*been_close) + } else if dist_sqrd < MAX_CHASE_DIST.powi(2) + || (dist_sqrd < SIGHT_DIST.powi(2) && !*been_close) { - if dist_sqrd < MAX_CHASE_DIST.powf(2.0) { + if dist_sqrd < MAX_CHASE_DIST.powi(2) { *been_close = true; } if let Some((bearing, speed)) = chaser.chase( @@ -1200,7 +1199,7 @@ impl<'a> System<'a> for Sys { } }, Tactic::QuadMedBasic => { - if dist_sqrd < (MIN_ATTACK_DIST * scale).powf(2.0) { + if dist_sqrd < (MIN_ATTACK_DIST * scale).powi(2) { inputs.move_dir = Vec2::zero(); if *powerup < 2.0 { inputs.secondary.set_state(true); @@ -1211,10 +1210,10 @@ impl<'a> System<'a> for Sys { } else { *powerup = 0.0; } - } else if dist_sqrd < MAX_CHASE_DIST.powf(2.0) - || (dist_sqrd < SIGHT_DIST.powf(2.0) && !*been_close) + } else if dist_sqrd < MAX_CHASE_DIST.powi(2) + || (dist_sqrd < SIGHT_DIST.powi(2) && !*been_close) { - if dist_sqrd < MAX_CHASE_DIST.powf(2.0) { + if dist_sqrd < MAX_CHASE_DIST.powi(2) { *been_close = true; } if let Some((bearing, speed)) = chaser.chase( @@ -1240,11 +1239,11 @@ impl<'a> System<'a> for Sys { } }, Tactic::Lavadrake => { - if dist_sqrd < (2.5 * MIN_ATTACK_DIST * scale).powf(2.0) { + if dist_sqrd < (2.5 * MIN_ATTACK_DIST * scale).powi(2) { inputs.move_dir = Vec2::zero(); inputs.secondary.set_state(true); } else if dist_sqrd - < (7.0 * MIN_ATTACK_DIST * scale).powf(2.0) + < (7.0 * MIN_ATTACK_DIST * scale).powi(2) { if *powerup < 2.0 { inputs.move_dir = (tgt_pos.0 - pos.0) @@ -1268,10 +1267,10 @@ impl<'a> System<'a> for Sys { } else { *powerup = 0.0; } - } else if dist_sqrd < MAX_CHASE_DIST.powf(2.0) - || (dist_sqrd < SIGHT_DIST.powf(2.0) && !*been_close) + } else if dist_sqrd < MAX_CHASE_DIST.powi(2) + || (dist_sqrd < SIGHT_DIST.powi(2) && !*been_close) { - if dist_sqrd < MAX_CHASE_DIST.powf(2.0) { + if dist_sqrd < MAX_CHASE_DIST.powi(2) { *been_close = true; } if let Some((bearing, speed)) = chaser.chase( @@ -1297,13 +1296,13 @@ impl<'a> System<'a> for Sys { } }, Tactic::Theropod => { - if dist_sqrd < (2.0 * MIN_ATTACK_DIST * scale).powf(2.0) { + if dist_sqrd < (2.0 * MIN_ATTACK_DIST * scale).powi(2) { inputs.move_dir = Vec2::zero(); inputs.primary.set_state(true); - } else if dist_sqrd < MAX_CHASE_DIST.powf(2.0) - || (dist_sqrd < SIGHT_DIST.powf(2.0) && !*been_close) + } else if dist_sqrd < MAX_CHASE_DIST.powi(2) + || (dist_sqrd < SIGHT_DIST.powi(2) && !*been_close) { - if dist_sqrd < MAX_CHASE_DIST.powf(2.0) { + if dist_sqrd < MAX_CHASE_DIST.powi(2) { *been_close = true; } if let Some((bearing, speed)) = chaser.chase( @@ -1359,11 +1358,11 @@ impl<'a> System<'a> for Sys { search_dist *= SNEAK_COEFFICIENT; listen_dist *= SNEAK_COEFFICIENT; } - ((e_pos.0.distance_squared(pos.0) < search_dist.powf(2.0) && + ((e_pos.0.distance_squared(pos.0) < search_dist.powi(2) && // Within our view (e_pos.0 - pos.0).try_normalized().map(|v| v.dot(*inputs.look_dir) > 0.15).unwrap_or(true)) // Within listen distance - || e_pos.0.distance_squared(pos.0) < listen_dist.powf(2.0)) + || e_pos.0.distance_squared(pos.0) < listen_dist.powi(2)) && *e != entity && !e_health.is_dead && alignment @@ -1438,7 +1437,7 @@ impl<'a> System<'a> for Sys { let owner_pos = positions.get(owner)?; let dist_sqrd = pos.0.distance_squared(owner_pos.0); - if dist_sqrd > MAX_FOLLOW_DIST.powf(2.0) && !agent.activity.is_follow() { + if dist_sqrd > MAX_FOLLOW_DIST.powi(2) && !agent.activity.is_follow() { agent.activity = Activity::Follow { target: owner, chaser: Chaser::default(), @@ -1503,6 +1502,6 @@ fn can_see_tgt(terrain: &TerrainGrid, pos: &Pos, tgt_pos: &Pos, dist_sqrd: f32) .until(Block::is_opaque) .cast() .0 - .powf(2.0) + .powi(2) >= dist_sqrd } diff --git a/common/src/sys/stats.rs b/common/src/sys/stats.rs index e76a900e8c..8301d164cd 100644 --- a/common/src/sys/stats.rs +++ b/common/src/sys/stats.rs @@ -115,7 +115,7 @@ impl<'a> System<'a> for Sys { // Have to account for Calc I differential equations due to acceleration energy.change_by(EnergyChange { amount: (energy.regen_rate * dt.0 - + ENERGY_REGEN_ACCEL * dt.0.powf(2.0) / 2.0) + + ENERGY_REGEN_ACCEL * dt.0.powi(2) / 2.0) as i32, source: EnergySource::Regen, }); diff --git a/server/src/events/inventory_manip.rs b/server/src/events/inventory_manip.rs index e61cb503e1..f1b26e12e5 100644 --- a/server/src/events/inventory_manip.rs +++ b/server/src/events/inventory_manip.rs @@ -286,8 +286,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv ) .join() .filter(|(_, wild_pos, _)| { - wild_pos.0.distance_squared(pos.0) - < 5.0f32.powf(2.0) + wild_pos.0.distance_squared(pos.0) < 5.0f32.powi(2) }) .filter(|(_, _, alignment)| { alignment == &&comp::Alignment::Wild diff --git a/server/src/rtsim/entity.rs b/server/src/rtsim/entity.rs index 7362b4b3d1..2680edd9c8 100644 --- a/server/src/rtsim/entity.rs +++ b/server/src/rtsim/entity.rs @@ -32,7 +32,7 @@ impl Entity { } pub fn get_level(&self) -> u32 { - (self.rng(PERM_LEVEL).gen::().powf(2.0) * 15.0).ceil() as u32 + (self.rng(PERM_LEVEL).gen::().powi(2) * 15.0).ceil() as u32 } pub fn get_loadout(&self, ability_map: &AbilityMap) -> comp::Loadout { diff --git a/server/src/sys/entity_sync.rs b/server/src/sys/entity_sync.rs index fffa97871e..8f3d5ff22e 100644 --- a/server/src/sys/entity_sync.rs +++ b/server/src/sys/entity_sync.rs @@ -352,7 +352,7 @@ impl<'a> System<'a> for Sys { pos.zip_with(presence, |pos, presence| { pos.0.xy().distance_squared(o_pos.xy()) < (presence.view_distance as f32 * TerrainChunkSize::RECT_SIZE.x as f32) - .powf(2.0) + .powi(2) }) }; diff --git a/voxygen/src/anim/src/biped_large/alpha.rs b/voxygen/src/anim/src/biped_large/alpha.rs index 31181f1489..b05f7bcba0 100644 --- a/voxygen/src/anim/src/biped_large/alpha.rs +++ b/voxygen/src/anim/src/biped_large/alpha.rs @@ -37,19 +37,17 @@ impl Animation for AlphaAnimation { let (movement1, movement2, movement3) = match stage_section { Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0), Some(StageSection::Swing) => (1.0, anim_time as f32, 0.0), - Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powf(4.0)), + Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powi(4)), _ => (0.0, 0.0, 0.0), }; let foot = (((1.0) - / (0.2 - + 0.8 - * ((anim_time as f32 * lab as f32 * 2.0 * velocity).sin()).powf(2.0 as f32))) + / (0.2 + 0.8 * ((anim_time as f32 * lab as f32 * 2.0 * velocity).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * lab as f32 * 2.0 * velocity).sin()); let slowersmooth = (anim_time as f32 * lab as f32 * 4.0).sin(); let slower = (((1.0) - / (0.0001 + 0.999 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32))) + / (0.0001 + 0.999 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * lab as f32 * 4.0).sin()); diff --git a/voxygen/src/anim/src/biped_large/beta.rs b/voxygen/src/anim/src/biped_large/beta.rs index b8d4fa7ba9..e952d94eae 100644 --- a/voxygen/src/anim/src/biped_large/beta.rs +++ b/voxygen/src/anim/src/biped_large/beta.rs @@ -33,7 +33,7 @@ impl Animation for BetaAnimation { let (movement1, movement2, movement3) = match stage_section { Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0), Some(StageSection::Swing) => (1.0, anim_time as f32, 0.0), - Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powf(4.0)), + Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powi(4)), _ => (0.0, 0.0, 0.0), }; diff --git a/voxygen/src/anim/src/biped_large/charge.rs b/voxygen/src/anim/src/biped_large/charge.rs index 732a751f2f..8d5fc46a29 100644 --- a/voxygen/src/anim/src/biped_large/charge.rs +++ b/voxygen/src/anim/src/biped_large/charge.rs @@ -32,24 +32,21 @@ impl Animation for ChargeAnimation { let lab = 1.0; - let foot = (((5.0) - / (0.2 + 4.8 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powf(2.0 as f32))) - .sqrt()) + let foot = (((5.0) / (0.2 + 4.8 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powi(2))) + .sqrt()) * ((anim_time as f32 * lab as f32 * 8.0).sin()); let foote = (((5.0) - / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 8.0 + 1.57).sin()).powf(2.0 as f32))) + / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 8.0 + 1.57).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * lab as f32 * 8.0).sin()); - let stress = (((5.0) - / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 20.0).cos()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 20.0).cos()); - let quick = (((5.0) - / (3.5 + 1.5 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powf(2.0 as f32))) - .sqrt()) + let stress = + (((5.0) / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 20.0).cos()).powi(2))).sqrt()) + * ((anim_time as f32 * lab as f32 * 20.0).cos()); + let quick = (((5.0) / (3.5 + 1.5 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powi(2))) + .sqrt()) * ((anim_time as f32 * lab as f32 * 8.0).sin()); - let stop = ((anim_time as f32).powf(0.3 as f32)).min(1.2); - let stopa = ((anim_time as f32).powf(0.9 as f32)).min(5.0); + let stop = ((anim_time as f32).powf(0.3)).min(1.2); + let stopa = ((anim_time as f32).powf(0.9)).min(5.0); let ori: Vec2 = Vec2::from(orientation); let last_ori = Vec2::from(last_ori); diff --git a/voxygen/src/anim/src/biped_large/dash.rs b/voxygen/src/anim/src/biped_large/dash.rs index e23047edd2..ee48b01e56 100644 --- a/voxygen/src/anim/src/biped_large/dash.rs +++ b/voxygen/src/anim/src/biped_large/dash.rs @@ -40,7 +40,7 @@ impl Animation for DashAnimation { }; fn short(x: f32) -> f32 { - (((5.0) / (1.5 + 3.5 * ((x * 5.0).sin()).powf(2.0 as f32))).sqrt()) * ((x * 5.0).sin()) + (((5.0) / (1.5 + 3.5 * ((x * 5.0).sin()).powi(2))).sqrt()) * ((x * 5.0).sin()) } fn foothoril(x: f32) -> f32 { (x * 5.0 + PI * 1.45).sin() } fn foothorir(x: f32) -> f32 { (x * 5.0 + PI * (0.45)).sin() } @@ -49,12 +49,12 @@ impl Animation for DashAnimation { fn footvertr(x: f32) -> f32 { (x * 5.0 + PI).sin() } fn footrotl(x: f32) -> f32 { - (((1.0) / (0.05 + (0.95) * ((x * 5.0 + PI * 1.4).sin()).powf(2.0 as f32))).sqrt()) + (((1.0) / (0.05 + (0.95) * ((x * 5.0 + PI * 1.4).sin()).powi(2))).sqrt()) * ((x * 5.0 + PI * 1.4).sin()) } fn footrotr(x: f32) -> f32 { - (((1.0) / (0.05 + (0.95) * ((x * 5.0 + PI * 0.4).sin()).powf(2.0 as f32))).sqrt()) + (((1.0) / (0.05 + (0.95) * ((x * 5.0 + PI * 0.4).sin()).powi(2))).sqrt()) * ((x * 5.0 + PI * 0.4).sin()) } diff --git a/voxygen/src/anim/src/biped_large/run.rs b/voxygen/src/anim/src/biped_large/run.rs index f49e3f61e6..105768b303 100644 --- a/voxygen/src/anim/src/biped_large/run.rs +++ b/voxygen/src/anim/src/biped_large/run.rs @@ -47,15 +47,11 @@ impl Animation for RunAnimation { let lab = 0.65; //.65 let foothoril = (((1.0) - / (0.4 - + (0.6) - * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32))) + / (0.4 + (0.6) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()); let foothorir = (((1.0) - / (0.4 - + (0.6) - * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32))) + / (0.4 + (0.6) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()); @@ -65,24 +61,20 @@ impl Animation for RunAnimation { let handhorir = (anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin(); let footrotl = (((5.0) - / (2.5 - + (2.5) - * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32))) + / (2.5 + (2.5) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()); let footrotr = (((5.0) - / (1.0 - + (4.0) - * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32))) + / (1.0 + (4.0) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()); let amplitude = (speed / 21.0).max(0.25); - let amplitude2 = (speed * 1.4 / 21.0).powf(0.5).max(0.6); - let amplitude3 = (speed / 21.0).powf(0.5).max(0.35); + let amplitude2 = (speed * 1.4 / 21.0).sqrt().max(0.6); + let amplitude3 = (speed / 21.0).sqrt().max(0.35); let speedmult = 1.0; - let canceler = (speed / 21.0).powf(0.5); + let canceler = (speed / 21.0).sqrt(); let short = (anim_time as f32 * (16.0) * lab as f32 * speedmult + PI * -0.15).sin(); // diff --git a/voxygen/src/anim/src/biped_large/shoot.rs b/voxygen/src/anim/src/biped_large/shoot.rs index 19b63eadc4..7af7cd9234 100644 --- a/voxygen/src/anim/src/biped_large/shoot.rs +++ b/voxygen/src/anim/src/biped_large/shoot.rs @@ -126,7 +126,7 @@ impl Animation for ShootAnimation { let (movement1, movement2, movement3) = match stage_section { Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0), Some(StageSection::Swing) => (1.0, anim_time as f32, 0.0), - Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powf(4.0)), + Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powi(4)), _ => (0.0, 0.0, 0.0), }; next.main.position = Vec3::new(0.0, 0.0, 0.0); diff --git a/voxygen/src/anim/src/biped_large/spin.rs b/voxygen/src/anim/src/biped_large/spin.rs index 93297a2d29..7d9f15007f 100644 --- a/voxygen/src/anim/src/biped_large/spin.rs +++ b/voxygen/src/anim/src/biped_large/spin.rs @@ -35,12 +35,12 @@ impl Animation for SpinAnimation { let (movement1, movement2, movement3) = match stage_section { Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0), Some(StageSection::Swing) => (1.0, (anim_time as f32).powf(1.8), 0.0), - Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powf(4.0)), + Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powi(4)), _ => (0.0, 0.0, 0.0), }; let foot = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 10.32).sin()).powf(2.0 as f32))) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 10.32).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * lab as f32 * 10.32).sin()); diff --git a/voxygen/src/anim/src/biped_large/spinmelee.rs b/voxygen/src/anim/src/biped_large/spinmelee.rs index db255fc79c..7e549e9b4f 100644 --- a/voxygen/src/anim/src/biped_large/spinmelee.rs +++ b/voxygen/src/anim/src/biped_large/spinmelee.rs @@ -52,7 +52,7 @@ impl Animation for SpinMeleeAnimation { }; let spin = if anim_time < 1.1 && velocity.z.abs() < 0.1 { - 0.5 * ((anim_time as f32).powf(2.0)) + 0.5 * ((anim_time as f32).powi(2)) } else { lab as f32 * anim_time as f32 * 0.9 }; diff --git a/voxygen/src/anim/src/biped_large/wield.rs b/voxygen/src/anim/src/biped_large/wield.rs index 4f898ea49b..77640eeac5 100644 --- a/voxygen/src/anim/src/biped_large/wield.rs +++ b/voxygen/src/anim/src/biped_large/wield.rs @@ -75,15 +75,11 @@ impl Animation for WieldAnimation { }; let foothoril = (((1.0) - / (0.4 - + (0.6) - * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32))) + / (0.4 + (0.6) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()); let foothorir = (((1.0) - / (0.4 - + (0.6) - * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32))) + / (0.4 + (0.6) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()); @@ -93,16 +89,12 @@ impl Animation for WieldAnimation { let handhorir = (anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin(); let footrotl = (((5.0) - / (2.5 - + (2.5) - * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32))) + / (2.5 + (2.5) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()); let footrotr = (((5.0) - / (1.0 - + (4.0) - * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32))) + / (1.0 + (4.0) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()); diff --git a/voxygen/src/anim/src/character/alpha.rs b/voxygen/src/anim/src/character/alpha.rs index 543ff2f2ba..3e22f7b6c6 100644 --- a/voxygen/src/anim/src/character/alpha.rs +++ b/voxygen/src/anim/src/character/alpha.rs @@ -37,23 +37,20 @@ impl Animation for AlphaAnimation { let (movement1, movement2, movement3) = match stage_section { Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0), Some(StageSection::Swing) => (1.0, anim_time as f32, 0.0), - Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powf(4.0)), + Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powi(4)), _ => (0.0, 0.0, 0.0), }; let foot = (((1.0) - / (0.2 - + 0.8 - * ((anim_time as f32 * lab as f32 * 2.0 * velocity).sin()).powf(2.0 as f32))) + / (0.2 + 0.8 * ((anim_time as f32 * lab as f32 * 2.0 * velocity).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * lab as f32 * 2.0 * velocity).sin()); let push = anim_time as f32 * lab as f32 * 4.0; - let slow = (((5.0) - / (0.4 + 4.6 * ((anim_time as f32 * lab as f32 * 9.0).sin()).powf(2.0 as f32))) - .sqrt()) + let slow = (((5.0) / (0.4 + 4.6 * ((anim_time as f32 * lab as f32 * 9.0).sin()).powi(2))) + .sqrt()) * ((anim_time as f32 * lab as f32 * 9.0).sin()); let slower = (((1.0) - / (0.0001 + 0.999 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32))) + / (0.0001 + 0.999 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * lab as f32 * 4.0).sin()); @@ -116,7 +113,7 @@ impl Animation for AlphaAnimation { let (movement1, movement2, movement3) = match stage_section { Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0), Some(StageSection::Swing) => (1.0, anim_time as f32, 0.0), - Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powf(4.0)), + Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powi(4)), _ => (0.0, 0.0, 0.0), }; next.control.position = Vec3::new( @@ -148,7 +145,7 @@ impl Animation for AlphaAnimation { let (movement1, movement2, movement3) = match stage_section { Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0), Some(StageSection::Swing) => (1.0, anim_time as f32, 0.0), - Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powf(4.0)), + Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powi(4)), _ => (0.0, 0.0, 0.0), }; next.main.position = Vec3::new(0.0, 0.0, 0.0); diff --git a/voxygen/src/anim/src/character/beta.rs b/voxygen/src/anim/src/character/beta.rs index 275ee8fd88..7255a22667 100644 --- a/voxygen/src/anim/src/character/beta.rs +++ b/voxygen/src/anim/src/character/beta.rs @@ -33,7 +33,7 @@ impl Animation for BetaAnimation { let (movement1, movement2, movement3) = match stage_section { Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0), Some(StageSection::Swing) => (1.0, anim_time as f32, 0.0), - Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powf(4.0)), + Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powi(4)), _ => (0.0, 0.0, 0.0), }; diff --git a/voxygen/src/anim/src/character/charge.rs b/voxygen/src/anim/src/character/charge.rs index b6ee338285..a64285ca9e 100644 --- a/voxygen/src/anim/src/character/charge.rs +++ b/voxygen/src/anim/src/character/charge.rs @@ -36,24 +36,21 @@ impl Animation for ChargeAnimation { let lab = 1.0; - let foot = (((5.0) - / (0.2 + 4.8 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powf(2.0 as f32))) - .sqrt()) + let foot = (((5.0) / (0.2 + 4.8 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powi(2))) + .sqrt()) * ((anim_time as f32 * lab as f32 * 8.0).sin()); let foote = (((5.0) - / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 8.0 + 1.57).sin()).powf(2.0 as f32))) + / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 8.0 + 1.57).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * lab as f32 * 8.0).sin()); - let stress = (((5.0) - / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 20.0).cos()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 20.0).cos()); - let quick = (((5.0) - / (3.5 + 1.5 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powf(2.0 as f32))) - .sqrt()) + let stress = + (((5.0) / (0.5 + 4.5 * ((anim_time as f32 * lab as f32 * 20.0).cos()).powi(2))).sqrt()) + * ((anim_time as f32 * lab as f32 * 20.0).cos()); + let quick = (((5.0) / (3.5 + 1.5 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powi(2))) + .sqrt()) * ((anim_time as f32 * lab as f32 * 8.0).sin()); - let stop = ((anim_time as f32).powf(0.3 as f32)).min(1.2); - let stopa = ((anim_time as f32).powf(0.9 as f32)).min(5.0); + let stop = ((anim_time as f32).powf(0.3)).min(1.2); + let stopa = ((anim_time as f32).powf(0.9)).min(5.0); let ori: Vec2 = Vec2::from(orientation); let last_ori = Vec2::from(last_ori); diff --git a/voxygen/src/anim/src/character/chargeswing.rs b/voxygen/src/anim/src/character/chargeswing.rs index d02fa6bb52..847bdbaf64 100644 --- a/voxygen/src/anim/src/character/chargeswing.rs +++ b/voxygen/src/anim/src/character/chargeswing.rs @@ -32,9 +32,8 @@ impl Animation for ChargeswingAnimation { let lab = 1.0; - let short = (((5.0) - / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powf(2.0 as f32))) - .sqrt()) + let short = (((5.0) / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powi(2))) + .sqrt()) * ((anim_time as f32 * lab as f32 * 8.0).sin()); // end spin stuff @@ -46,7 +45,7 @@ impl Animation for ChargeswingAnimation { (anim_time as f32 * 18.0 * lab as f32).sin(), ), Some(StageSection::Swing) => (1.0, anim_time as f32, 0.0, 0.0), - Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powf(4.0), 0.0), + Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powi(4), 0.0), _ => (0.0, 0.0, 0.0, 0.0), }; if let Some(ToolKind::Hammer) = active_tool_kind { diff --git a/voxygen/src/anim/src/character/climb.rs b/voxygen/src/anim/src/character/climb.rs index 25d33d4ea1..3cc1afc84e 100644 --- a/voxygen/src/anim/src/character/climb.rs +++ b/voxygen/src/anim/src/character/climb.rs @@ -39,14 +39,11 @@ impl Animation for ClimbAnimation { let dropa = (anim_time as f32 * constant as f32 * 4.0).sin(); let quick = (((5.0) - / (0.6 + 4.0 * ((anim_time as f32 * constant as f32 * 1.5).sin()).powf(2.0 as f32))) + / (0.6 + 4.0 * ((anim_time as f32 * constant as f32 * 1.5).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * constant as f32 * 1.5).sin()); let quicka = (((5.0) - / (0.6 - + 4.0 - * ((anim_time as f32 * constant as f32 * 1.5 + PI / 2.0).sin()) - .powf(2.0 as f32))) + / (0.6 + 4.0 * ((anim_time as f32 * constant as f32 * 1.5 + PI / 2.0).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * constant as f32 * 1.5 + PI / 2.0).sin()); let head_look = Vec2::new( diff --git a/voxygen/src/anim/src/character/dance.rs b/voxygen/src/anim/src/character/dance.rs index 143d01f148..592be56398 100644 --- a/voxygen/src/anim/src/character/dance.rs +++ b/voxygen/src/anim/src/character/dance.rs @@ -27,9 +27,8 @@ impl Animation for DanceAnimation { *rate = 1.0; let lab = 1.0; - let short = (((5.0) - / (3.0 + 2.0 * ((anim_time as f32 * lab as f32 * 6.0).sin()).powf(2.0 as f32))) - .sqrt()) + let short = (((5.0) / (3.0 + 2.0 * ((anim_time as f32 * lab as f32 * 6.0).sin()).powi(2))) + .sqrt()) * ((anim_time as f32 * lab as f32 * 6.0).sin()); let noisea = (anim_time as f32 * 11.0 + PI / 6.0).sin(); let noiseb = (anim_time as f32 * 19.0 + PI / 4.0).sin(); @@ -39,7 +38,7 @@ impl Animation for DanceAnimation { let shortealt = (anim_time as f32 * lab as f32 * 6.0 + PI / 2.0).sin(); let foot = (((5.0) - / (1.0 + (4.0) * ((anim_time as f32 * lab as f32 * 8.0).sin()).powf(2.0 as f32))) + / (1.0 + (4.0) * ((anim_time as f32 * lab as f32 * 8.0).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * lab as f32 * 8.0).sin()); diff --git a/voxygen/src/anim/src/character/dash.rs b/voxygen/src/anim/src/character/dash.rs index 3efa5b6d4e..4edd33f3e7 100644 --- a/voxygen/src/anim/src/character/dash.rs +++ b/voxygen/src/anim/src/character/dash.rs @@ -35,17 +35,16 @@ impl Animation for DashAnimation { Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0, 0.0), Some(StageSection::Charge) => (1.0, anim_time as f32, 0.0, 0.0), Some(StageSection::Swing) => (1.0, 1.0, anim_time as f32, 0.0), - Some(StageSection::Recover) => (1.1, 1.0, 1.0, (anim_time as f32).powf(4.0)), + Some(StageSection::Recover) => (1.1, 1.0, 1.0, (anim_time as f32).powi(4)), _ => (0.0, 0.0, 0.0, 0.0), }; fn slow(x: f32) -> f32 { - (((5.0) / (1.1 + 3.9 * ((x * 12.4).sin()).powf(2.0 as f32))).sqrt()) - * ((x * 12.4).sin()) + (((5.0) / (1.1 + 3.9 * ((x * 12.4).sin()).powi(2))).sqrt()) * ((x * 12.4).sin()) } fn short(x: f32) -> f32 { - (((5.0) / (1.5 + 3.5 * ((x * 5.0).sin()).powf(2.0 as f32))).sqrt()) * ((x * 5.0).sin()) + (((5.0) / (1.5 + 3.5 * ((x * 5.0).sin()).powi(2))).sqrt()) * ((x * 5.0).sin()) } fn foothoril(x: f32) -> f32 { (x * 5.0 + PI * 1.45).sin() } fn foothorir(x: f32) -> f32 { (x * 5.0 + PI * (0.45)).sin() } @@ -54,12 +53,12 @@ impl Animation for DashAnimation { fn footvertr(x: f32) -> f32 { (x * 5.0 + PI).sin() } fn footrotl(x: f32) -> f32 { - (((1.0) / (0.05 + (0.95) * ((x * 5.0 + PI * 1.4).sin()).powf(2.0 as f32))).sqrt()) + (((1.0) / (0.05 + (0.95) * ((x * 5.0 + PI * 1.4).sin()).powi(2))).sqrt()) * ((x * 5.0 + PI * 1.4).sin()) } fn footrotr(x: f32) -> f32 { - (((1.0) / (0.05 + (0.95) * ((x * 5.0 + PI * 0.4).sin()).powf(2.0 as f32))).sqrt()) + (((1.0) / (0.05 + (0.95) * ((x * 5.0 + PI * 0.4).sin()).powi(2))).sqrt()) * ((x * 5.0 + PI * 0.4).sin()) } diff --git a/voxygen/src/anim/src/character/run.rs b/voxygen/src/anim/src/character/run.rs index 8dcdd1ab39..6e02667f69 100644 --- a/voxygen/src/anim/src/character/run.rs +++ b/voxygen/src/anim/src/character/run.rs @@ -53,30 +53,26 @@ impl Animation for RunAnimation { let footrotl = (((1.0) / (0.5 + (0.5) - * ((anim_time as f32 * 16.0 * walk * lab as f32 + PI * 1.4).sin()) - .powf(2.0 as f32))) + * ((anim_time as f32 * 16.0 * walk * lab as f32 + PI * 1.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * walk * lab as f32 + PI * 1.4).sin()); let footrotr = (((1.0) / (0.5 + (0.5) - * ((anim_time as f32 * 16.0 * walk * lab as f32 + PI * 0.4).sin()) - .powf(2.0 as f32))) + * ((anim_time as f32 * 16.0 * walk * lab as f32 + PI * 0.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * walk * lab as f32 + PI * 0.4).sin()); let short = (((5.0) - / (1.5 - + 3.5 * ((anim_time as f32 * lab as f32 * 16.0 * walk).sin()).powf(2.0 as f32))) + / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 16.0 * walk).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * lab as f32 * 16.0 * walk).sin()); let noisea = (anim_time as f32 * 11.0 + PI / 6.0).sin(); let noiseb = (anim_time as f32 * 19.0 + PI / 4.0).sin(); let shorte = (((5.0) - / (4.0 - + 1.0 * ((anim_time as f32 * lab as f32 * 16.0 * walk).sin()).powf(2.0 as f32))) + / (4.0 + 1.0 * ((anim_time as f32 * lab as f32 * 16.0 * walk).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * lab as f32 * 16.0 * walk).sin()); diff --git a/voxygen/src/anim/src/character/shoot.rs b/voxygen/src/anim/src/character/shoot.rs index 4ab001e23e..7217109854 100644 --- a/voxygen/src/anim/src/character/shoot.rs +++ b/voxygen/src/anim/src/character/shoot.rs @@ -118,7 +118,7 @@ impl Animation for ShootAnimation { let (_movement1, movement2, _movement3) = match stage_section { Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0), Some(StageSection::Swing) => (1.0, anim_time as f32, 0.0), - Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powf(4.0)), + Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powi(4)), _ => (0.0, 0.0, 0.0), }; next.main.position = Vec3::new(0.0, 0.0, 0.0); diff --git a/voxygen/src/anim/src/character/sneak.rs b/voxygen/src/anim/src/character/sneak.rs index f07dde47a8..2d4f9bae15 100644 --- a/voxygen/src/anim/src/character/sneak.rs +++ b/voxygen/src/anim/src/character/sneak.rs @@ -39,16 +39,12 @@ impl Animation for SneakAnimation { let footvertr = (anim_time as f32 * 7.0 * lab as f32 + PI).sin(); let footrotl = (((5.0) - / (2.5 - + (2.5) - * ((anim_time as f32 * 7.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32))) + / (2.5 + (2.5) * ((anim_time as f32 * 7.0 * lab as f32 + PI * 1.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 7.0 * lab as f32 + PI * 1.4).sin()); let footrotr = (((5.0) - / (1.0 - + (4.0) - * ((anim_time as f32 * 7.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32))) + / (1.0 + (4.0) * ((anim_time as f32 * 7.0 * lab as f32 + PI * 0.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 7.0 * lab as f32 + PI * 0.4).sin()); @@ -56,10 +52,9 @@ impl Animation for SneakAnimation { let noisea = (anim_time as f32 * 11.0 + PI / 6.0).sin(); let noiseb = (anim_time as f32 * 19.0 + PI / 4.0).sin(); - let shorte = (((5.0) - / (4.0 + 1.0 * ((anim_time as f32 * lab as f32 * 7.0).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 7.0).sin()); + let shorte = + (((5.0) / (4.0 + 1.0 * ((anim_time as f32 * lab as f32 * 7.0).sin()).powi(2))).sqrt()) + * ((anim_time as f32 * lab as f32 * 7.0).sin()); let shortalt = (anim_time as f32 * lab as f32 * 7.0 + PI / 2.0).sin(); diff --git a/voxygen/src/anim/src/character/spin.rs b/voxygen/src/anim/src/character/spin.rs index 294c7bfb47..1c95ee58ec 100644 --- a/voxygen/src/anim/src/character/spin.rs +++ b/voxygen/src/anim/src/character/spin.rs @@ -35,12 +35,12 @@ impl Animation for SpinAnimation { let (movement1, movement2, movement3) = match stage_section { Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0), Some(StageSection::Swing) => (1.0, (anim_time as f32).powf(1.8), 0.0), - Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powf(4.0)), + Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powi(4)), _ => (0.0, 0.0, 0.0), }; let foot = (((5.0) - / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 10.32).sin()).powf(2.0 as f32))) + / (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 10.32).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * lab as f32 * 10.32).sin()); @@ -110,7 +110,7 @@ impl Animation for SpinAnimation { let (movement1, movement2, movement3) = match stage_section { Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0), Some(StageSection::Swing) => (1.0, anim_time as f32, 0.0), - Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powf(4.0)), + Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powi(4)), _ => (0.0, 0.0, 0.0), }; @@ -156,7 +156,7 @@ impl Animation for SpinAnimation { * (1.0 - movement3), ); next.torso.orientation = Quaternion::rotation_z( - movement1.powf(2.0) * -6.0 + movement2 * -1.7 + movement3 * 1.4, + movement1.powi(2) * -6.0 + movement2 * -1.7 + movement3 * 1.4, ); next.foot_l.position = Vec3::new( diff --git a/voxygen/src/anim/src/character/spinmelee.rs b/voxygen/src/anim/src/character/spinmelee.rs index 78a0d45165..2a801bfe39 100644 --- a/voxygen/src/anim/src/character/spinmelee.rs +++ b/voxygen/src/anim/src/character/spinmelee.rs @@ -52,7 +52,7 @@ impl Animation for SpinMeleeAnimation { }; let spin = if anim_time < 1.1 && velocity.z.abs() < 0.1 { - 0.5 * ((anim_time as f32).powf(2.0)) + 0.5 * ((anim_time as f32).powi(2)) } else { lab as f32 * anim_time as f32 * 0.9 }; diff --git a/voxygen/src/anim/src/character/swim.rs b/voxygen/src/anim/src/character/swim.rs index 5c03fdd3b0..ebb6f3d29a 100644 --- a/voxygen/src/anim/src/character/swim.rs +++ b/voxygen/src/anim/src/character/swim.rs @@ -50,16 +50,12 @@ impl Animation for SwimAnimation { let foot = (anim_time as f32 * lab as f32 * 6.0 + PI * -0.1).sin(); let footrotl = (((1.0) - / (0.2 - + (0.8) - * ((anim_time as f32 * 6.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32))) + / (0.2 + (0.8) * ((anim_time as f32 * 6.0 * lab as f32 + PI * 1.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 6.0 * lab as f32 + PI * 1.4).sin()); let footrotr = (((1.0) - / (0.2 - + (0.8) - * ((anim_time as f32 * 6.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32))) + / (0.2 + (0.8) * ((anim_time as f32 * 6.0 * lab as f32 + PI * 0.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 6.0 * lab as f32 + PI * 0.4).sin()); diff --git a/voxygen/src/anim/src/character/swimwield.rs b/voxygen/src/anim/src/character/swimwield.rs index bf7a77e272..217563de5d 100644 --- a/voxygen/src/anim/src/character/swimwield.rs +++ b/voxygen/src/anim/src/character/swimwield.rs @@ -30,16 +30,12 @@ impl Animation for SwimWieldAnimation { *rate = 1.0; let intensity = if speed > 0.5 { 1.0 } else { 0.3 }; let footrotl = (((1.0) - / (0.2 - + (0.8) - * ((anim_time as f32 * 6.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32))) + / (0.2 + (0.8) * ((anim_time as f32 * 6.0 * lab as f32 + PI * 1.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 6.0 * lab as f32 + PI * 1.4).sin()); let footrotr = (((1.0) - / (0.2 - + (0.8) - * ((anim_time as f32 * 6.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32))) + / (0.2 + (0.8) * ((anim_time as f32 * 6.0 * lab as f32 + PI * 0.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 6.0 * lab as f32 + PI * 0.4).sin()); @@ -61,10 +57,9 @@ impl Animation for SwimWieldAnimation { let foothoril = (anim_time as f32 * 6.0 * lab as f32 + PI * 1.45).sin(); let foothorir = (anim_time as f32 * 6.0 * lab as f32 + PI * (0.45)).sin(); let u_slowalt = (anim_time as f32 * 3.0 + PI).cos(); - let short = (((5.0) - / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 16.0).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 16.0).sin()); + let short = + (((5.0) / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 16.0).sin()).powi(2))).sqrt()) + * ((anim_time as f32 * lab as f32 * 16.0).sin()); let noisea = (anim_time as f32 * 11.0 + PI / 6.0).sin(); let noiseb = (anim_time as f32 * 19.0 + PI / 4.0).sin(); diff --git a/voxygen/src/anim/src/character/wield.rs b/voxygen/src/anim/src/character/wield.rs index 3075c24b53..a60109796c 100644 --- a/voxygen/src/anim/src/character/wield.rs +++ b/voxygen/src/anim/src/character/wield.rs @@ -62,9 +62,7 @@ impl Animation for WieldAnimation { let footvertlstatic = (anim_time as f32 * 10.0 * lab as f32).sin(); let footvertrstatic = (anim_time as f32 * 10.0 * lab as f32 + PI).sin(); let footrotl = (((1.0) - / (0.5 - + (0.5) - * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32))) + / (0.5 + (0.5) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()); @@ -75,10 +73,9 @@ impl Animation for WieldAnimation { let slow = (anim_time as f32 * 5.0 + PI).sin(); let u_slowalt = (anim_time as f32 * 3.0 + PI).cos(); - let short = (((5.0) - / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 16.0).sin()).powf(2.0 as f32))) - .sqrt()) - * ((anim_time as f32 * lab as f32 * 16.0).sin()); + let short = + (((5.0) / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 16.0).sin()).powi(2))).sqrt()) + * ((anim_time as f32 * lab as f32 * 16.0).sin()); let direction = velocity.y * -0.098 * orientation.y + velocity.x * -0.098 * orientation.x; let side = velocity.x * -0.098 * orientation.y + velocity.y * 0.098 * orientation.x; let strafeabs = (1.0 / (direction).abs() - 1.0).min(1.0); diff --git a/voxygen/src/anim/src/dragon/run.rs b/voxygen/src/anim/src/dragon/run.rs index 66bb134b9c..2bb1f02a83 100644 --- a/voxygen/src/anim/src/dragon/run.rs +++ b/voxygen/src/anim/src/dragon/run.rs @@ -26,9 +26,7 @@ impl Animation for RunAnimation { let lab = 0.6; //6 let short = (((1.0) - / (0.72 - + 0.28 - * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.0).sin()).powf(2.0 as f32))) + / (0.72 + 0.28 * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.0).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.0).sin()); diff --git a/voxygen/src/anim/src/golem/alpha.rs b/voxygen/src/anim/src/golem/alpha.rs index d1f072daec..d147dfca34 100644 --- a/voxygen/src/anim/src/golem/alpha.rs +++ b/voxygen/src/anim/src/golem/alpha.rs @@ -27,9 +27,7 @@ impl Animation for AlphaAnimation { let lab = 1.0; let slower = (((1.0) - / (0.05 - + 0.95 - * ((anim_time as f32 * lab as f32 * 8.0 - 0.5 * PI).sin()).powf(2.0 as f32))) + / (0.05 + 0.95 * ((anim_time as f32 * lab as f32 * 8.0 - 0.5 * PI).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * lab as f32 * 8.0 - 0.5 * PI).sin()) + 1.0; diff --git a/voxygen/src/anim/src/golem/run.rs b/voxygen/src/anim/src/golem/run.rs index 055a801efe..1f37f2f21f 100644 --- a/voxygen/src/anim/src/golem/run.rs +++ b/voxygen/src/anim/src/golem/run.rs @@ -26,31 +26,23 @@ impl Animation for RunAnimation { let lab = 0.45; //.65 let foothoril = (((1.0) - / (0.4 - + (0.6) - * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32))) + / (0.4 + (0.6) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()); let foothorir = (((1.0) - / (0.4 - + (0.6) - * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32))) + / (0.4 + (0.6) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()); let footvertl = (anim_time as f32 * 16.0 * lab as f32).sin(); let footvertr = (anim_time as f32 * 16.0 * lab as f32 + PI).sin(); let footrotl = (((5.0) - / (2.5 - + (2.5) - * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32))) + / (2.5 + (2.5) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.4).sin()); let footrotr = (((5.0) - / (1.0 - + (4.0) - * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32))) + / (1.0 + (4.0) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.4).sin()); diff --git a/voxygen/src/anim/src/golem/shockwave.rs b/voxygen/src/anim/src/golem/shockwave.rs index 9a3538902a..1072138087 100644 --- a/voxygen/src/anim/src/golem/shockwave.rs +++ b/voxygen/src/anim/src/golem/shockwave.rs @@ -30,8 +30,7 @@ impl Animation for ShockwaveAnimation { let slower = (((1.0) / (0.00001 - + 0.9999 - * ((anim_time as f32 * lab as f32 * 2.0 - 0.5 * PI).sin()).powf(2.0 as f32))) + + 0.9999 * ((anim_time as f32 * lab as f32 * 2.0 - 0.5 * PI).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * lab as f32 * 2.0 - 0.5 * PI).sin()) + 1.0; diff --git a/voxygen/src/anim/src/quadruped_low/beta.rs b/voxygen/src/anim/src/quadruped_low/beta.rs index cbd71973dd..43dd5ffd56 100644 --- a/voxygen/src/anim/src/quadruped_low/beta.rs +++ b/voxygen/src/anim/src/quadruped_low/beta.rs @@ -25,8 +25,8 @@ impl Animation for BetaAnimation { let mut next = (*skeleton).clone(); let (movement1base, movement2base, movement3) = match stage_section { - Some(StageSection::Buildup) => ((anim_time as f32).powf(0.5), 0.0, 0.0), - Some(StageSection::Swing) => (1.0, (anim_time as f32).powf(4.0), 0.0), + Some(StageSection::Buildup) => ((anim_time as f32).sqrt(), 0.0, 0.0), + Some(StageSection::Swing) => (1.0, (anim_time as f32).powi(4), 0.0), Some(StageSection::Recover) => (1.0, 1.0, anim_time as f32), _ => (0.0, 0.0, 0.0), }; diff --git a/voxygen/src/anim/src/quadruped_low/breathe.rs b/voxygen/src/anim/src/quadruped_low/breathe.rs index 097876c7e4..82a55d7659 100644 --- a/voxygen/src/anim/src/quadruped_low/breathe.rs +++ b/voxygen/src/anim/src/quadruped_low/breathe.rs @@ -27,7 +27,7 @@ impl Animation for BreatheAnimation { let speed = (Vec2::::from(velocity).magnitude()).min(24.0); let (movement1base, _movement2base, movement3, twitch) = match stage_section { - Some(StageSection::Buildup) => ((anim_time as f32).powf(0.5), 0.0, 0.0, 0.0), + Some(StageSection::Buildup) => ((anim_time as f32).sqrt(), 0.0, 0.0, 0.0), Some(StageSection::Cast) => (1.0, (anim_time as f32).min(1.0), 0.0, anim_time as f32), Some(StageSection::Recover) => (1.0, 1.0, anim_time as f32, 1.0), _ => (0.0, 0.0, 0.0, 0.0), diff --git a/voxygen/src/anim/src/quadruped_low/dash.rs b/voxygen/src/anim/src/quadruped_low/dash.rs index f747840dd4..e64669ab23 100644 --- a/voxygen/src/anim/src/quadruped_low/dash.rs +++ b/voxygen/src/anim/src/quadruped_low/dash.rs @@ -26,9 +26,9 @@ impl Animation for DashAnimation { let mut next = (*skeleton).clone(); let (movement1base, chargemovementbase, movement2base, movement3) = match stage_section { - Some(StageSection::Buildup) => ((anim_time as f32).powf(0.5), 0.0, 0.0, 0.0), + Some(StageSection::Buildup) => ((anim_time as f32).sqrt(), 0.0, 0.0, 0.0), Some(StageSection::Charge) => (1.0, 1.0, 0.0, 0.0), - Some(StageSection::Swing) => (1.0, 1.0, (anim_time as f32).powf(4.0), 0.0), + Some(StageSection::Swing) => (1.0, 1.0, (anim_time as f32).powi(4), 0.0), Some(StageSection::Recover) => (1.0, 1.0, 1.0, anim_time as f32), _ => (0.0, 0.0, 0.0, 0.0), }; @@ -44,8 +44,7 @@ impl Animation for DashAnimation { let movement1abs = movement1base * pullback; let movement2abs = movement2base * pullback; let short = (((1.0) - / (0.72 - + 0.28 * ((anim_time as f32 * 16.0 as f32 + PI * 0.25).sin()).powf(2.0 as f32))) + / (0.72 + 0.28 * ((anim_time as f32 * 16.0 as f32 + PI * 0.25).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 as f32 + PI * 0.25).sin()) * chargemovementbase diff --git a/voxygen/src/anim/src/quadruped_low/run.rs b/voxygen/src/anim/src/quadruped_low/run.rs index e58358552a..b1d1851637 100644 --- a/voxygen/src/anim/src/quadruped_low/run.rs +++ b/voxygen/src/anim/src/quadruped_low/run.rs @@ -27,47 +27,32 @@ impl Animation for RunAnimation { let x_tilt = avg_vel.z.atan2(avg_vel.xy().magnitude()).max(-0.7); let short = (((1.0) - / (0.72 - + 0.28 - * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.25).sin()) - .powf(2.0 as f32))) + / (0.72 + 0.28 * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.25).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.25).sin()); let shortalt = (anim_time as f32 * 16.0 * lab as f32 + PI * 0.25).sin(); let foothoril = (((1.0) - / (0.4 - + (0.6) - * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.45).sin()) - .powf(2.0 as f32))) + / (0.4 + (0.6) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.45).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.45).sin()); let footvertl = (anim_time as f32 * 16.0 * lab as f32 + PI * 0.0).sin(); let foothorir = (((1.0) - / (0.4 - + (0.6) - * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.45).sin()) - .powf(2.0 as f32))) + / (0.4 + (0.6) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.45).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.45).sin()); let footvertr = (anim_time as f32 * 16.0 * lab as f32 + PI).sin(); //back feet let foothorilb = (((1.0) - / (0.4 - + (0.6) - * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.05).sin()) - .powf(2.0 as f32))) + / (0.4 + (0.6) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.05).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 1.05).sin()); let footvertlb = (anim_time as f32 * 16.0 * lab as f32 + PI * (-0.4)).sin(); let foothorirb = (((1.0) - / (0.4 - + (0.6) - * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.05).sin()) - .powf(2.0 as f32))) + / (0.4 + (0.6) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.05).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.05).sin()); let footvertrb = (anim_time as f32 * 16.0 * lab as f32 + PI * 0.6).sin(); diff --git a/voxygen/src/anim/src/quadruped_low/tailwhip.rs b/voxygen/src/anim/src/quadruped_low/tailwhip.rs index 9bd910d812..c242defe31 100644 --- a/voxygen/src/anim/src/quadruped_low/tailwhip.rs +++ b/voxygen/src/anim/src/quadruped_low/tailwhip.rs @@ -31,11 +31,11 @@ impl Animation for TailwhipAnimation { (anim_time as f32 * 15.0).sin(), 0.0, ), - Some(StageSection::Swing) => (1.0, (anim_time as f32).powf(4.0), 0.0, 1.0, 0.0), + Some(StageSection::Swing) => (1.0, (anim_time as f32).powi(4), 0.0, 1.0, 0.0), Some(StageSection::Recover) => ( 1.0, 1.0, - (anim_time as f32).powf(6.0), + (anim_time as f32).powi(6), 1.0, (anim_time as f32 * 7.0).sin(), ), diff --git a/voxygen/src/anim/src/quadruped_medium/alpha.rs b/voxygen/src/anim/src/quadruped_medium/alpha.rs index 8dd053e555..cc8a0bf855 100644 --- a/voxygen/src/anim/src/quadruped_medium/alpha.rs +++ b/voxygen/src/anim/src/quadruped_medium/alpha.rs @@ -27,7 +27,7 @@ impl Animation for AlphaAnimation { let (movement1base, movement2base, movement3) = match stage_section { Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0), Some(StageSection::Swing) => (1.0, (anim_time as f32).powf(0.25), 0.0), - Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powf(4.0)), + Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powi(4)), _ => (0.0, 0.0, 0.0), }; let pullback = 1.0 - movement3; diff --git a/voxygen/src/anim/src/quadruped_medium/beta.rs b/voxygen/src/anim/src/quadruped_medium/beta.rs index ae735b8632..81009ac985 100644 --- a/voxygen/src/anim/src/quadruped_medium/beta.rs +++ b/voxygen/src/anim/src/quadruped_medium/beta.rs @@ -26,8 +26,8 @@ impl Animation for BetaAnimation { let (movement1base, movement2base, movement3) = match stage_section { Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0), - Some(StageSection::Swing) => (1.0, (anim_time as f32).powf(0.5), 0.0), - Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powf(4.0)), + Some(StageSection::Swing) => (1.0, (anim_time as f32).sqrt(), 0.0), + Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powi(4)), _ => (0.0, 0.0, 0.0), }; let pullback = 1.0 - movement3; diff --git a/voxygen/src/anim/src/quadruped_medium/dash.rs b/voxygen/src/anim/src/quadruped_medium/dash.rs index 888ca96fb6..08d3aba41d 100644 --- a/voxygen/src/anim/src/quadruped_medium/dash.rs +++ b/voxygen/src/anim/src/quadruped_medium/dash.rs @@ -27,15 +27,11 @@ impl Animation for DashAnimation { let (movement1base, chargemovementbase, movement2base, movement3, legtell) = match stage_section { - Some(StageSection::Buildup) => ( - (anim_time as f32).powf(0.5), - 0.0, - 0.0, - 0.0, - (anim_time as f32), - ), + Some(StageSection::Buildup) => { + ((anim_time as f32).sqrt(), 0.0, 0.0, 0.0, (anim_time as f32)) + }, Some(StageSection::Charge) => (1.0, 1.0, 0.0, 0.0, 0.0), - Some(StageSection::Swing) => (1.0, 1.0, (anim_time as f32).powf(4.0), 0.0, 1.0), + Some(StageSection::Swing) => (1.0, 1.0, (anim_time as f32).powi(4), 0.0, 1.0), Some(StageSection::Recover) => (1.0, 1.0, 1.0, anim_time as f32, 1.0), _ => (0.0, 0.0, 0.0, 0.0, 0.0), }; @@ -53,8 +49,7 @@ impl Animation for DashAnimation { let legtwitch = (legtell * 6.0).sin() * pullback; let legswing = legtell * pullback; let short = (((1.0) - / (0.72 - + 0.28 * ((anim_time as f32 * 16.0 as f32 + PI * 0.25).sin()).powf(2.0 as f32))) + / (0.72 + 0.28 * ((anim_time as f32 * 16.0 as f32 + PI * 0.25).sin()).powi(2))) .sqrt()) * ((anim_time as f32 * 16.0 as f32 + PI * 0.25).sin()) * chargemovementbase diff --git a/voxygen/src/anim/src/quadruped_medium/hoof.rs b/voxygen/src/anim/src/quadruped_medium/hoof.rs index 187b96631f..20338b07f2 100644 --- a/voxygen/src/anim/src/quadruped_medium/hoof.rs +++ b/voxygen/src/anim/src/quadruped_medium/hoof.rs @@ -30,7 +30,7 @@ impl Animation for HoofAnimation { Some(StageSection::Swing) => { (1.0, (anim_time as f32).powf(0.25), 0.0, anim_time as f32) }, - Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powf(4.0), 1.0), + Some(StageSection::Recover) => (1.0, 1.0, (anim_time as f32).powi(4), 1.0), _ => (0.0, 0.0, 0.0, 0.0), }; let pullback = 1.0 - movement3; diff --git a/voxygen/src/anim/src/quadruped_medium/leapmelee.rs b/voxygen/src/anim/src/quadruped_medium/leapmelee.rs index b0f1463261..91888d00d2 100644 --- a/voxygen/src/anim/src/quadruped_medium/leapmelee.rs +++ b/voxygen/src/anim/src/quadruped_medium/leapmelee.rs @@ -28,7 +28,7 @@ impl Animation for LeapMeleeAnimation { Some(StageSection::Buildup) => ((anim_time as f32).powf(0.25), 0.0, 0.0, 0.0), Some(StageSection::Movement) => (1.0, anim_time as f32, 0.0, 0.0), Some(StageSection::Swing) => (1.0, 1.0, anim_time as f32, 0.0), - Some(StageSection::Recover) => (0.0, 1.0, 1.0, (anim_time as f32).powf(4.0)), + Some(StageSection::Recover) => (0.0, 1.0, 1.0, (anim_time as f32).powi(4)), _ => (0.0, 0.0, 0.0, 0.0), }; let pullback = 1.0 - movement4; diff --git a/voxygen/src/anim/src/quadruped_medium/run.rs b/voxygen/src/anim/src/quadruped_medium/run.rs index 09e51b33f4..b1f88f4755 100644 --- a/voxygen/src/anim/src/quadruped_medium/run.rs +++ b/voxygen/src/anim/src/quadruped_medium/run.rs @@ -27,16 +27,16 @@ impl Animation for RunAnimation { //let increasefreqtest = (((1.0/speed)*3.0).round()).min(5.0); let lab = 0.72; //0.72 let amplitude = (speed / 24.0).max(0.25); - let amplitude2 = (speed * 1.4 / 24.0).powf(0.5).max(0.6); - let amplitude3 = (speed / 24.0).powf(0.5).max(0.35); + let amplitude2 = (speed * 1.4 / 24.0).sqrt().max(0.6); + let amplitude3 = (speed / 24.0).sqrt().max(0.35); let speedmult = s_a.tempo; - let canceler = (speed / 24.0).powf(0.5); + let canceler = (speed / 24.0).sqrt(); let short = (((1.0) / (0.72 + 0.28 * ((anim_time as f32 * (16.0) * lab as f32 * speedmult + PI * -0.15 - 0.5) .sin()) - .powf(2.0 as f32))) + .powi(2))) .sqrt()) * ((anim_time as f32 * (16.0) * lab as f32 * speedmult + PI * -0.15 - 0.5).sin()); diff --git a/voxygen/src/anim/src/quadruped_small/alpha.rs b/voxygen/src/anim/src/quadruped_small/alpha.rs index 661f1189da..37f03c3f1b 100644 --- a/voxygen/src/anim/src/quadruped_small/alpha.rs +++ b/voxygen/src/anim/src/quadruped_small/alpha.rs @@ -25,8 +25,8 @@ impl Animation for AlphaAnimation { let mut next = (*skeleton).clone(); let (movement1base, movement2base, movement3) = match stage_section { - Some(StageSection::Buildup) => ((anim_time as f32).powf(0.5), 0.0, 0.0), - Some(StageSection::Swing) => (1.0, (anim_time as f32).powf(4.0), 0.0), + Some(StageSection::Buildup) => ((anim_time as f32).sqrt(), 0.0, 0.0), + Some(StageSection::Swing) => (1.0, (anim_time as f32).powi(4), 0.0), Some(StageSection::Recover) => (1.0, 1.0, anim_time as f32), _ => (0.0, 0.0, 0.0), }; diff --git a/voxygen/src/anim/src/theropod/alpha.rs b/voxygen/src/anim/src/theropod/alpha.rs index 64f8e6f6e1..88d69ca6f3 100644 --- a/voxygen/src/anim/src/theropod/alpha.rs +++ b/voxygen/src/anim/src/theropod/alpha.rs @@ -25,8 +25,8 @@ impl Animation for AlphaAnimation { let mut next = (*skeleton).clone(); let (movement1base, movement2base, movement3) = match stage_section { - Some(StageSection::Buildup) => ((anim_time as f32).powf(2.0), 0.0, 0.0), - Some(StageSection::Swing) => (1.0, (anim_time as f32).powf(4.0), 0.0), + Some(StageSection::Buildup) => ((anim_time as f32).powi(2), 0.0, 0.0), + Some(StageSection::Swing) => (1.0, (anim_time as f32).powi(4), 0.0), Some(StageSection::Recover) => (1.0, 1.0, anim_time as f32), _ => (0.0, 0.0, 0.0), }; diff --git a/voxygen/src/anim/src/theropod/beta.rs b/voxygen/src/anim/src/theropod/beta.rs index 154f3f178e..c1a523fd7f 100644 --- a/voxygen/src/anim/src/theropod/beta.rs +++ b/voxygen/src/anim/src/theropod/beta.rs @@ -25,8 +25,8 @@ impl Animation for BetaAnimation { let mut next = (*skeleton).clone(); let (movement1base, movement2base, movement3) = match stage_section { - Some(StageSection::Buildup) => ((anim_time as f32).powf(2.0), 0.0, 0.0), - Some(StageSection::Swing) => (1.0, (anim_time as f32).powf(4.0), 0.0), + Some(StageSection::Buildup) => ((anim_time as f32).powi(2), 0.0, 0.0), + Some(StageSection::Swing) => (1.0, (anim_time as f32).powi(4), 0.0), Some(StageSection::Recover) => (1.0, 1.0, anim_time as f32), _ => (0.0, 0.0, 0.0), }; diff --git a/voxygen/src/anim/src/theropod/run.rs b/voxygen/src/anim/src/theropod/run.rs index 6279827b52..e380ea3e97 100644 --- a/voxygen/src/anim/src/theropod/run.rs +++ b/voxygen/src/anim/src/theropod/run.rs @@ -42,7 +42,7 @@ impl Animation for RunAnimation { + 0.28 * ((anim_time as f32 * (16.0) * lab as f32 * speedmult + PI * -0.15 - 0.5) .sin()) - .powf(2.0 as f32))) + .powi(2))) .sqrt()) * ((anim_time as f32 * (16.0) * lab as f32 * speedmult + PI * -0.15 - 0.5).sin()); diff --git a/voxygen/src/audio/ambient.rs b/voxygen/src/audio/ambient.rs index 4a46a65fcf..0742bb5278 100644 --- a/voxygen/src/audio/ambient.rs +++ b/voxygen/src/audio/ambient.rs @@ -76,7 +76,7 @@ impl AmbientMgr { // the lower wind volume. The trees make more of an impact // the closer the camera is to the ground. self.tree_multiplier = - ((1.0 - tree_density) + ((cam_pos.z - terrain_alt) / 150.0).powf(2.0)).min(1.0); + ((1.0 - tree_density) + ((cam_pos.z - terrain_alt) / 150.0).powi(2)).min(1.0); let mut volume_multiplier = alt_multiplier * self.tree_multiplier; diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 866e82a97f..d1a5048653 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -601,7 +601,7 @@ impl FigureMgr { if (i as u64 + tick) % (1 + ((pos.0.distance_squared(focus_pos).powf(0.25) - - MIN_PERFECT_RATE_DIST.powf(0.5)) + - MIN_PERFECT_RATE_DIST.sqrt()) .max(0.0) / 3.0) as u64) != 0 @@ -3630,9 +3630,9 @@ impl FigureMgr { let figure_low_detail_distance = figure_lod_render_distance * 0.75; let figure_mid_detail_distance = figure_lod_render_distance * 0.5; - let model = if pos.distance_squared(cam_pos) > figure_low_detail_distance.powf(2.0) { + let model = if pos.distance_squared(cam_pos) > figure_low_detail_distance.powi(2) { &model_entry.models[2] - } else if pos.distance_squared(cam_pos) > figure_mid_detail_distance.powf(2.0) { + } else if pos.distance_squared(cam_pos) > figure_mid_detail_distance.powi(2) { &model_entry.models[1] } else { &model_entry.models[0] diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 4b3e569b64..b18df92b1a 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -563,7 +563,7 @@ impl Scene { light_anim.col != Rgb::zero() && light_anim.strength > 0.0 && (pos.0.distance_squared(player_pos) as f32) - < loaded_distance.powf(2.0) + LIGHT_DIST_RADIUS + < loaded_distance.powi(2) + LIGHT_DIST_RADIUS }) .map(|(pos, ori, interpolated, light_anim)| { // Use interpolated values if they are available @@ -617,7 +617,7 @@ impl Scene { .filter(|(_, _, _, _, health)| !health.is_dead) .filter(|(pos, _, _, _, _)| { (pos.0.distance_squared(player_pos) as f32) - < (loaded_distance.min(SHADOW_MAX_DIST) + SHADOW_DIST_RADIUS).powf(2.0) + < (loaded_distance.min(SHADOW_MAX_DIST) + SHADOW_DIST_RADIUS).powi(2) }) .map(|(pos, interpolated, scale, _, _)| { Shadow::new( diff --git a/voxygen/src/scene/terrain.rs b/voxygen/src/scene/terrain.rs index ab504881f6..9f6ca7c6b5 100644 --- a/voxygen/src/scene/terrain.rs +++ b/voxygen/src/scene/terrain.rs @@ -841,7 +841,7 @@ impl Terrain { // boundary let nearest_in_chunk = Vec2::from(focus_pos).clamped(chunk_pos, chunk_pos + chunk_sz); let distance_2 = Vec2::::from(focus_pos).distance_squared(nearest_in_chunk); - let in_range = distance_2 < loaded_distance.powf(2.0); + let in_range = distance_2 < loaded_distance.powi(2); chunk.visible.in_range = in_range; @@ -1150,7 +1150,7 @@ impl Terrain { .min(Vec2::from(cam_pos).distance_squared( chunk_center + chunk_size.x * 0.5 - chunk_size.y * 0.5, )); - if focus_dist_sqrd < sprite_render_distance.powf(2.0) { + if focus_dist_sqrd < sprite_render_distance.powi(2) { for (kind, instances) in (&chunk.sprite_instances).into_iter() { let SpriteData { model, locals, .. } = if kind .0 @@ -1159,14 +1159,14 @@ impl Terrain { .map(|config| config.wind_sway >= 0.4) .unwrap_or(false) && dist_sqrd <= chunk_mag - || dist_sqrd < sprite_high_detail_distance.powf(2.0) + || dist_sqrd < sprite_high_detail_distance.powi(2) { &self.sprite_data[&kind][0] - } else if dist_sqrd < sprite_hid_detail_distance.powf(2.0) { + } else if dist_sqrd < sprite_hid_detail_distance.powi(2) { &self.sprite_data[&kind][1] - } else if dist_sqrd < sprite_mid_detail_distance.powf(2.0) { + } else if dist_sqrd < sprite_mid_detail_distance.powi(2) { &self.sprite_data[&kind][2] - } else if dist_sqrd < sprite_low_detail_distance.powf(2.0) { + } else if dist_sqrd < sprite_low_detail_distance.powi(2) { &self.sprite_data[&kind][3] } else { &self.sprite_data[&kind][4] diff --git a/world/examples/turb.rs b/world/examples/turb.rs index 8249feba9c..ba1df7190f 100644 --- a/world/examples/turb.rs +++ b/world/examples/turb.rs @@ -22,7 +22,7 @@ fn main() { let pos = pos * 10.0; - let pos = (0..10).fold(pos, |pos, _| pos.map(|e| e.powf(3.0) - 1.0)); + let pos = (0..10).fold(pos, |pos, _| pos.map(|e| e.powi(3) - 1.0)); let val = if pos.map(|e| e.abs() < 0.5).reduce_and() { 1.0f32 diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 5d4103c64b..a7f3c4c156 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -85,7 +85,7 @@ impl<'a> BlockGen<'a> { .gen_ctx .warp_nz .get(wposf.div(24.0)) - .mul((chaos - 0.1).max(0.0).min(1.0).powf(2.0)) + .mul((chaos - 0.1).max(0.0).min(1.0).powi(2)) .mul(16.0); let warp = Lerp::lerp(0.0, warp, warp_factor); @@ -125,7 +125,7 @@ impl<'a> BlockGen<'a> { } else if (wposf.z as f32) < height { let grass_factor = (wposf.z as f32 - (height - grass_depth)) .div(grass_depth) - .powf(0.5); + .sqrt(); let col = Lerp::lerp(sub_surface_color, surface_color, grass_factor); // Surface Some(Block::new( @@ -144,7 +144,7 @@ impl<'a> BlockGen<'a> { } .or_else(|| { // Rocks - if (height + 2.5 - wposf.z as f32).div(7.5).abs().powf(2.0) < rock { + if (height + 2.5 - wposf.z as f32).div(7.5).abs().powi(2) < rock { #[allow(clippy::identity_op)] let field0 = RandomField::new(world.seed + 0); let field1 = RandomField::new(world.seed + 1); diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index fb990d9d95..a3f420eb88 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -674,7 +674,7 @@ fn walk_in_dir(sim: &WorldSim, a: Vec2, dir: Vec2) -> Option { let a_chunk = sim.get(a)?; let b_chunk = sim.get(a + dir)?; - let hill_cost = ((b_chunk.alt - a_chunk.alt).abs() / 5.0).powf(2.0); + let hill_cost = ((b_chunk.alt - a_chunk.alt).abs() / 5.0).powi(2); let water_cost = if b_chunk.river.near_water() { 50.0 } else { diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index c22d0f8409..04aa0231fa 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -238,7 +238,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { let river_width = Lerp::lerp( river_width_min, river_width_max, - river_t.max(0.0).min(1.0).powf(0.5), + river_t.max(0.0).min(1.0).sqrt(), ); let river_width = river_width * (1.0 + river_width_noise * 0.3); @@ -716,7 +716,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { .div(100.0) .into_array(), ) as f32) - //.mul(water_dist.map(|wd| (wd / 2.0).clamped(0.0, 1.0).powf(0.5)).unwrap_or(1.0)) + //.mul(water_dist.map(|wd| (wd / 2.0).clamped(0.0, 1.0).sqrt()).unwrap_or(1.0)) .mul(rockiness) .sub(0.4) .max(0.0) @@ -745,7 +745,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { let wposf3d = Vec3::new(wposf.x, wposf.y, alt as f64); let marble_small = (sim.gen_ctx.hill_nz.get((wposf3d.div(3.0)).into_array()) as f32) - .powf(3.0) + .powi(3) .add(1.0) .mul(0.5); let marble_mid = (sim.gen_ctx.hill_nz.get((wposf3d.div(12.0)).into_array()) as f32) diff --git a/world/src/layer/mod.rs b/world/src/layer/mod.rs index 9bf7d1b1f1..1891bf1e6a 100644 --- a/world/src/layer/mod.rs +++ b/world/src/layer/mod.rs @@ -118,8 +118,8 @@ pub fn apply_caves_to(canvas: &mut Canvas) { let cave_x = (cave_dist / cave.width).min(1.0); // Relative units - let cave_floor = 0.0 - 0.5 * (1.0 - cave_x.powf(2.0)).max(0.0).sqrt() * cave.width; - let cave_height = (1.0 - cave_x.powf(2.0)).max(0.0).sqrt() * cave.width; + let cave_floor = 0.0 - 0.5 * (1.0 - cave_x.powi(2)).max(0.0).sqrt() * cave.width; + let cave_height = (1.0 - cave_x.powi(2)).max(0.0).sqrt() * cave.width; // Abs units let cave_base = (cave.alt + cave_floor) as i32; @@ -222,7 +222,7 @@ pub fn apply_caves_supplement<'a>( let cave_x = (cave_dist / cave.width).min(1.0); // Relative units - let cave_floor = 0.0 - 0.5 * (1.0 - cave_x.powf(2.0)).max(0.0).sqrt() * cave.width; + let cave_floor = 0.0 - 0.5 * (1.0 - cave_x.powi(2)).max(0.0).sqrt() * cave.width; // Abs units let cave_base = (cave.alt + cave_floor) as i32; diff --git a/world/src/lib.rs b/world/src/lib.rs index cc7bcfaf1f..c36ebed098 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -205,7 +205,7 @@ impl World { index.sites[**id] .get_origin() .distance_squared(chunk_center_wpos2d) as f32 - <= index.sites[**id].radius().powf(2.0) + <= index.sites[**id].radius().powi(2) }) .min_by_key(|id| { index.sites[**id] diff --git a/world/src/sim/erosion.rs b/world/src/sim/erosion.rs index 3c5e96e264..aed89171d0 100644 --- a/world/src/sim/erosion.rs +++ b/world/src/sim/erosion.rs @@ -925,7 +925,7 @@ fn erode( }; // Higher rock strength tends to lead to higher curvature? - let kd_factor = (max_slope / mid_slope).powf(2.0); + let kd_factor = (max_slope / mid_slope).powi(2); let k_da = k_da * kd_factor; let mwrec_i = &mwrec[posi]; diff --git a/world/src/sim/map.rs b/world/src/sim/map.rs index 63384a1de3..59b9a0f947 100644 --- a/world/src/sim/map.rs +++ b/world/src/sim/map.rs @@ -157,7 +157,7 @@ pub fn sample_pos( Lerp::lerp( sample.sub_surface_color, sample.surface_color, - ((wposz as f32 - (alt - grass_depth)) / grass_depth).powf(0.5), + ((wposz as f32 - (alt - grass_depth)) / grass_depth).sqrt(), ) .map(|e| e as f64) } diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index d0beeefa2f..d2c465eb0f 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -492,7 +492,7 @@ impl WorldSim { .set_frequency((10_000.0 / continent_scale) as f64) // persistence = lacunarity^(-(1.0 - fractal increment)) .set_lacunarity(util::HybridMulti::DEFAULT_LACUNARITY) - .set_persistence(util::HybridMulti::DEFAULT_LACUNARITY.powf(-(1.0 - 0.0))) + .set_persistence(util::HybridMulti::DEFAULT_LACUNARITY.powi(-1)) .set_offset(0.0) .set_seed(rng.gen()), temp_nz: Fbm::new() @@ -530,7 +530,7 @@ impl WorldSim { .set_lacunarity(rock_lacunarity) // persistence = lacunarity^(-(1.0 - fractal increment)) // NOTE: In paper, fractal increment is roughly 0.25. - .set_persistence(rock_lacunarity.powf(-(1.0 - 0.25))) + .set_persistence(rock_lacunarity.powf(-0.75)) .set_frequency( 1.0 * (5_000.0 / continent_scale) / (2.0 * TerrainChunkSize::RECT_SIZE.x as f64 * 2.0.powi(10 - 1)), @@ -749,7 +749,7 @@ impl WorldSim { .mul(0.3) .add(1.0) .mul(0.4) - + spring(alt_main.abs().powf(0.5).min(0.75).mul(60.0).sin(), 4.0).mul(0.045) + + spring(alt_main.abs().sqrt().min(0.75).mul(60.0).sin(), 4.0).mul(0.045) }; // Now we can compute the final altitude using chaos. @@ -815,7 +815,7 @@ impl WorldSim { None } else { let oheight = alt_old_no_ocean[posi].0 as f64 - 0.5; - let height = (oheight + 0.5).powf(2.0); + let height = (oheight + 0.5).powi(2); Some(height) } }); @@ -2199,7 +2199,7 @@ impl SimChunk { let soil_nz = gen_ctx.hill_nz.get(wposf.div(96.0).into_array()) as f32; let soil_nz = (soil_nz + 1.0) * 0.5; const SOIL_SCALE: f32 = 16.0; - let soil = soil_nz * SOIL_SCALE * tree_density.powf(0.5) * humidity.powf(0.5); + let soil = soil_nz * SOIL_SCALE * tree_density.sqrt() * humidity.sqrt(); dune + soil }; diff --git a/world/src/sim/way.rs b/world/src/sim/way.rs index 350e522d63..1f8b4252e3 100644 --- a/world/src/sim/way.rs +++ b/world/src/sim/way.rs @@ -37,9 +37,7 @@ impl Path { /// Return the number of blocks of headspace required at the given path /// distance /// TODO: make this generic over width - pub fn head_space(&self, dist: f32) -> i32 { - (8 - (dist * 0.25).powf(6.0).round() as i32).max(1) - } + pub fn head_space(&self, dist: f32) -> i32 { (8 - (dist * 0.25).powi(6).round() as i32).max(1) } /// Get the surface colour of a path given the surrounding surface color pub fn surface_color(&self, col: Rgb) -> Rgb { col.map(|e| (e as f32 * 0.7) as u8) } diff --git a/world/src/site/dungeon/mod.rs b/world/src/site/dungeon/mod.rs index 10231c77f2..87b5098cd5 100644 --- a/world/src/site/dungeon/mod.rs +++ b/world/src/site/dungeon/mod.rs @@ -1105,9 +1105,9 @@ impl Floor { let make_staircase = move |pos: Vec3, radius: f32, inner_radius: f32, stretch: f32| { let stone = BlockMask::new(Block::new(BlockKind::Rock, colors.stone.into()), 5); - if (pos.xy().magnitude_squared() as f32) < inner_radius.powf(2.0) { + if (pos.xy().magnitude_squared() as f32) < inner_radius.powi(2) { stone - } else if (pos.xy().magnitude_squared() as f32) < radius.powf(2.0) { + } else if (pos.xy().magnitude_squared() as f32) < radius.powi(2) { if ((pos.x as f32).atan2(pos.y as f32) / (f32::consts::PI * 2.0) * stretch + (floor_z + pos.z) as f32) .rem_euclid(stretch) @@ -1163,7 +1163,7 @@ impl Floor { Some(Tile::Solid) => BlockMask::nothing(), Some(Tile::Tunnel) => { if dist_to_wall >= wall_thickness - && (z as f32) < tunnel_height * (1.0 - tunnel_dist.powf(4.0)) + && (z as f32) < tunnel_height * (1.0 - tunnel_dist.powi(4)) { if z == 0 { floor_sprite } else { vacant } } else { @@ -1173,15 +1173,14 @@ impl Floor { Some(Tile::Room(room)) | Some(Tile::DownStair(room)) if dist_to_wall < wall_thickness || z as f32 - >= self.rooms[*room].height as f32 * (1.0 - tunnel_dist.powf(4.0)) + >= self.rooms[*room].height as f32 * (1.0 - tunnel_dist.powi(4)) || self.rooms[*room] .pillars .map(|pillar_space| { tile_pos .map(|e| e.rem_euclid(pillar_space) == 0) .reduce_and() - && rtile_pos.map(|e| e as f32).magnitude_squared() - < 3.5f32.powf(2.0) + && rtile_pos.map(|e| e as f32).magnitude_squared() < 3.5f32.powi(2) }) .unwrap_or(false) => { diff --git a/world/src/site/settlement/building/archetype/keep.rs b/world/src/site/settlement/building/archetype/keep.rs index 99f9a31977..96d371b949 100644 --- a/world/src/site/settlement/building/archetype/keep.rs +++ b/world/src/site/settlement/building/archetype/keep.rs @@ -174,9 +174,9 @@ impl Archetype for Keep { let make_staircase = move |pos: Vec3, radius: f32, inner_radius: f32, stretch: f32| { let stone = BlockMask::new(Block::new(BlockKind::Rock, dungeon_stone.into()), 5); - if (pos.xy().magnitude_squared() as f32) < inner_radius.powf(2.0) { + if (pos.xy().magnitude_squared() as f32) < inner_radius.powi(2) { stone - } else if (pos.xy().magnitude_squared() as f32) < radius.powf(2.0) { + } else if (pos.xy().magnitude_squared() as f32) < radius.powi(2) { if ((pos.x as f32).atan2(pos.y as f32) / (std::f32::consts::PI * 2.0) * stretch + pos.z as f32) .rem_euclid(stretch) @@ -205,7 +205,7 @@ impl Archetype for Keep { let door_height = 6; let rampart_height = roof_height + if ridge_x % 2 == 0 { 3 } else { 4 }; let min_dist = if attr.rounded { - bound_offset.map(|e| e.pow(2) as f32).sum().powf(0.5) as i32 + bound_offset.map(|e| e.pow(2) as f32).sum().sqrt() as i32 } else { bound_offset.map(|e| e.abs()).reduce_max() }; diff --git a/world/src/site/settlement/mod.rs b/world/src/site/settlement/mod.rs index edc7c192cd..8add7e55fb 100644 --- a/world/src/site/settlement/mod.rs +++ b/world/src/site/settlement/mod.rs @@ -221,7 +221,7 @@ impl Settlement { /// Testing only pub fn place_river(&mut self, rng: &mut impl Rng) { let river_dir = Vec2::new(rng.gen::() - 0.5, rng.gen::() - 0.5).normalized(); - let radius = 500.0 + rng.gen::().powf(2.0) * 1000.0; + let radius = 500.0 + rng.gen::().powi(2) * 1000.0; let river = self.land.new_plot(Plot::Water); let river_offs = Vec2::new(rng.gen_range(-3, 4), rng.gen_range(-3, 4)); @@ -1133,7 +1133,7 @@ impl Land { let center_tile = self.tile_at(neighbors[4].0.map(to_tile)); if let Some(tower) = center_tile.and_then(|tile| tile.tower.as_ref()) { - if (neighbors[4].0.distance_squared(pos) as f32) < tower.radius().powf(2.0) { + if (neighbors[4].0.distance_squared(pos) as f32) < tower.radius().powi(2) { sample.tower = Some((tower, neighbors[4].0)); } } diff --git a/world/src/util/fast_noise.rs b/world/src/util/fast_noise.rs index 43b595a015..8caa007639 100644 --- a/world/src/util/fast_noise.rs +++ b/world/src/util/fast_noise.rs @@ -37,7 +37,7 @@ impl Sampler<'static> for FastNoise { let factor = pos.map(|e| { let f = e.fract().add(1.0).fract() as f32; - f.powf(2.0) * (3.0 - 2.0 * f) + f.powi(2) * (3.0 - 2.0 * f) }); let x00 = v000 + factor.x * (v100 - v000);