Merge branch 'timo-voxygen-warnings' into 'master'

Fix warnings all around voxygen

See merge request veloren/veloren!304
This commit is contained in:
Joshua Barretto 2019-07-04 12:11:30 +00:00
commit d1ccd88fab
11 changed files with 28 additions and 126 deletions

View File

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

View File

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

View File

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

View File

@ -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<f32> = 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()) {

View File

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

View File

@ -58,16 +58,6 @@ impl<V: BaseVol<Vox = Block> + 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<V: BaseVol<Vox = Block> + 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,

View File

@ -15,12 +15,10 @@ fn get_ao_quad<V: ReadVol>(
pos: Vec3<i32>,
shift: Vec3<i32>,
dirs: &[Vec3<i32>],
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<V: ReadVol>(
.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<P: Pipeline, F: Fn(Vec3<f32>, Vec3<f32>, Rgb<f32>, f32, f32) -> P
darkness_ao: Vec4<(f32, f32)>,
vcons: &F,
) -> Quad<P> {
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,
));
}

View File

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

View File

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

View File

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

View File

@ -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<RefCell<Client>>, _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<f32> = 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();