From 2800c9e9f55aa8ed2136fb131bef80a189320d3c Mon Sep 17 00:00:00 2001 From: Piotr Date: Sat, 20 Apr 2019 20:35:45 +0200 Subject: [PATCH] make 11.0 a const Former-commit-id: 4602f3147b434e93256d48938b813325e74ad551 --- voxygen/src/anim/character/idle.rs | 17 +++++++++-------- voxygen/src/anim/character/mod.rs | 2 ++ voxygen/src/anim/character/run.rs | 17 +++++++++-------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/voxygen/src/anim/character/idle.rs b/voxygen/src/anim/character/idle.rs index 55a0f8f425..9bada97c00 100644 --- a/voxygen/src/anim/character/idle.rs +++ b/voxygen/src/anim/character/idle.rs @@ -8,6 +8,7 @@ use vek::*; use super::{ CharacterSkeleton, super::Animation, + SCALE, }; pub struct IdleAnimation; @@ -22,24 +23,24 @@ impl Animation for IdleAnimation { time: f64, ) -> Self::Skeleton { let mut next = (*skeleton).clone(); - next.head.offset = Vec3::unit_z() * 13.0 / 11.0; + next.head.offset = Vec3::unit_z() * 13.0 / SCALE; next.head.ori = Quaternion::rotation_z(0.0); - next.chest.offset = Vec3::unit_z() * 9.0 / 11.0; + next.chest.offset = Vec3::unit_z() * 9.0 / SCALE; next.chest.ori = Quaternion::rotation_z(0.0); - next.belt.offset = Vec3::unit_z() * 7.0 / 11.0; + next.belt.offset = Vec3::unit_z() * 7.0 / SCALE; next.belt.ori = Quaternion::rotation_z(0.0); - next.shorts.offset = Vec3::unit_z() * 4.0 / 11.0; + next.shorts.offset = Vec3::unit_z() * 4.0 / SCALE; next.shorts.ori = Quaternion::rotation_z(0.0); - next.l_hand.offset = Vec3::new(-8.0, 0.0, 9.0) / 11.0; - next.r_hand.offset = Vec3::new(8.0, 0.0, 9.0 ) / 11.0; + next.l_hand.offset = Vec3::new(-8.0, 0.0, 9.0) / SCALE; + next.r_hand.offset = Vec3::new(8.0, 0.0, 9.0 ) / SCALE; - next.l_foot.offset = Vec3::new(-3.5, 0.0, 3.0) / 11.0; + next.l_foot.offset = Vec3::new(-3.5, 0.0, 3.0) / SCALE; next.l_foot.ori = Quaternion::rotation_x(0.0); - next.r_foot.offset = Vec3::new(3.5, 0.0, 3.0) / 11.0; + next.r_foot.offset = Vec3::new(3.5, 0.0, 3.0) / SCALE; next.r_foot.ori = Quaternion::rotation_x(0.0); next.back.offset = Vec3::new(-9.0, 5.0, 18.0); diff --git a/voxygen/src/anim/character/mod.rs b/voxygen/src/anim/character/mod.rs index f84cc18e09..3d6e3e1dfc 100644 --- a/voxygen/src/anim/character/mod.rs +++ b/voxygen/src/anim/character/mod.rs @@ -14,6 +14,8 @@ use super::{ Bone, }; +const SCALE: f32 = 11.0; + #[derive(Clone)] pub struct CharacterSkeleton { head: Bone, diff --git a/voxygen/src/anim/character/run.rs b/voxygen/src/anim/character/run.rs index abab662168..27da889f95 100644 --- a/voxygen/src/anim/character/run.rs +++ b/voxygen/src/anim/character/run.rs @@ -8,6 +8,7 @@ use vek::*; use super::{ CharacterSkeleton, super::Animation, + SCALE }; pub struct RunAnimation; @@ -26,24 +27,24 @@ impl Animation for RunAnimation { let wave_slow = (time as f32 * 6.0 + PI).sin(); let wave_dip = (wave_slow.abs() - 0.5).abs(); - next.head.offset = Vec3::unit_z() * 13.0 / 11.0; + next.head.offset = Vec3::unit_z() * 13.0 / SCALE; next.head.ori = Quaternion::rotation_z(wave * 0.3); - next.chest.offset = Vec3::unit_z() * 9.0 / 11.0; + next.chest.offset = Vec3::unit_z() * 9.0 / SCALE; next.chest.ori = Quaternion::rotation_z(wave * 0.3); - next.belt.offset = Vec3::unit_z() * 7.0 / 11.0; + next.belt.offset = Vec3::unit_z() * 7.0 / SCALE; next.belt.ori = Quaternion::rotation_z(wave * 0.2); - next.shorts.offset = Vec3::unit_z() * 4.0 / 11.0; + next.shorts.offset = Vec3::unit_z() * 4.0 / SCALE; next.shorts.ori = Quaternion::rotation_z(wave * 0.1); - next.l_hand.offset = Vec3::new(-6.0 - wave_dip * 6.0, wave * 5.0, 11.0 - wave_dip * 6.0) / 11.0; - next.r_hand.offset = Vec3::new(6.0 + wave_dip * 6.0, -wave * 5.0, 11.0 - wave_dip * 6.0) / 11.0; + next.l_hand.offset = Vec3::new(-6.0 - wave_dip * 6.0, wave * 5.0, 11.0 - wave_dip * 6.0) / SCALE; + next.r_hand.offset = Vec3::new(6.0 + wave_dip * 6.0, -wave * 5.0, 11.0 - wave_dip * 6.0) / SCALE; - next.l_foot.offset = Vec3::new(-3.5, 1.0 - wave * 8.0, 3.5 - wave_dip * 4.0) / 11.0; + next.l_foot.offset = Vec3::new(-3.5, 1.0 - wave * 8.0, 3.5 - wave_dip * 4.0) / SCALE; next.l_foot.ori = Quaternion::rotation_x(-wave + 1.0); - next.r_foot.offset = Vec3::new(3.5, 1.0 + wave * 8.0, 3.5 - wave_dip * 4.0) / 11.0; + next.r_foot.offset = Vec3::new(3.5, 1.0 + wave * 8.0, 3.5 - wave_dip * 4.0) / SCALE; next.r_foot.ori = Quaternion::rotation_x(wave + 1.0); next.back.offset = Vec3::new(-9.0, 5.0, 18.0);