Replaced every unnecssary powf in the entire codebase with either powi or sqrt.

This commit is contained in:
Sam 2020-11-24 18:28:24 -06:00
parent 5461f002fe
commit 33e4448542
70 changed files with 276 additions and 369 deletions

View File

@ -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;

View File

@ -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

View File

@ -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::<f32>::from(update.vel.0).magnitude_squared() < GLIDE_SPEED.powf(2.0)
if Vec2::<f32>::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::<f32>::from(update.vel.0).magnitude() * 0.075)

View File

@ -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);
}

View File

@ -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::<f32>() < 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::<f32>() < 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::<f32>() < 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::<f32>() < 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::<f32>() < 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
}

View File

@ -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,
});

View File

@ -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

View File

@ -32,7 +32,7 @@ impl Entity {
}
pub fn get_level(&self) -> u32 {
(self.rng(PERM_LEVEL).gen::<f32>().powf(2.0) * 15.0).ceil() as u32
(self.rng(PERM_LEVEL).gen::<f32>().powi(2) * 15.0).ceil() as u32
}
pub fn get_loadout(&self, ability_map: &AbilityMap) -> comp::Loadout {

View File

@ -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)
})
};

View File

@ -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());

View File

@ -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),
};

View File

@ -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<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);

View File

@ -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())
}

View File

@ -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();
//

View File

@ -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);

View File

@ -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());

View File

@ -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
};

View File

@ -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());

View File

@ -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);

View File

@ -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),
};

View File

@ -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<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);

View File

@ -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 {

View File

@ -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(

View File

@ -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());

View File

@ -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())
}

View File

@ -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());

View File

@ -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);

View File

@ -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();

View File

@ -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(

View File

@ -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
};

View File

@ -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());

View File

@ -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();

View File

@ -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);

View File

@ -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());

View File

@ -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;

View File

@ -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());

View File

@ -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;

View File

@ -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),
};

View File

@ -27,7 +27,7 @@ impl Animation for BreatheAnimation {
let speed = (Vec2::<f32>::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),

View File

@ -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

View File

@ -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();

View File

@ -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(),
),

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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());

View File

@ -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),
};

View File

@ -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),
};

View File

@ -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),
};

View File

@ -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());

View File

@ -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;

View File

@ -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]

View File

@ -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(

View File

@ -841,7 +841,7 @@ impl<V: RectRasterableVol> Terrain<V> {
// boundary
let nearest_in_chunk = Vec2::from(focus_pos).clamped(chunk_pos, chunk_pos + chunk_sz);
let distance_2 = Vec2::<f32>::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<V: RectRasterableVol> Terrain<V> {
.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<V: RectRasterableVol> Terrain<V> {
.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]

View File

@ -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

View File

@ -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);

View File

@ -674,7 +674,7 @@ fn walk_in_dir(sim: &WorldSim, a: Vec2<i32>, dir: Vec2<i32>) -> Option<f32> {
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 {

View File

@ -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)

View File

@ -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;

View File

@ -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]

View File

@ -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];

View File

@ -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)
}

View File

@ -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
};

View File

@ -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<u8>) -> Rgb<u8> { col.map(|e| (e as f32 * 0.7) as u8) }

View File

@ -1105,9 +1105,9 @@ impl Floor {
let make_staircase = move |pos: Vec3<i32>, 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) =>
{

View File

@ -174,9 +174,9 @@ impl Archetype for Keep {
let make_staircase = move |pos: Vec3<i32>, 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()
};

View File

@ -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::<f32>() - 0.5, rng.gen::<f32>() - 0.5).normalized();
let radius = 500.0 + rng.gen::<f32>().powf(2.0) * 1000.0;
let radius = 500.0 + rng.gen::<f32>().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));
}
}

View File

@ -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);