Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applied cargo clippy --fix #244

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/boilerplate.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(clippy::single_match)]
use vangers::{
config::{settings::Terrain, Settings},
config::Settings,
render::{GraphicsContext, ScreenTargets, DEPTH_FORMAT},
};

Expand Down
4 changes: 2 additions & 2 deletions bin/convert/level_obj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ pub fn save(path: &Path, level: &Level, config: &Config) {
{
let diag_column = &c.face_columns[(dy - config.yr.start) as usize]
[(dx - config.xr.start) as usize];
column.add_faces(&diag_column, diagonal.corner);
column.add_faces(diag_column, diagonal.corner);
}
}

Expand Down Expand Up @@ -441,7 +441,7 @@ pub fn save(path: &Path, level: &Level, config: &Config) {
unit(num_tris),
);

let mut dest = BufWriter::new(File::create(&path).unwrap());
let mut dest = BufWriter::new(File::create(path).unwrap());
bar.set_job_title("Vertices:");
for v in c.final_vertices {
writeln!(dest, "v {} {} {}", v[0], v[1], v[2]).unwrap();
Expand Down
6 changes: 3 additions & 3 deletions bin/convert/level_png.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn save(path: &Path, layers: LevelLayers, palette: &[u8]) {
{
println!("\t\t{}...", mp.height);
let file = File::create(path.with_file_name(mp.height)).unwrap();
let mut encoder = png::Encoder::new(file, layers.size.0 as u32, layers.size.1 as u32);
let mut encoder = png::Encoder::new(file, layers.size.0, layers.size.1);
encoder.set_color(png::ColorType::Rgb);
data.clear();
for ((&h0, &h1), &delta) in layers.het0.iter().zip(&layers.het1).zip(&layers.delta) {
Expand All @@ -46,7 +46,7 @@ pub fn save(path: &Path, layers: LevelLayers, palette: &[u8]) {
{
println!("\t\t{}...", mp.material_lo);
let file = File::create(path.with_file_name(mp.material_lo)).unwrap();
let mut encoder = png::Encoder::new(file, layers.size.0 as u32, layers.size.1 as u32);
let mut encoder = png::Encoder::new(file, layers.size.0, layers.size.1);
encoder.set_color(png::ColorType::Indexed);
encoder.set_palette(palette.to_vec());
encoder.set_depth(png::BitDepth::Four);
Expand All @@ -59,7 +59,7 @@ pub fn save(path: &Path, layers: LevelLayers, palette: &[u8]) {
{
println!("\t\t{}...", mp.material_hi);
let file = File::create(path.with_file_name(mp.material_hi)).unwrap();
let mut encoder = png::Encoder::new(file, layers.size.0 as u32, layers.size.1 as u32);
let mut encoder = png::Encoder::new(file, layers.size.0, layers.size.1);
encoder.set_color(png::ColorType::Indexed);
encoder.set_palette(palette.to_vec());
encoder.set_depth(png::BitDepth::Four);
Expand Down
20 changes: 10 additions & 10 deletions bin/convert/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,36 @@ use std::{
pub fn save_tiff(path: &Path, layers: layers::LevelLayers) {
let images = [
tiff::Image {
width: layers.size.0 as u32,
height: layers.size.1 as u32,
width: layers.size.0,
height: layers.size.1,
bpp: 8,
name: "h0",
data: &layers.het0,
},
tiff::Image {
width: layers.size.0 as u32,
height: layers.size.1 as u32,
width: layers.size.0,
height: layers.size.1,
bpp: 8,
name: "h1",
data: &layers.het1,
},
tiff::Image {
width: layers.size.0 as u32,
height: layers.size.1 as u32,
width: layers.size.0,
height: layers.size.1,
bpp: 8,
name: "del",
data: &layers.delta,
},
tiff::Image {
width: layers.size.0 as u32,
height: layers.size.1 as u32,
width: layers.size.0,
height: layers.size.1,
bpp: 4,
name: "m0",
data: &layers.mat0,
},
tiff::Image {
width: layers.size.0 as u32,
height: layers.size.1 as u32,
width: layers.size.0,
height: layers.size.1,
bpp: 4,
name: "m1",
data: &layers.mat1,
Expand Down
12 changes: 6 additions & 6 deletions bin/convert/model_obj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type RefModel = Model<Mesh<String>, Mesh<String>>;
type RefAnimatedMesh = AnimatedMesh<String>;
type DrawAnimatedMesh = AnimatedMesh<Geometry<DrawTriangle>>;

const MAT_NAME: &'static str = "object.mtl";
const MAT_NAME: &str = "object.mtl";

pub fn export_m3d(full: FullModel, model_path: &Path) {
const BODY_PATH: &str = "body.obj";
Expand Down Expand Up @@ -87,11 +87,11 @@ pub fn import_m3d(model_path: &Path) -> FullModel {
let resolve_geom_draw = |name| -> Geometry<DrawTriangle> { load_geometry(dir_path.join(name)) };
let resolve_geom_coll =
|name| -> Geometry<CollisionQuad> { load_geometry(dir_path.join(name)) };
let resolve_mesh = |mesh: Mesh<String>| mesh.map(&resolve_geom_draw);
let resolve_mesh = |mesh: Mesh<String>| mesh.map(resolve_geom_draw);

FullModel {
body: model.body.map(&resolve_geom_draw),
shape: model.shape.map(&resolve_geom_coll),
body: model.body.map(resolve_geom_draw),
shape: model.shape.map(resolve_geom_coll),
bound: model.bound,
color: model.color,
wheels: model
Expand All @@ -103,8 +103,8 @@ pub fn import_m3d(model_path: &Path) -> FullModel {
.debris
.into_iter()
.map(|debrie| Debrie {
mesh: debrie.mesh.map(&resolve_geom_draw),
shape: debrie.shape.map(&resolve_geom_coll),
mesh: debrie.mesh.map(resolve_geom_draw),
shape: debrie.shape.map(resolve_geom_coll),
})
.collect(),
slots: Slot::map_all(model.slots, |mesh, _| resolve_mesh(mesh)),
Expand Down
2 changes: 1 addition & 1 deletion bin/level/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl LevelView {
level,
cam,
input: Input::Empty,
ui: settings.ui.clone(),
ui: settings.ui,
last_mouse_pos: cgmath::vec2(-1.0, -1.0),
alt_button_pressed: false,
mouse_button_pressed: false,
Expand Down
2 changes: 1 addition & 1 deletion bin/level/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main() {
}

let path = matches.free.first();
let app = app::LevelView::new(path.as_deref(), &settings, &harness.graphics_ctx);
let app = app::LevelView::new(path, &settings, &harness.graphics_ctx);

harness.main_loop(app);
}
2 changes: 1 addition & 1 deletion bin/road/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ impl Game {
level,
agents,
stats: Stats::default(),
ui: settings.ui.clone(),
ui: settings.ui,
cam,
cam_style: CameraStyle::new(&settings.game.camera),
max_quant: settings.game.physics.max_quant,
Expand Down
4 changes: 2 additions & 2 deletions src/level/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub fn load_flood(config: &LevelConfig) -> Box<[u8]> {
let size = (config.size.0.as_value(), config.size.1.as_value());
let flood_size = size.1 >> config.section.as_power();

let vpr_file = match File::open(&config.path_data.with_extension("vpr")) {
let vpr_file = match File::open(config.path_data.with_extension("vpr")) {
Ok(file) => file,
Err(_) => return vec![0; flood_size as usize].into_boxed_slice(),
};
Expand Down Expand Up @@ -297,7 +297,7 @@ impl LevelData {
}

Splay::write_trivial(&mut vmc);
assert_eq!(vmc.seek(SeekFrom::Current(0)).unwrap(), base_offset);
assert_eq!(vmc.stream_position().unwrap(), base_offset);

self.height
.chunks(self.size.0 as _)
Expand Down
6 changes: 3 additions & 3 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::render::{
use m3d;
use wgpu::util::DeviceExt as _;

use std::{fs::File, mem, ops::Range, slice, sync::Arc};
use std::{fs::File, ops::Range, slice, sync::Arc};

#[derive(Copy, Clone)]
pub struct BoundingBox {
Expand Down Expand Up @@ -127,7 +127,7 @@ pub fn load_c3d(
) -> Arc<Mesh> {
let num_vertices = raw.geometry.polygons.len() * 3;
debug!("\tGot {} GPU vertices...", num_vertices);
let vertex_size = mem::size_of::<ObjectVertex>();
let vertex_size = size_of::<ObjectVertex>();
let vertex_buf = device.create_buffer(&wgpu::BufferDescriptor {
label: Some("C3D"),
size: (num_vertices * vertex_size) as wgpu::BufferAddress,
Expand Down Expand Up @@ -251,7 +251,7 @@ pub fn load_c3d_shape(

let vertex_buf = device.create_buffer(&wgpu::BufferDescriptor {
label: Some("Shape"),
size: (raw.geometry.positions.len() * mem::size_of::<ShapeVertex>()) as wgpu::BufferAddress,
size: (raw.geometry.positions.len() * size_of::<ShapeVertex>()) as wgpu::BufferAddress,
usage: wgpu::BufferUsages::VERTEX | wgpu::BufferUsages::STORAGE,
mapped_at_creation: true,
});
Expand Down
12 changes: 6 additions & 6 deletions src/render/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
use bytemuck::{Pod, Zeroable};
use wgpu::util::DeviceExt as _;

use std::{collections::HashMap, mem, num::NonZeroU64};
use std::{collections::HashMap, num::NonZeroU64};

const BLEND_FRONT: wgpu::BlendComponent = wgpu::BlendComponent::REPLACE;
const BLEND_BEHIND: wgpu::BlendComponent = wgpu::BlendComponent {
Expand Down Expand Up @@ -157,7 +157,7 @@ impl Context {
]),
usage: wgpu::BufferUsages::UNIFORM,
});
let locals_size = mem::size_of::<Locals>() as wgpu::BufferAddress;
let locals_size = size_of::<Locals>() as wgpu::BufferAddress;
let bind_group_line = device.create_bind_group(&wgpu::BindGroupDescriptor {
label: Some("Debug line"),
layout: &bind_group_layout,
Expand Down Expand Up @@ -242,7 +242,7 @@ impl Context {
entry_point: "main_vs",
buffers: &[
wgpu::VertexBufferLayout {
array_stride: mem::size_of::<Position>() as wgpu::BufferAddress,
array_stride: size_of::<Position>() as wgpu::BufferAddress,
step_mode: wgpu::VertexStepMode::Vertex,
attributes: &[wgpu::VertexAttribute {
offset: 0,
Expand All @@ -251,7 +251,7 @@ impl Context {
}],
},
wgpu::VertexBufferLayout {
array_stride: mem::size_of::<Color>() as wgpu::BufferAddress,
array_stride: size_of::<Color>() as wgpu::BufferAddress,
step_mode: color_rate,
attributes: &[wgpu::VertexAttribute {
offset: 0,
Expand Down Expand Up @@ -327,14 +327,14 @@ impl Context {

//TODO: this is broken - both regular rendering and debug one
// require instancing now, one has to yield and be refactored.
let instance_offset = instance_id * mem::size_of::<ObjectInstance>();
let instance_offset = instance_id * size_of::<ObjectInstance>();
pass.set_bind_group(2, shape_bg, &[]);
pass.set_vertex_buffer(0, shape.polygon_buf.slice(..));
pass.set_vertex_buffer(
1,
instance_buf.slice(
instance_offset as wgpu::BufferAddress
..mem::size_of::<ObjectInstance>() as wgpu::BufferAddress,
..size_of::<ObjectInstance>() as wgpu::BufferAddress,
),
);

Expand Down
3 changes: 1 addition & 2 deletions src/render/global.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::{config::settings, space::Camera};
use bytemuck::{Pod, Zeroable};
use std::mem;

#[repr(C)]
#[derive(Clone, Copy)]
Expand Down Expand Up @@ -91,7 +90,7 @@ impl Context {
});
let uniform_buf = gfx.device.create_buffer(&wgpu::BufferDescriptor {
label: Some("Uniform"),
size: mem::size_of::<Constants>() as wgpu::BufferAddress,
size: size_of::<Constants>() as wgpu::BufferAddress,
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
mapped_at_creation: false,
});
Expand Down
9 changes: 4 additions & 5 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::{
collections::HashMap,
fs::File,
io::{BufReader, Error as IoError, Read},
mem,
ops::Range,
path::PathBuf,
sync::Arc,
Expand Down Expand Up @@ -89,7 +88,7 @@ impl ShapeVertexDesc {

pub fn buffer_desc(&self) -> wgpu::VertexBufferLayout<'_> {
wgpu::VertexBufferLayout {
array_stride: mem::size_of::<ShapePolygon>() as wgpu::BufferAddress,
array_stride: size_of::<ShapePolygon>() as wgpu::BufferAddress,
step_mode: wgpu::VertexStepMode::Instance,
attributes: &self.attributes,
}
Expand Down Expand Up @@ -462,7 +461,7 @@ impl Render {
0,
&self.global.uniform_buf,
0,
mem::size_of::<global::Constants>() as wgpu::BufferAddress,
size_of::<global::Constants>() as wgpu::BufferAddress,
);

self.terrain.prepare_shadow(
Expand Down Expand Up @@ -518,7 +517,7 @@ impl Render {
0,
&self.global.uniform_buf,
0,
mem::size_of::<global::Constants>() as wgpu::BufferAddress,
size_of::<global::Constants>() as wgpu::BufferAddress,
);

self.terrain.prepare(
Expand All @@ -528,7 +527,7 @@ impl Render {
&self.fog_config,
level.geometry.height,
cam,
viewport.unwrap_or_else(|| Rect {
viewport.unwrap_or(Rect {
x: 0,
y: 0,
w: self.screen_size.width as u16,
Expand Down
6 changes: 3 additions & 3 deletions src/render/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
use bytemuck::{Pod, Zeroable};
use m3d::NUM_COLOR_IDS;

use std::{mem, slice};
use std::slice;

pub const COLOR_TABLE: [[u8; 2]; NUM_COLOR_IDS as usize] = [
[0, 0], // reserved
Expand Down Expand Up @@ -109,7 +109,7 @@ impl InstanceDesc {

pub fn buffer_desc(&self) -> wgpu::VertexBufferLayout<'_> {
wgpu::VertexBufferLayout {
array_stride: mem::size_of::<Instance>() as wgpu::BufferAddress,
array_stride: size_of::<Instance>() as wgpu::BufferAddress,
step_mode: wgpu::VertexStepMode::Instance,
attributes: &self.attributes,
}
Expand All @@ -133,7 +133,7 @@ impl Context {
front_face: wgpu::FrontFace,
) -> PipelineSet {
let vertex_descriptor = wgpu::VertexBufferLayout {
array_stride: mem::size_of::<Vertex>() as wgpu::BufferAddress,
array_stride: size_of::<Vertex>() as wgpu::BufferAddress,
step_mode: wgpu::VertexStepMode::Vertex,
attributes: &wgpu::vertex_attr_array![0 => Sint8x4, 1 => Uint32, 2 => Snorm8x4],
};
Expand Down
Loading
Loading