Setup rustfmt for everything and address cargo clippy.
This commit is contained in:
parent
5e7139f0ba
commit
1ca903c64b
@ -1 +1,2 @@
|
||||
imports_granularity = "Crate"
|
||||
format_code_in_doc_comments = true
|
||||
|
||||
2
rtiow/noise_explorer/rustfmt.toml
Normal file
2
rtiow/noise_explorer/rustfmt.toml
Normal file
@ -0,0 +1,2 @@
|
||||
imports_granularity = "Crate"
|
||||
format_code_in_doc_comments = true
|
||||
@ -11,7 +11,6 @@ use actix_web::Path;
|
||||
use actix_web::Query;
|
||||
use actix_web::Result;
|
||||
use askama::Template;
|
||||
use image;
|
||||
use log::info;
|
||||
use rand::SeedableRng;
|
||||
use rand_xorshift::XorShiftRng;
|
||||
@ -26,19 +25,12 @@ use renderer::texture::NoiseTexture;
|
||||
use renderer::texture::Texture;
|
||||
use renderer::vec3::Vec3;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(StructOpt)]
|
||||
#[structopt(name = "noise_explorer", about = "CLI for exploring Perlin noise")]
|
||||
struct Opt {
|
||||
/// HTTP listen address
|
||||
#[structopt(long = "addr", default_value = "0.0.0.0:8889")]
|
||||
pub addr: String,
|
||||
|
||||
/// Width of noise images
|
||||
#[structopt(short = "w", long = "width", default_value = "128")]
|
||||
pub width: u32,
|
||||
/// Height of noise images
|
||||
#[structopt(short = "h", long = "height", default_value = "128")]
|
||||
pub height: u32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Deserialize, PartialEq)]
|
||||
@ -63,11 +55,6 @@ struct OptionalParams {
|
||||
pixel_scale: f32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct NoiseSourceParam {
|
||||
noise_source: NoiseSource,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct NoiseParams {
|
||||
width: u32,
|
||||
|
||||
2
rtiow/noise_explorer_warp/rustfmt.toml
Normal file
2
rtiow/noise_explorer_warp/rustfmt.toml
Normal file
@ -0,0 +1,2 @@
|
||||
imports_granularity = "Crate"
|
||||
format_code_in_doc_comments = true
|
||||
2
rtiow/renderer/rustfmt.toml
Normal file
2
rtiow/renderer/rustfmt.toml
Normal file
@ -0,0 +1,2 @@
|
||||
imports_granularity = "Crate"
|
||||
format_code_in_doc_comments = true
|
||||
@ -130,6 +130,12 @@ impl Formatter {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Formatter {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Scales {
|
||||
/// Instantiates a new `Scales` with SI keys
|
||||
pub fn new() -> Self {
|
||||
@ -199,7 +205,7 @@ impl Scales {
|
||||
}
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
0.0
|
||||
}
|
||||
|
||||
fn to_scaled_value(&self, value: f64) -> ScaledValue {
|
||||
@ -221,3 +227,9 @@ impl Scales {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Scales {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ fn print_tree(f: &mut fmt::Formatter, depth: usize, kdt: &KDTree) -> fmt::Result
|
||||
impl fmt::Display for KDTree {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
writeln!(f, "kd-tree")?;
|
||||
print_tree(f, 1, &self)
|
||||
print_tree(f, 1, self)
|
||||
}
|
||||
}
|
||||
impl Hit for KDTree {
|
||||
|
||||
@ -35,7 +35,7 @@ fn perlin_generate_perm<R>(rng: &mut R) -> Vec<usize>
|
||||
where
|
||||
R: Rng,
|
||||
{
|
||||
let mut p: Vec<usize> = (0..256).map(|i| i).collect();
|
||||
let mut p: Vec<usize> = (0..256).collect();
|
||||
p.shuffle(rng);
|
||||
p
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ pub fn set_pixel(name: &str, x: usize, y: usize, pixel: Vec3) {
|
||||
let (_it, img) = debugger
|
||||
.images
|
||||
.get_mut(name)
|
||||
.expect(&format!("couldn't find image named '{}'", name));
|
||||
.unwrap_or_else(|| panic!("couldn't find image named '{}'", name));
|
||||
let y_inv = img.h - y - 1;
|
||||
img.put_pixel(x, y_inv, pixel);
|
||||
}
|
||||
@ -108,7 +108,7 @@ pub fn set_pixel_grey(name: &str, x: usize, y: usize, grey: f32) {
|
||||
let (_it, img) = debugger
|
||||
.images
|
||||
.get_mut(name)
|
||||
.expect(&format!("couldn't find image named '{}'", name));
|
||||
.unwrap_or_else(|| panic!("couldn't find image named '{}'", name));
|
||||
let y_inv = img.h - y - 1;
|
||||
img.put_pixel(x, y_inv, [grey, grey, grey].into());
|
||||
}
|
||||
|
||||
@ -52,17 +52,17 @@ pub enum Model {
|
||||
impl Model {
|
||||
pub fn scene(&self, opt: &Opt) -> Scene {
|
||||
match self {
|
||||
Model::BVH => scenes::bvh::new(&opt),
|
||||
Model::Bench => scenes::bench::new(&opt),
|
||||
Model::Book => scenes::book::new(&opt),
|
||||
Model::CornellBox => scenes::cornell_box::new(&opt),
|
||||
Model::CornellSmoke => scenes::cornell_smoke::new(&opt),
|
||||
Model::Final => scenes::final_scene::new(&opt),
|
||||
Model::Mandelbrot => scenes::mandelbrot::new(&opt),
|
||||
Model::PerlinDebug => scenes::perlin_debug::new(&opt),
|
||||
Model::Spheramid => scenes::spheramid::new(&opt),
|
||||
Model::Test => scenes::test::new(&opt),
|
||||
Model::Tutorial => scenes::tutorial::new(&opt),
|
||||
Model::BVH => scenes::bvh::new(opt),
|
||||
Model::Bench => scenes::bench::new(opt),
|
||||
Model::Book => scenes::book::new(opt),
|
||||
Model::CornellBox => scenes::cornell_box::new(opt),
|
||||
Model::CornellSmoke => scenes::cornell_smoke::new(opt),
|
||||
Model::Final => scenes::final_scene::new(opt),
|
||||
Model::Mandelbrot => scenes::mandelbrot::new(opt),
|
||||
Model::PerlinDebug => scenes::perlin_debug::new(opt),
|
||||
Model::Spheramid => scenes::spheramid::new(opt),
|
||||
Model::Test => scenes::test::new(opt),
|
||||
Model::Tutorial => scenes::tutorial::new(opt),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -155,7 +155,7 @@ pub fn opt_hash(opt: &Opt) -> String {
|
||||
opt.pprof.is_some(),
|
||||
opt.model.to_string(),
|
||||
opt.use_accel,
|
||||
opt.output.display().to_string().replace("/", "_")
|
||||
opt.output.display().to_string().replace('/', "_")
|
||||
)
|
||||
}
|
||||
|
||||
@ -378,7 +378,7 @@ fn trace_pixel_random(x: usize, y: usize, scene: &Scene) -> (Vec3, usize) {
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, Default)]
|
||||
struct RenderStats {
|
||||
rays: usize,
|
||||
pixels: usize,
|
||||
@ -412,12 +412,6 @@ fn progress(
|
||||
)
|
||||
}
|
||||
|
||||
impl Default for RenderStats {
|
||||
fn default() -> Self {
|
||||
RenderStats { rays: 0, pixels: 0 }
|
||||
}
|
||||
}
|
||||
|
||||
enum Request {
|
||||
Pixel { x: usize, y: usize },
|
||||
Line { width: usize, y: usize },
|
||||
|
||||
@ -57,7 +57,6 @@ pub fn new(opt: &Opt) -> Scene {
|
||||
height: opt.height,
|
||||
global_illumination: true,
|
||||
env_map: Some(EnvMap::new(skybox)),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -115,6 +115,5 @@ pub fn new(opt: &Opt) -> Scene {
|
||||
height: opt.height,
|
||||
global_illumination: true,
|
||||
env_map: Some(EnvMap::new(skybox)),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,9 +5,7 @@ use rand::Rng;
|
||||
use crate::texture::Texture;
|
||||
use crate::vec3::Vec3;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Mandelbrot {
|
||||
scale: f32,
|
||||
palette: Vec<Vec3>,
|
||||
}
|
||||
|
||||
@ -49,7 +47,6 @@ fn generate_palette(num: usize) -> Vec<Vec3> {
|
||||
impl Default for Mandelbrot {
|
||||
fn default() -> Self {
|
||||
Mandelbrot {
|
||||
scale: 2.0,
|
||||
palette: generate_palette(10),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1 +1,2 @@
|
||||
imports_granularity = "Crate"
|
||||
format_code_in_doc_comments = true
|
||||
|
||||
2
rtiow/tracer/rustfmt.toml
Normal file
2
rtiow/tracer/rustfmt.toml
Normal file
@ -0,0 +1,2 @@
|
||||
imports_granularity = "Crate"
|
||||
format_code_in_doc_comments = true
|
||||
@ -4,7 +4,6 @@ use std::fs;
|
||||
#[cfg(feature = "profile")]
|
||||
use cpuprofiler::PROFILER;
|
||||
use log::info;
|
||||
use stderrlog;
|
||||
use structopt::StructOpt;
|
||||
|
||||
use renderer::renderer::render;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user