diff --git a/src/accel/mod.rs b/src/accel/mod.rs index 890518b..6309f55 100644 --- a/src/accel/mod.rs +++ b/src/accel/mod.rs @@ -11,7 +11,7 @@ use math::{Normal, Point, Vector}; use shading::surface_closure::SurfaceClosure; pub use self::bvh::{BVHNode, BVH}; -pub use self::bvh4::{BVH4, BVH4Node}; +pub use self::bvh4::{BVH4Node, BVH4}; pub use self::light_array::LightArray; pub use self::light_tree::LightTree; diff --git a/src/light/rectangle_light.rs b/src/light/rectangle_light.rs index 228937d..8e349d7 100644 --- a/src/light/rectangle_light.rs +++ b/src/light/rectangle_light.rs @@ -36,8 +36,7 @@ impl<'a> RectangleLight<'a> { .map(|d| BBox { min: Point::new(d.0 * -0.5, d.1 * -0.5, 0.0), max: Point::new(d.0 * 0.5, d.1 * 0.5, 0.0), - }) - .collect(); + }).collect(); RectangleLight { dimensions: arena.copy_slice(&dimensions), colors: arena.copy_slice(&colors), diff --git a/src/light/sphere_light.rs b/src/light/sphere_light.rs index a55b590..1dd1265 100644 --- a/src/light/sphere_light.rs +++ b/src/light/sphere_light.rs @@ -35,8 +35,7 @@ impl<'a> SphereLight<'a> { .map(|r| BBox { min: Point::new(-*r, -*r, -*r), max: Point::new(*r, *r, *r), - }) - .collect(); + }).collect(); SphereLight { radii: arena.copy_slice(&radii), colors: arena.copy_slice(&colors), @@ -257,8 +256,7 @@ impl<'a> Surface for SphereLight<'a> { // Get our final parametric values let mut t0 = q / a; - let mut t1 = - if q != 0.0 { c / q } else { r.max_t }; + let mut t1 = if q != 0.0 { c / q } else { r.max_t }; // Swap them so they are ordered right if t0 > t1 { diff --git a/src/main.rs b/src/main.rs index b1cde9d..de76d12 100644 --- a/src/main.rs +++ b/src/main.rs @@ -91,8 +91,7 @@ fn main() { .help("Input .psy file") .takes_value(true) .required_unless_one(&["dev", "use_stdin"]), - ) - .arg( + ).arg( Arg::with_name("spp") .short("s") .long("spp") @@ -104,8 +103,7 @@ fn main() { .and(Ok(())) .or(Err("must be an integer".to_string())) }), - ) - .arg( + ).arg( Arg::with_name("max_bucket_samples") .short("b") .long("spb") @@ -117,24 +115,21 @@ fn main() { .and(Ok(())) .or(Err("must be an integer".to_string())) }), - ) - .arg( + ).arg( Arg::with_name("crop") .long("crop") .value_name("X1 Y1 X2 Y2") .help( "Only render the image between pixel coordinates (X1, Y1) \ and (X2, Y2). Coordinates are zero-indexed and inclusive.", - ) - .takes_value(true) + ).takes_value(true) .number_of_values(4) .validator(|s| { usize::from_str(&s) .and(Ok(())) .or(Err("must be four integers".to_string())) }), - ) - .arg( + ).arg( Arg::with_name("threads") .short("t") .long("threads") @@ -142,37 +137,31 @@ fn main() { .help( "Number of threads to render with. Defaults to the number of logical \ cores on the system.", - ) - .takes_value(true) + ).takes_value(true) .validator(|s| { usize::from_str(&s) .and(Ok(())) .or(Err("must be an integer".to_string())) }), - ) - .arg( + ).arg( Arg::with_name("stats") .long("stats") .help("Print additional statistics about rendering"), - ) - .arg( + ).arg( Arg::with_name("dev") .long("dev") .help("Show useful dev/debug info."), - ) - .arg( + ).arg( Arg::with_name("serialized_output") .long("serialized_output") .help("Serialize and send render output to standard output.") .hidden(true), - ) - .arg( + ).arg( Arg::with_name("use_stdin") .long("use_stdin") .help("Take scene file in from stdin instead of a file path.") .hidden(true), - ) - .get_matches(); + ).get_matches(); // Print some misc useful dev info. if args.is_present("dev") { diff --git a/src/parse/psy.rs b/src/parse/psy.rs index 289c38e..b769854 100644 --- a/src/parse/psy.rs +++ b/src/parse/psy.rs @@ -207,7 +207,8 @@ fn parse_output_info(tree: &DataTree) -> Result { type_name, contents, byte_offset, - } if type_name == "Path" => + } + if type_name == "Path" => { // Trim and validate let tc = contents.trim(); @@ -270,7 +271,8 @@ fn parse_render_settings(tree: &DataTree) -> Result<((u32, u32), u32, u32), PsyP type_name, contents, byte_offset, - } if type_name == "Resolution" => + } + if type_name == "Resolution" => { if let IResult::Done(_, (w, h)) = closure!(terminated!(tuple!(ws_u32, ws_u32), eof!()))(contents.as_bytes()) @@ -292,7 +294,8 @@ fn parse_render_settings(tree: &DataTree) -> Result<((u32, u32), u32, u32), PsyP type_name, contents, byte_offset, - } if type_name == "SamplesPerPixel" => + } + if type_name == "SamplesPerPixel" => { if let IResult::Done(_, n) = ws_u32(contents.as_bytes()) { found_spp = true; @@ -313,7 +316,8 @@ fn parse_render_settings(tree: &DataTree) -> Result<((u32, u32), u32, u32), PsyP type_name, contents, byte_offset, - } if type_name == "Seed" => + } + if type_name == "Seed" => { if let IResult::Done(_, n) = ws_u32(contents.as_bytes()) { seed = n; @@ -366,7 +370,8 @@ fn parse_camera<'a>(arena: &'a MemArena, tree: &'a DataTree) -> Result + } + if type_name == "Fov" => { if let IResult::Done(_, fov) = ws_f32(contents.as_bytes()) { fovs.push(fov * (f32::consts::PI / 180.0)); @@ -386,7 +391,8 @@ fn parse_camera<'a>(arena: &'a MemArena, tree: &'a DataTree) -> Result + } + if type_name == "FocalDistance" => { if let IResult::Done(_, fd) = ws_f32(contents.as_bytes()) { focus_distances.push(fd); @@ -406,7 +412,8 @@ fn parse_camera<'a>(arena: &'a MemArena, tree: &'a DataTree) -> Result + } + if type_name == "ApertureRadius" => { if let IResult::Done(_, ar) = ws_f32(contents.as_bytes()) { aperture_radii.push(ar); @@ -426,7 +433,8 @@ fn parse_camera<'a>(arena: &'a MemArena, tree: &'a DataTree) -> Result + } + if type_name == "Transform" => { if let Ok(mat) = parse_matrix(contents) { mats.push(mat); diff --git a/src/parse/psy_assembly.rs b/src/parse/psy_assembly.rs index c60763d..a9e27be 100644 --- a/src/parse/psy_assembly.rs +++ b/src/parse/psy_assembly.rs @@ -51,7 +51,8 @@ pub fn parse_assembly<'a>( // Get surface shader binding, if any. let surface_shader_name = if child .iter_leaf_children_with_type("SurfaceShaderBind") - .count() > 0 + .count() + > 0 { Some( child diff --git a/src/parse/psy_light.rs b/src/parse/psy_light.rs index 27a61dd..c79bc22 100644 --- a/src/parse/psy_light.rs +++ b/src/parse/psy_light.rs @@ -31,7 +31,8 @@ pub fn parse_distant_disk_light<'a>( type_name, contents, byte_offset, - } if type_name == "Radius" => + } + if type_name == "Radius" => { if let IResult::Done(_, radius) = ws_f32(contents.as_bytes()) { radii.push(radius); @@ -46,7 +47,8 @@ pub fn parse_distant_disk_light<'a>( type_name, contents, byte_offset, - } if type_name == "Direction" => + } + if type_name == "Direction" => { if let IResult::Done(_, direction) = closure!(tuple!(ws_f32, ws_f32, ws_f32))(contents.as_bytes()) @@ -63,7 +65,8 @@ pub fn parse_distant_disk_light<'a>( type_name, contents, byte_offset, - } if type_name == "Color" => + } + if type_name == "Color" => { if let IResult::Done(_, color) = closure!(tuple!(ws_f32, ws_f32, ws_f32))(contents.as_bytes()) @@ -104,7 +107,8 @@ pub fn parse_sphere_light<'a>( type_name, contents, byte_offset, - } if type_name == "Radius" => + } + if type_name == "Radius" => { if let IResult::Done(_, radius) = ws_f32(contents.as_bytes()) { radii.push(radius); @@ -119,7 +123,8 @@ pub fn parse_sphere_light<'a>( type_name, contents, byte_offset, - } if type_name == "Color" => + } + if type_name == "Color" => { if let IResult::Done(_, color) = closure!(tuple!(ws_f32, ws_f32, ws_f32))(contents.as_bytes()) @@ -160,7 +165,8 @@ pub fn parse_rectangle_light<'a>( type_name, contents, byte_offset, - } if type_name == "Dimensions" => + } + if type_name == "Dimensions" => { if let IResult::Done(_, radius) = closure!(tuple!(ws_f32, ws_f32))(contents.as_bytes()) @@ -177,7 +183,8 @@ pub fn parse_rectangle_light<'a>( type_name, contents, byte_offset, - } if type_name == "Color" => + } + if type_name == "Color" => { if let IResult::Done(_, color) = closure!(tuple!(ws_f32, ws_f32, ws_f32))(contents.as_bytes()) diff --git a/src/renderer.rs b/src/renderer.rs index 5e44724..e876eba 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -621,7 +621,8 @@ impl LightPath { .world .background_color .to_spectral_sample(self.wavelength) - .e * self.light_attenuation + .e + * self.light_attenuation / self.closure_sample_pdf; return false; } diff --git a/src/scene/assembly.rs b/src/scene/assembly.rs index e281b90..56ea21f 100644 --- a/src/scene/assembly.rs +++ b/src/scene/assembly.rs @@ -307,10 +307,10 @@ impl<'a> AssemblyBuilder<'a> { InstanceType::Assembly => { self.assemblies[inst.data_index] .light_accel - .approximate_energy() > 0.0 + .approximate_energy() + > 0.0 } - }) - .cloned() + }).cloned() .collect(); // Build light accel diff --git a/src/shading/surface_closure.rs b/src/shading/surface_closure.rs index 2a9f228..6ce9552 100644 --- a/src/shading/surface_closure.rs +++ b/src/shading/surface_closure.rs @@ -435,8 +435,9 @@ impl GTRClosure { let roughness2 = self.roughness * self.roughness; // Calculate top half of equation - let top = 1.0 - ((roughness2.powf(1.0 - self.tail_shape) * (1.0 - u)) + u) - .powf(1.0 / (1.0 - self.tail_shape)); + let top = 1.0 + - ((roughness2.powf(1.0 - self.tail_shape) * (1.0 - u)) + u) + .powf(1.0 / (1.0 - self.tail_shape)); // Calculate bottom half of equation let bottom = 1.0 - roughness2; diff --git a/src/surface/triangle.rs b/src/surface/triangle.rs index c0088ea..9fdff2c 100644 --- a/src/surface/triangle.rs +++ b/src/surface/triangle.rs @@ -139,9 +139,9 @@ pub fn surface_point(tri: (Point, Point, Point), bary: (f32, f32, f32)) -> (Poin let pos_err = (((tri.0.into_vector().abs() * bary.0) + (tri.1.into_vector().abs() * bary.1) - + (tri.2.into_vector().abs() * bary.2)) * fp_gamma(7)) - .co - .h_max(); + + (tri.2.into_vector().abs() * bary.2)) + * fp_gamma(7)).co + .h_max(); (pos, pos_err) } diff --git a/sub_crates/color/build.rs b/sub_crates/color/build.rs index 7d247ca..b79ff1e 100644 --- a/sub_crates/color/build.rs +++ b/sub_crates/color/build.rs @@ -201,15 +201,18 @@ fn rgb_to_xyz(chroma: Chromaticities, y: f64) -> [[f64; 3]; 3] { let sr = (x * (chroma.b.1 - chroma.g.1) - chroma.g.0 * (y * (chroma.b.1 - 1.0) + chroma.b.1 * (x + z)) - + chroma.b.0 * (y * (chroma.g.1 - 1.0) + chroma.g.1 * (x + z))) / d; + + chroma.b.0 * (y * (chroma.g.1 - 1.0) + chroma.g.1 * (x + z))) + / d; let sg = (x * (chroma.r.1 - chroma.b.1) + chroma.r.0 * (y * (chroma.b.1 - 1.0) + chroma.b.1 * (x + z)) - - chroma.b.0 * (y * (chroma.r.1 - 1.0) + chroma.r.1 * (x + z))) / d; + - chroma.b.0 * (y * (chroma.r.1 - 1.0) + chroma.r.1 * (x + z))) + / d; let sb = (x * (chroma.g.1 - chroma.r.1) - chroma.r.0 * (y * (chroma.g.1 - 1.0) + chroma.g.1 * (x + z)) - + chroma.g.0 * (y * (chroma.r.1 - 1.0) + chroma.r.1 * (x + z))) / d; + + chroma.g.0 * (y * (chroma.r.1 - 1.0) + chroma.r.1 * (x + z))) + / d; // Assemble the matrix let mut mat = [[0.0; 3]; 3]; diff --git a/sub_crates/halton/build.rs b/sub_crates/halton/build.rs index dfbc2c1..b36aa67 100644 --- a/sub_crates/halton/build.rs +++ b/sub_crates/halton/build.rs @@ -255,8 +255,7 @@ fn get_faure_permutation(faure: &Vec>, b: usize) -> Vec { let f: usize = faure[b - 1][i - ((i > c) as usize)]; f + ((f >= c) as usize) - }) - .collect(); + }).collect(); } else { // even let c = b / 2; @@ -268,8 +267,7 @@ fn get_faure_permutation(faure: &Vec>, b: usize) -> Vec { } else { 2 * faure[c][i - c] + 1 } - }) - .collect(); + }).collect(); } } diff --git a/sub_crates/mem_arena/src/lib.rs b/sub_crates/mem_arena/src/lib.rs index 5fd8cd4..4f57e31 100644 --- a/sub_crates/mem_arena/src/lib.rs +++ b/sub_crates/mem_arena/src/lib.rs @@ -303,7 +303,8 @@ impl MemArena { let w1 = ((blocks[0].capacity() - blocks[0].len()) * 100) / blocks[0].capacity(); let w2 = ((self.stat_space_occupied.get() - self.stat_space_allocated.get()) - * 100) / self.stat_space_occupied.get(); + * 100) + / self.stat_space_occupied.get(); if w1 < w2 { w1 } else {