From a8981378bfe7906a3c78f0b0b585435f52cbdfe3 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sun, 12 May 2019 18:43:55 +0100 Subject: [PATCH] Improved performance and compilation speed for debug builds Former-commit-id: 5d8b1c27a8a2ebfe63797969ee2aba7452a09dd3 --- Cargo.toml | 4 ++++ common/src/ray.rs | 10 +++++----- server/src/cmd.rs | 14 +++++++++----- voxygen/src/anim/character/idle.rs | 4 ++-- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 533a0add9c..435991041f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,10 @@ members = [ ] [profile.dev] +opt-level = 2 +overflow-checks = false [profile.release] debug = true +codegen-units = 1 +lto = true diff --git a/common/src/ray.rs b/common/src/ray.rs index 49a7e7da37..568dedc4c4 100644 --- a/common/src/ray.rs +++ b/common/src/ray.rs @@ -54,17 +54,17 @@ impl<'a, V: ReadVol, F: RayUntil> Ray<'a, V, F> { pos = self.from + dir * dist; ipos = pos.map(|e| e.floor() as i32); + // Allow one iteration above max + if dist > max { + break; + } + match self.vol.get(ipos).map(|vox| (vox, (self.until)(vox))) { Ok((vox, true)) => return (dist, Ok(Some(vox))), Err(err) if !self.ignore_error => return (dist, Err(err)), _ => {} } - // Allow one iteration above max - if dist > max { - break; - } - let deltas = (dir.map(|e| if e < 0.0 { 0.0 } else { 1.0 }) - pos.map(|e| e.abs().fract())) / dir; diff --git a/server/src/cmd.rs b/server/src/cmd.rs index e92f6da9f8..c2b2642a4b 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -195,11 +195,15 @@ fn handle_pet(server: &mut Server, entity: EcsEntity, args: String, action: &Cha .read_component_cloned::(entity) { Some(pos) => { - server.create_npc(comp::Character::random()) - .with(comp::Control::default()) - .with(comp::Agent::Pet{ target: entity, offset: Vec2::zero() }) - .with(pos) - .build(); + let mut current = entity; + + for _ in 0..1 { + current = server.create_npc(comp::Character::random()) + .with(comp::Control::default()) + .with(comp::Agent::Pet{ target: current, offset: Vec2::zero() }) + .with(pos) + .build(); + } server.clients.notify(entity, ServerMsg::Chat("Pet spawned!".to_owned())); }, None => server.clients.notify(entity, ServerMsg::Chat("You have no position!".to_owned())), diff --git a/voxygen/src/anim/character/idle.rs b/voxygen/src/anim/character/idle.rs index 74472e622b..85c0e03315 100644 --- a/voxygen/src/anim/character/idle.rs +++ b/voxygen/src/anim/character/idle.rs @@ -29,12 +29,12 @@ impl Animation for IdleAnimation { let wave_dip = (wave_slow.abs() - 0.5).abs(); let head_look = Vec2::new( - ((global_time + anim_time) as f32 / 5.0) + ((global_time + anim_time) as f32 / 8.0) .floor() .mul(7331.0) .sin() * 0.5, - ((global_time + anim_time) as f32 / 5.0) + ((global_time + anim_time) as f32 / 8.0) .floor() .mul(1337.0) .sin()