From fdcbf163c8612a3a9e8ad113936f39ef1ef65a2f Mon Sep 17 00:00:00 2001 From: timokoesters Date: Thu, 4 Jul 2019 14:02:26 +0200 Subject: [PATCH] Fix warnings all around voxygen --- voxygen/src/audio/base.rs | 4 +- voxygen/src/menu/char_selection/mod.rs | 11 +--- voxygen/src/menu/char_selection/ui.rs | 4 +- voxygen/src/menu/main/mod.rs | 11 +--- voxygen/src/menu/main/start_singleplayer.rs | 10 +++- voxygen/src/mesh/terrain.rs | 17 +----- voxygen/src/mesh/vol.rs | 63 +++------------------ voxygen/src/render/renderer.rs | 3 +- voxygen/src/scene/figure.rs | 9 --- voxygen/src/scene/mod.rs | 2 +- voxygen/src/session.rs | 20 ++----- 11 files changed, 28 insertions(+), 126 deletions(-) diff --git a/voxygen/src/audio/base.rs b/voxygen/src/audio/base.rs index 16f708a300..bd3e99c42a 100644 --- a/voxygen/src/audio/base.rs +++ b/voxygen/src/audio/base.rs @@ -4,7 +4,7 @@ use crossbeam::{ atomic::AtomicCell, channel::{unbounded, Sender}, queue::SegQueue, - sync::{ShardedLock, WaitGroup}, + sync::ShardedLock, }; use rodio::{Decoder, Device, Sink, SpatialSink}; use std::sync::{Arc, Condvar, Mutex}; @@ -220,7 +220,7 @@ impl Jukebox { // TODO: The `update` function should associate with `conrod` to visualise the audio playlist // and settings. - pub(crate) fn update(&mut self, msg: AudioPlayerMsg) { + pub(crate) fn update(&mut self, _msg: AudioPlayerMsg) { unimplemented!() } diff --git a/voxygen/src/menu/char_selection/mod.rs b/voxygen/src/menu/char_selection/mod.rs index 3aeee92da1..1537833c1b 100644 --- a/voxygen/src/menu/char_selection/mod.rs +++ b/voxygen/src/menu/char_selection/mod.rs @@ -12,7 +12,6 @@ use log::error; use scene::Scene; use std::{cell::RefCell, rc::Rc, time::Duration}; use ui::CharSelectionUi; -use vek::*; pub struct CharSelectionState { char_selection_ui: CharSelectionUi, @@ -31,14 +30,6 @@ impl CharSelectionState { } } -// Background colour -const BG_COLOR: Rgba = Rgba { - r: 0.0, - g: 0.3, - b: 1.0, - a: 1.0, -}; - impl PlayState for CharSelectionState { fn play(&mut self, _: Direction, global_state: &mut GlobalState) -> PlayStateResult { // Set up an fps clock. @@ -61,7 +52,7 @@ impl PlayState for CharSelectionState { } } - global_state.window.renderer_mut().clear(BG_COLOR); + global_state.window.renderer_mut().clear(); // Maintain the UI. for event in self diff --git a/voxygen/src/menu/char_selection/ui.rs b/voxygen/src/menu/char_selection/ui.rs index 84cc4b6bbf..b3ed0de920 100644 --- a/voxygen/src/menu/char_selection/ui.rs +++ b/voxygen/src/menu/char_selection/ui.rs @@ -7,7 +7,7 @@ use crate::{ }, window::Window, }; -use common::comp::{humanoid, item::Weapon, quadruped, quadruped_medium}; +use common::comp::{humanoid, item::Weapon}; use conrod_core::{ color, color::TRANSPARENT, @@ -1038,7 +1038,7 @@ impl CharSelectionUi { .font_id(self.fonts.metamorph) .color(TEXT_COLOR_2) .set(self.ids.beard_text, ui_widgets); - if let Some(val) = ImageSlider::continuous( + if let Some(_val) = ImageSlider::continuous( 5.0, 0.0, 10.0, diff --git a/voxygen/src/menu/main/mod.rs b/voxygen/src/menu/main/mod.rs index b0f0b609de..b46b076e69 100644 --- a/voxygen/src/menu/main/mod.rs +++ b/voxygen/src/menu/main/mod.rs @@ -10,7 +10,6 @@ use log::warn; use start_singleplayer::StartSingleplayerState; use std::time::Duration; use ui::{Event as MainMenuEvent, MainMenuUi}; -use vek::*; pub struct MainMenuState { main_menu_ui: MainMenuUi, @@ -27,14 +26,6 @@ impl MainMenuState { const DEFAULT_PORT: u16 = 59003; -// Background colour -const BG_COLOR: Rgba = Rgba { - r: 0.0, - g: 0.3, - b: 1.0, - a: 1.0, -}; - impl PlayState for MainMenuState { fn play(&mut self, _: Direction, global_state: &mut GlobalState) -> PlayStateResult { // Set up an fps clock. @@ -57,7 +48,7 @@ impl PlayState for MainMenuState { } } - global_state.window.renderer_mut().clear(BG_COLOR); + global_state.window.renderer_mut().clear(); // Poll client creation. match client_init.as_ref().and_then(|init| init.poll()) { diff --git a/voxygen/src/menu/main/start_singleplayer.rs b/voxygen/src/menu/main/start_singleplayer.rs index 640b3389c5..75eaf54924 100644 --- a/voxygen/src/menu/main/start_singleplayer.rs +++ b/voxygen/src/menu/main/start_singleplayer.rs @@ -8,16 +8,20 @@ use log::warn; use std::net::SocketAddr; pub struct StartSingleplayerState { - singleplayer: Singleplayer, + // Necessary to keep singleplayer working + _singleplayer: Singleplayer, sock: SocketAddr, } impl StartSingleplayerState { /// Create a new `MainMenuState`. pub fn new() -> Self { - let (singleplayer, sock) = Singleplayer::new(None); // TODO: Make client and server use the same thread pool + let (_singleplayer, sock) = Singleplayer::new(None); // TODO: Make client and server use the same thread pool - Self { singleplayer, sock } + Self { + _singleplayer, + sock, + } } } diff --git a/voxygen/src/mesh/terrain.rs b/voxygen/src/mesh/terrain.rs index 839092caa4..49134f4dc0 100644 --- a/voxygen/src/mesh/terrain.rs +++ b/voxygen/src/mesh/terrain.rs @@ -58,16 +58,6 @@ impl + ReadVol + Debug, S: VolSize + Clone> Meshable for // Create mesh polygons if let Some(col) = self.get(pos).ok().and_then(|vox| vox.get_color()) { - let avg_light = neighbour_light - .iter() - .map(|row| row.iter()) - .flatten() - .map(|col| col.iter()) - .flatten() - .fold(0.0, |a, x| a + x) - / 27.0; - let light = avg_light; - let col = col.map(|e| e as f32 / 255.0); let offs = (pos - range.min * Vec3::new(1, 1, 0)).map(|e| e as f32) @@ -80,12 +70,7 @@ impl + ReadVol + Debug, S: VolSize + Clone> Meshable for offs, col, |pos, norm, col, ao, light| { - TerrainVertex::new( - pos, - norm, - Lerp::lerp(Rgb::zero(), col, 1.0), - light * ao, - ) + TerrainVertex::new(pos, norm, col, light * ao) }, false, &neighbour_light, diff --git a/voxygen/src/mesh/vol.rs b/voxygen/src/mesh/vol.rs index 563a520e15..0e98b84511 100644 --- a/voxygen/src/mesh/vol.rs +++ b/voxygen/src/mesh/vol.rs @@ -15,12 +15,10 @@ fn get_ao_quad( pos: Vec3, shift: Vec3, dirs: &[Vec3], - corners: &[[usize; 3]; 4], darknesses: &[[[f32; 3]; 3]; 3], ) -> Vec4<(f32, f32)> { dirs.windows(2) - .enumerate() - .map(|(i, offs)| { + .map(|offs| { let (s1, s2) = ( vol.get(pos + shift + offs[0]) .map(|v| !v.is_empty()) @@ -30,8 +28,6 @@ fn get_ao_quad( .unwrap_or(false), ); - let darkness = darknesses[corners[i][0]][corners[i][1]][corners[i][2]]; - let darkness = darknesses .iter() .map(|x| x.iter().map(|y| y.iter())) @@ -70,9 +66,6 @@ fn create_quad, Vec3, Rgb, f32, f32) -> P darkness_ao: Vec4<(f32, f32)>, vcons: &F, ) -> Quad

{ - let ao_scale = 0.95; - let dark = col * (1.0 - ao_scale); - let darkness = darkness_ao.map(|e| e.0); let ao = darkness_ao.map(|e| e.1); @@ -123,14 +116,7 @@ pub fn push_vox_verts< Vec3::unit_y(), -Vec3::unit_x(), col, - get_ao_quad( - vol, - pos, - -Vec3::unit_x(), - &[-z, -y, z, y, -z], - &[[0; 3]; 4], - darknesses, - ), + get_ao_quad(vol, pos, -Vec3::unit_x(), &[-z, -y, z, y, -z], darknesses), &vcons, )); } @@ -146,14 +132,7 @@ pub fn push_vox_verts< Vec3::unit_z(), Vec3::unit_x(), col, - get_ao_quad( - vol, - pos, - Vec3::unit_x(), - &[-y, -z, y, z, -y], - &[[0; 3]; 4], - darknesses, - ), + get_ao_quad(vol, pos, Vec3::unit_x(), &[-y, -z, y, z, -y], darknesses), &vcons, )); } @@ -169,14 +148,7 @@ pub fn push_vox_verts< Vec3::unit_z(), -Vec3::unit_y(), col, - get_ao_quad( - vol, - pos, - -Vec3::unit_y(), - &[-x, -z, x, z, -x], - &[[0; 3]; 4], - darknesses, - ), + get_ao_quad(vol, pos, -Vec3::unit_y(), &[-x, -z, x, z, -x], darknesses), &vcons, )); } @@ -192,14 +164,7 @@ pub fn push_vox_verts< Vec3::unit_x(), Vec3::unit_y(), col, - get_ao_quad( - vol, - pos, - Vec3::unit_y(), - &[-z, -x, z, x, -z], - &[[0; 3]; 4], - darknesses, - ), + get_ao_quad(vol, pos, Vec3::unit_y(), &[-z, -x, z, x, -z], darknesses), &vcons, )); } @@ -215,14 +180,7 @@ pub fn push_vox_verts< Vec3::unit_x(), -Vec3::unit_z(), col, - get_ao_quad( - vol, - pos, - -Vec3::unit_z(), - &[-y, -x, y, x, -y], - &[[0; 3]; 4], - darknesses, - ), + get_ao_quad(vol, pos, -Vec3::unit_z(), &[-y, -x, y, x, -y], darknesses), &vcons, )); } @@ -238,14 +196,7 @@ pub fn push_vox_verts< Vec3::unit_y(), Vec3::unit_z(), col, - get_ao_quad( - vol, - pos, - Vec3::unit_z(), - &[-x, -y, x, y, -x], - &[[0, 0, 1], [1, 0, 1], [1, 1, 1], [0, 1, 1]], - darknesses, - ), + get_ao_quad(vol, pos, Vec3::unit_z(), &[-x, -y, x, y, -x], darknesses), &vcons, )); } diff --git a/voxygen/src/render/renderer.rs b/voxygen/src/render/renderer.rs index 42c65e3e94..94fb819d5d 100644 --- a/voxygen/src/render/renderer.rs +++ b/voxygen/src/render/renderer.rs @@ -228,8 +228,7 @@ impl Renderer { } /// Queue the clearing of the color and depth targets ready for a new frame to be rendered. - /// TODO: Make a version of this that doesn't clear the colour target for speed. - pub fn clear(&mut self, col: Rgba) { + pub fn clear(&mut self) { self.encoder.clear_depth(&self.tgt_depth_view, 1.0); self.encoder.clear_depth(&self.win_depth_view, 1.0); } diff --git a/voxygen/src/scene/figure.rs b/voxygen/src/scene/figure.rs index 108b5cf19a..cbbb7096a9 100644 --- a/voxygen/src/scene/figure.rs +++ b/voxygen/src/scene/figure.rs @@ -13,7 +13,6 @@ use common::{ assets, comp::{self, humanoid, item::Weapon, quadruped, quadruped_medium, Body}, figure::Segment, - state::DeltaTime, terrain::TerrainChunkSize, vol::VolSize, }; @@ -200,13 +199,6 @@ impl FigureModelCache { "figure/head/head_danari_female.vox", Vec3::new(-9.0, -5.5, -2.5), ), - _ => { - warn!("Invalid race, body_type combination for figure head"); - ( - "figure/head/head_human_male.vox", - Vec3::new(-7.0, -5.5, -9.25), - ) - } }; Self::load_mesh(name, offset) } @@ -306,7 +298,6 @@ impl FigureModelCache { Weapon::Sword => ("weapon/sword/rusty_2h.vox", Vec3::new(-1.5, -6.5, -4.0)), Weapon::Hammer => ("weapon/hammer/rusty_2h.vox", Vec3::new(-2.5, -5.5, -4.0)), Weapon::Axe => ("weapon/axe/rusty_2h.vox", Vec3::new(-1.5, -6.5, -4.0)), - Weapon::Sword => ("weapon/sword/wood_2h.vox", Vec3::new(-1.5, -6.5, -4.0)), Weapon::Daggers => ("weapon/hammer/rusty_2h.vox", Vec3::new(-2.5, -5.5, -4.0)), Weapon::SwordShield => ("weapon/axe/rusty_2h.vox", Vec3::new(-2.5, -6.5, -2.0)), Weapon::Bow => ("weapon/hammer/rusty_2h.vox", Vec3::new(-2.5, -5.5, -4.0)), diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 2a511d3a58..548bdc5804 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -41,7 +41,7 @@ pub struct Scene { impl Scene { /// Create a new `Scene` with default parameters. - pub fn new(renderer: &mut Renderer, client: &Client) -> Self { + pub fn new(renderer: &mut Renderer) -> Self { let resolution = renderer.get_resolution().map(|e| e as f32); Self { diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 4acac6be1e..6aee2e34ef 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -9,7 +9,7 @@ use crate::{ }; use client::{self, Client}; use common::{ - clock::Clock, comp, comp::Pos, msg::ClientState, ray::Ray, terrain::block::Block, vol::ReadVol, + clock::Clock, comp, comp::Pos, msg::ClientState, terrain::block::Block, vol::ReadVol, }; use log::{error, warn}; use std::{cell::RefCell, rc::Rc, time::Duration}; @@ -28,7 +28,7 @@ impl SessionState { /// Create a new `SessionState`. pub fn new(window: &mut Window, client: Rc>, _settings: Settings) -> Self { // Create a scene for this session. The scene handles visible elements of the game world. - let scene = Scene::new(window.renderer_mut(), &client.borrow()); + let scene = Scene::new(window.renderer_mut()); Self { scene, client, @@ -39,14 +39,6 @@ impl SessionState { } } -// Background colour -const BG_COLOR: Rgba = Rgba { - r: 0.0, - g: 0.3, - b: 1.0, - a: 1.0, -}; - impl SessionState { /// Tick the session (and the client attached to it). fn tick(&mut self, dt: Duration) -> Result<(), Error> { @@ -72,7 +64,7 @@ impl SessionState { /// This method should be called once per frame. pub fn render(&mut self, renderer: &mut Renderer) { // Clear the screen - renderer.clear(BG_COLOR); + renderer.clear(); // Render the screen using the global renderer self.scene.render(renderer, &mut self.client.borrow_mut()); @@ -120,8 +112,7 @@ impl PlayState for SessionState { .get(client.entity()) .is_some() { - let (view_mat, _, cam_pos) = - self.scene.camera().compute_dependents(&client); + let cam_pos = self.scene.camera().compute_dependents(&client).2; let cam_dir = (self.scene.camera().get_focus_pos() - cam_pos).normalized(); @@ -158,8 +149,7 @@ impl PlayState for SessionState { .get(client.entity()) .is_some() { - let (view_mat, _, cam_pos) = - self.scene.camera().compute_dependents(&client); + let cam_pos = self.scene.camera().compute_dependents(&client).2; let cam_dir = (self.scene.camera().get_focus_pos() - cam_pos).normalized();