mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix all clippy warnings
This commit is contained in:
parent
af1962f11c
commit
ea6985e565
@ -5,7 +5,7 @@ use common::{
|
|||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use vek::*;
|
use vek::*;
|
||||||
use veloren_voxygen::{mesh::Meshable, scene::terrain::BlocksOfInterest};
|
use veloren_voxygen::{mesh::terrain::generate_mesh, scene::terrain::BlocksOfInterest};
|
||||||
use world::{sim, World};
|
use world::{sim, World};
|
||||||
|
|
||||||
const CENTER: Vec2<i32> = Vec2 { x: 512, y: 512 };
|
const CENTER: Vec2<i32> = Vec2 { x: 512, y: 512 };
|
||||||
@ -142,11 +142,10 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
|||||||
let (volume, range) = sample(Vec2::new(x, y));
|
let (volume, range) = sample(Vec2::new(x, y));
|
||||||
meshing_benches.bench_function(&format!("Terrain mesh {}, {}", x, y), move |b| {
|
meshing_benches.bench_function(&format!("Terrain mesh {}, {}", x, y), move |b| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
volume.generate_mesh(black_box((
|
generate_mesh(
|
||||||
range,
|
black_box(&volume),
|
||||||
Vec2::new(8192, 8192),
|
black_box((range, Vec2::new(8192, 8192), &BlocksOfInterest::default())),
|
||||||
&BlocksOfInterest::default(),
|
)
|
||||||
)))
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ enum InitState {
|
|||||||
// Waiting on the client initialization
|
// Waiting on the client initialization
|
||||||
Client(ClientInit),
|
Client(ClientInit),
|
||||||
// Client initialized but still waiting on Renderer pipeline creation
|
// Client initialized but still waiting on Renderer pipeline creation
|
||||||
Pipeline(Client),
|
Pipeline(Box<Client>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InitState {
|
impl InitState {
|
||||||
@ -136,7 +136,7 @@ impl PlayState for MainMenuState {
|
|||||||
Some(InitMsg::Done(Ok(mut client))) => {
|
Some(InitMsg::Done(Ok(mut client))) => {
|
||||||
// Register voxygen components / resources
|
// Register voxygen components / resources
|
||||||
crate::ecs::init(client.state_mut().ecs_mut());
|
crate::ecs::init(client.state_mut().ecs_mut());
|
||||||
self.init = InitState::Pipeline(client);
|
self.init = InitState::Pipeline(Box::new(client));
|
||||||
},
|
},
|
||||||
Some(InitMsg::Done(Err(err))) => {
|
Some(InitMsg::Done(Err(err))) => {
|
||||||
let localized_strings = global_state.i18n.read();
|
let localized_strings = global_state.i18n.read();
|
||||||
@ -319,7 +319,7 @@ impl PlayState for MainMenuState {
|
|||||||
self.main_menu_ui.connected();
|
self.main_menu_ui.connected();
|
||||||
return PlayStateResult::Push(Box::new(CharSelectionState::new(
|
return PlayStateResult::Push(Box::new(CharSelectionState::new(
|
||||||
global_state,
|
global_state,
|
||||||
std::rc::Rc::new(std::cell::RefCell::new(client)),
|
std::rc::Rc::new(std::cell::RefCell::new(*client)),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,6 +224,7 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
|
|||||||
|
|
||||||
#[allow(clippy::collapsible_if)]
|
#[allow(clippy::collapsible_if)]
|
||||||
#[allow(clippy::many_single_char_names)]
|
#[allow(clippy::many_single_char_names)]
|
||||||
|
#[allow(clippy::type_complexity)]
|
||||||
#[allow(clippy::needless_range_loop)] // TODO: Pending review in #587
|
#[allow(clippy::needless_range_loop)] // TODO: Pending review in #587
|
||||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||||
pub fn generate_mesh<'a, V: RectRasterableVol<Vox = Block> + ReadVol + Debug + 'static>(
|
pub fn generate_mesh<'a, V: RectRasterableVol<Vox = Block> + ReadVol + Debug + 'static>(
|
||||||
|
@ -24,6 +24,7 @@ impl<T: Copy + Pod> Buffer<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::len_without_is_empty)]
|
||||||
pub fn len(&self) -> usize { self.len }
|
pub fn len(&self) -> usize { self.len }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,9 +54,9 @@ impl<V: Vertex> Mesh<V> {
|
|||||||
self.verts.push(quad.d);
|
self.verts.push(quad.d);
|
||||||
} else {
|
} else {
|
||||||
// Tri 1
|
// Tri 1
|
||||||
self.verts.push(quad.a.clone());
|
self.verts.push(quad.a);
|
||||||
self.verts.push(quad.b);
|
self.verts.push(quad.b);
|
||||||
self.verts.push(quad.c.clone());
|
self.verts.push(quad.c);
|
||||||
|
|
||||||
// Tri 2
|
// Tri 2
|
||||||
self.verts.push(quad.c);
|
self.verts.push(quad.c);
|
||||||
@ -78,9 +78,9 @@ impl<V: Vertex> Mesh<V> {
|
|||||||
debug_assert!(index % 3 == 0);
|
debug_assert!(index % 3 == 0);
|
||||||
assert!(index + 5 < self.verts.len());
|
assert!(index + 5 < self.verts.len());
|
||||||
// Tri 1
|
// Tri 1
|
||||||
self.verts[index] = quad.a.clone();
|
self.verts[index] = quad.a;
|
||||||
self.verts[index + 1] = quad.b;
|
self.verts[index + 1] = quad.b;
|
||||||
self.verts[index + 2] = quad.c.clone();
|
self.verts[index + 2] = quad.c;
|
||||||
|
|
||||||
// Tri 2
|
// Tri 2
|
||||||
self.verts[index + 3] = quad.c;
|
self.verts[index + 3] = quad.c;
|
||||||
@ -99,7 +99,7 @@ impl<V: Vertex> Mesh<V> {
|
|||||||
self.verts.reserve(other.vertices().len());
|
self.verts.reserve(other.vertices().len());
|
||||||
|
|
||||||
for vert in other.vertices() {
|
for vert in other.vertices() {
|
||||||
self.verts.push(f(vert.clone()));
|
self.verts.push(f(*vert));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,10 +162,10 @@ impl<V: Vertex> Quad<V> {
|
|||||||
let verts = [self.a, self.b, self.c, self.d];
|
let verts = [self.a, self.b, self.c, self.d];
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
a: verts[n % 4].clone(),
|
a: verts[n % 4],
|
||||||
b: verts[(1 + n) % 4].clone(),
|
b: verts[(1 + n) % 4],
|
||||||
c: verts[(2 + n) % 4].clone(),
|
c: verts[(2 + n) % 4],
|
||||||
d: verts[(3 + n) % 4].clone(),
|
d: verts[(3 + n) % 4],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ impl<'a, V: Vertex> SubModel<'a, V> {
|
|||||||
self.buf.slice(start..end)
|
self.buf.slice(start..end)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::len_without_is_empty)]
|
||||||
pub fn len(&self) -> u32 { self.vertex_range.end - self.vertex_range.start }
|
pub fn len(&self) -> u32 { self.vertex_range.end - self.vertex_range.start }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ impl<V: Vertex> Model<V> {
|
|||||||
|
|
||||||
pub(super) fn buf(&self) -> &wgpu::Buffer { &self.vbuf.buf }
|
pub(super) fn buf(&self) -> &wgpu::Buffer { &self.vbuf.buf }
|
||||||
|
|
||||||
|
#[allow(clippy::len_without_is_empty)]
|
||||||
pub fn len(&self) -> usize { self.vbuf.len() }
|
pub fn len(&self) -> usize { self.vbuf.len() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,5 +79,6 @@ impl<V: Vertex> DynamicModel<V> {
|
|||||||
|
|
||||||
pub fn buf(&self) -> &wgpu::Buffer { &self.vbuf.buf }
|
pub fn buf(&self) -> &wgpu::Buffer { &self.vbuf.buf }
|
||||||
|
|
||||||
|
#[allow(clippy::len_without_is_empty)]
|
||||||
pub fn len(&self) -> usize { self.vbuf.len() }
|
pub fn len(&self) -> usize { self.vbuf.len() }
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,7 @@ struct Shadow {
|
|||||||
/// Represent two states of the renderer:
|
/// Represent two states of the renderer:
|
||||||
/// 1. Only interface pipelines created
|
/// 1. Only interface pipelines created
|
||||||
/// 2. All of the pipelines have been created
|
/// 2. All of the pipelines have been created
|
||||||
|
#[allow(clippy::large_enum_variant)] // They are both pretty large
|
||||||
enum State {
|
enum State {
|
||||||
// NOTE: this is used as a transient placeholder for moving things out of State temporarily
|
// NOTE: this is used as a transient placeholder for moving things out of State temporarily
|
||||||
Nothing,
|
Nothing,
|
||||||
@ -487,7 +488,7 @@ impl Renderer {
|
|||||||
self.swap_chain = self.device.create_swap_chain(&self.surface, &self.sc_desc);
|
self.swap_chain = self.device.create_swap_chain(&self.surface, &self.sc_desc);
|
||||||
|
|
||||||
// Resize other render targets
|
// Resize other render targets
|
||||||
self.views = Self::create_rt_views(&mut self.device, (dims.x, dims.y), &self.mode)?;
|
self.views = Self::create_rt_views(&self.device, (dims.x, dims.y), &self.mode)?;
|
||||||
// Rebind views to clouds/postprocess bind groups
|
// Rebind views to clouds/postprocess bind groups
|
||||||
self.locals.rebind(
|
self.locals.rebind(
|
||||||
&self.device,
|
&self.device,
|
||||||
@ -519,7 +520,7 @@ impl Renderer {
|
|||||||
if let (Some((point_depth, directed_depth)), ShadowMode::Map(mode)) =
|
if let (Some((point_depth, directed_depth)), ShadowMode::Map(mode)) =
|
||||||
(shadow_views, self.mode.shadow)
|
(shadow_views, self.mode.shadow)
|
||||||
{
|
{
|
||||||
match ShadowMap::create_shadow_views(&mut self.device, (dims.x, dims.y), &mode) {
|
match ShadowMap::create_shadow_views(&self.device, (dims.x, dims.y), &mode) {
|
||||||
Ok((new_point_depth, new_directed_depth)) => {
|
Ok((new_point_depth, new_directed_depth)) => {
|
||||||
*point_depth = new_point_depth;
|
*point_depth = new_point_depth;
|
||||||
*directed_depth = new_directed_depth;
|
*directed_depth = new_directed_depth;
|
||||||
|
@ -545,7 +545,7 @@ impl<'pass> FirstPassDrawer<'pass> {
|
|||||||
FigureDrawer { render_pass }
|
FigureDrawer { render_pass }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_terrain<'data: 'pass>(&mut self) -> TerrainDrawer<'_, 'pass> {
|
pub fn draw_terrain(&mut self) -> TerrainDrawer<'_, 'pass> {
|
||||||
let mut render_pass = self.render_pass.scope("terrain", self.borrow.device);
|
let mut render_pass = self.render_pass.scope("terrain", self.borrow.device);
|
||||||
|
|
||||||
render_pass.set_pipeline(&self.pipelines.terrain.pipeline);
|
render_pass.set_pipeline(&self.pipelines.terrain.pipeline);
|
||||||
@ -584,7 +584,7 @@ impl<'pass> FirstPassDrawer<'pass> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_fluid<'data: 'pass>(&mut self) -> FluidDrawer<'_, 'pass> {
|
pub fn draw_fluid(&mut self) -> FluidDrawer<'_, 'pass> {
|
||||||
let mut render_pass = self.render_pass.scope("fluid", self.borrow.device);
|
let mut render_pass = self.render_pass.scope("fluid", self.borrow.device);
|
||||||
|
|
||||||
render_pass.set_pipeline(&self.pipelines.fluid.pipeline);
|
render_pass.set_pipeline(&self.pipelines.fluid.pipeline);
|
||||||
@ -816,7 +816,7 @@ impl<'pass_ref, 'pass: 'pass_ref> PreparedUiDrawer<'pass_ref, 'pass> {
|
|||||||
self.render_pass.set_vertex_buffer(0, model.buf().slice(..))
|
self.render_pass.set_vertex_buffer(0, model.buf().slice(..))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_scissor<'data: 'pass>(&mut self, scissor: Aabr<u16>) {
|
pub fn set_scissor(&mut self, scissor: Aabr<u16>) {
|
||||||
let Aabr { min, max } = scissor;
|
let Aabr { min, max } = scissor;
|
||||||
// TODO: Got an invalid scissor panic from wgpu,
|
// TODO: Got an invalid scissor panic from wgpu,
|
||||||
// use this if you can reproduce
|
// use this if you can reproduce
|
||||||
@ -840,15 +840,12 @@ fn set_quad_index_buffer<'a, V: super::super::Vertex>(
|
|||||||
pass: &mut wgpu::RenderPass<'a>,
|
pass: &mut wgpu::RenderPass<'a>,
|
||||||
borrow: &RendererBorrow<'a>,
|
borrow: &RendererBorrow<'a>,
|
||||||
) {
|
) {
|
||||||
match V::QUADS_INDEX {
|
if let Some(format) = V::QUADS_INDEX {
|
||||||
Some(format) => {
|
|
||||||
let slice = match format {
|
let slice = match format {
|
||||||
wgpu::IndexFormat::Uint16 => borrow.quad_index_buffer_u16.buf.slice(..),
|
wgpu::IndexFormat::Uint16 => borrow.quad_index_buffer_u16.buf.slice(..),
|
||||||
wgpu::IndexFormat::Uint32 => borrow.quad_index_buffer_u32.buf.slice(..),
|
wgpu::IndexFormat::Uint32 => borrow.quad_index_buffer_u32.buf.slice(..),
|
||||||
};
|
};
|
||||||
|
|
||||||
pass.set_index_buffer(slice, format);
|
pass.set_index_buffer(slice, format);
|
||||||
},
|
|
||||||
None => {},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -618,15 +618,15 @@ fn create_ingame_and_shadow_pipelines(
|
|||||||
|
|
||||||
IngameAndShadowPipelines {
|
IngameAndShadowPipelines {
|
||||||
ingame: IngamePipelines {
|
ingame: IngamePipelines {
|
||||||
skybox,
|
|
||||||
figure,
|
figure,
|
||||||
terrain,
|
|
||||||
fluid,
|
fluid,
|
||||||
sprite,
|
|
||||||
particle,
|
|
||||||
lod_terrain,
|
lod_terrain,
|
||||||
|
particle,
|
||||||
clouds,
|
clouds,
|
||||||
postprocess,
|
postprocess,
|
||||||
|
skybox,
|
||||||
|
sprite,
|
||||||
|
terrain,
|
||||||
// player_shadow_pipeline,
|
// player_shadow_pipeline,
|
||||||
},
|
},
|
||||||
shadow: ShadowPipelines {
|
shadow: ShadowPipelines {
|
||||||
|
@ -6,7 +6,7 @@ use treeculler::Frustum;
|
|||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
pub const NEAR_PLANE: f32 = 0.0625;
|
pub const NEAR_PLANE: f32 = 0.0625;
|
||||||
pub const FAR_PLANE: f32 = 524288.0625;
|
pub const FAR_PLANE: f32 = 524288.06; // excessive precision: 524288.0625
|
||||||
|
|
||||||
const FIRST_PERSON_INTERP_TIME: f32 = 0.1;
|
const FIRST_PERSON_INTERP_TIME: f32 = 0.1;
|
||||||
const THIRD_PERSON_INTERP_TIME: f32 = 0.1;
|
const THIRD_PERSON_INTERP_TIME: f32 = 0.1;
|
||||||
|
@ -219,7 +219,7 @@ fn mesh_worker<V: BaseVol<Vox = Block> + RectRasterableVol + ReadVol + Debug + '
|
|||||||
// Extract sprite locations from volume
|
// Extract sprite locations from volume
|
||||||
sprite_instances: {
|
sprite_instances: {
|
||||||
span!(_guard, "extract sprite_instances");
|
span!(_guard, "extract sprite_instances");
|
||||||
let mut instances = [Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new()];
|
let mut instances = [(); SPRITE_LOD_LEVELS].map(|()| Vec::new());
|
||||||
|
|
||||||
for x in 0..V::RECT_SIZE.x as i32 {
|
for x in 0..V::RECT_SIZE.x as i32 {
|
||||||
for y in 0..V::RECT_SIZE.y as i32 {
|
for y in 0..V::RECT_SIZE.y as i32 {
|
||||||
@ -250,8 +250,9 @@ fn mesh_worker<V: BaseVol<Vox = Block> + RectRasterableVol + ReadVol + Debug + '
|
|||||||
let light = light_map(wpos);
|
let light = light_map(wpos);
|
||||||
let glow = glow_map(wpos);
|
let glow = glow_map(wpos);
|
||||||
|
|
||||||
for lod_level in 0..SPRITE_LOD_LEVELS {
|
for (lod_level, sprite_data) in
|
||||||
let sprite_data = &sprite_data[&key][lod_level];
|
instances.iter_mut().zip(&sprite_data[&key])
|
||||||
|
{
|
||||||
let mat = Mat4::identity()
|
let mat = Mat4::identity()
|
||||||
// Scaling for different LOD resolutions
|
// Scaling for different LOD resolutions
|
||||||
.scaled_3d(sprite_data.scale)
|
.scaled_3d(sprite_data.scale)
|
||||||
@ -276,7 +277,7 @@ fn mesh_worker<V: BaseVol<Vox = Block> + RectRasterableVol + ReadVol + Debug + '
|
|||||||
glow,
|
glow,
|
||||||
page,
|
page,
|
||||||
);
|
);
|
||||||
instances[lod_level].push(instance);
|
lod_level.push(instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user