diff --git a/src/accel/bvh_base.rs b/src/accel/bvh_base.rs index 60593f5..afecff0 100644 --- a/src/accel/bvh_base.rs +++ b/src/accel/bvh_base.rs @@ -119,10 +119,12 @@ impl BVHBase { // We make sure that it's worth having multiple time samples, and if not // we reduce to the union of the time samples. self.acc_bounds(objects, bounder); - let union_bounds = self.bounds_cache + let union_bounds = self + .bounds_cache .iter() .fold(BBox::new(), |b1, b2| (b1 | *b2)); - let average_area = self.bounds_cache + let average_area = self + .bounds_cache .iter() .fold(0.0, |area, bb| area + bb.surface_area()) / self.bounds_cache.len() as f32; diff --git a/src/camera.rs b/src/camera.rs index f115b93..fd6dfd0 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -55,7 +55,8 @@ impl<'a> Camera<'a> { } // Convert angle fov into linear fov. - let tfovs: Vec = fovs.iter() + let tfovs: Vec = fovs + .iter() .map(|n| (n / 2.0).sin() / (n / 2.0).cos()) .collect(); diff --git a/src/light/distant_disk_light.rs b/src/light/distant_disk_light.rs index 3ddec1d..8cc286a 100644 --- a/src/light/distant_disk_light.rs +++ b/src/light/distant_disk_light.rs @@ -87,7 +87,8 @@ impl<'a> WorldLightSource for DistantDiskLight<'a> { } fn approximate_energy(&self) -> f32 { - let color: XYZ = self.colors + let color: XYZ = self + .colors .iter() .fold(XYZ::new(0.0, 0.0, 0.0), |a, &b| a + b) / self.colors.len() as f32; diff --git a/src/light/rectangle_light.rs b/src/light/rectangle_light.rs index 27e23e8..228937d 100644 --- a/src/light/rectangle_light.rs +++ b/src/light/rectangle_light.rs @@ -244,7 +244,8 @@ impl<'a> SurfaceLight for RectangleLight<'a> { } fn approximate_energy(&self) -> f32 { - let color: XYZ = self.colors + let color: XYZ = self + .colors .iter() .fold(XYZ::new(0.0, 0.0, 0.0), |a, &b| a + b) / self.colors.len() as f32; diff --git a/src/light/sphere_light.rs b/src/light/sphere_light.rs index 93fbcb5..a55b590 100644 --- a/src/light/sphere_light.rs +++ b/src/light/sphere_light.rs @@ -194,7 +194,8 @@ impl<'a> SurfaceLight for SphereLight<'a> { } fn approximate_energy(&self) -> f32 { - let color: XYZ = self.colors + let color: XYZ = self + .colors .iter() .fold(XYZ::new(0.0, 0.0, 0.0), |a, &b| a + b) / self.colors.len() as f32; diff --git a/src/scene/assembly.rs b/src/scene/assembly.rs index 3ad2a01..e281b90 100644 --- a/src/scene/assembly.rs +++ b/src/scene/assembly.rs @@ -244,7 +244,8 @@ impl<'a> AssemblyBuilder<'a> { instance_type: InstanceType::Object, data_index: self.object_map[name], surface_shader_index: surface_shader_name.map(|name| { - *self.surface_shader_map + *self + .surface_shader_map .get(name) .expect(&format!("Unknown surface shader '{}'.", name)) }), @@ -257,7 +258,8 @@ impl<'a> AssemblyBuilder<'a> { instance_type: InstanceType::Assembly, data_index: self.assembly_map[name], surface_shader_index: surface_shader_name.map(|name| { - *self.surface_shader_map + *self + .surface_shader_map .get(name) .expect(&format!("Unknown surface shader '{}'.", name)) }), @@ -290,7 +292,8 @@ impl<'a> AssemblyBuilder<'a> { // Get list of instances that are for light sources or assemblies that contain light // sources. - let mut light_instances: Vec<_> = self.instances + let mut light_instances: Vec<_> = self + .instances .iter() .filter(|inst| match inst.instance_type { InstanceType::Object => { diff --git a/src/scene/scene.rs b/src/scene/scene.rs index 2516626..1ba3481 100644 --- a/src/scene/scene.rs +++ b/src/scene/scene.rs @@ -34,7 +34,8 @@ impl<'a> Scene<'a> { // Calculate relative probabilities of traversing into world lights // or local lights. - let wl_energy = if self.world + let wl_energy = if self + .world .lights .iter() .fold(0.0, |energy, light| energy + light.approximate_energy()) diff --git a/src/shading/mod.rs b/src/shading/mod.rs index 7571052..07e62d9 100644 --- a/src/shading/mod.rs +++ b/src/shading/mod.rs @@ -2,7 +2,9 @@ pub mod surface_closure; use std::fmt::Debug; -use self::surface_closure::{EmitClosure, GGXClosure, GTRClosure, LambertClosure, SurfaceClosureUnion}; +use self::surface_closure::{ + EmitClosure, GGXClosure, GTRClosure, LambertClosure, SurfaceClosureUnion, +}; use color::{Color, XYZ}; use surface::SurfaceIntersectionData; diff --git a/src/shading/surface_closure.rs b/src/shading/surface_closure.rs index 3616ea9..a9fa2e1 100644 --- a/src/shading/surface_closure.rs +++ b/src/shading/surface_closure.rs @@ -68,7 +68,13 @@ pub trait SurfaceClosure { /// /// Returns the resulting filter color and pdf of if this had been generated /// by `sample()`. - fn evaluate(&self, inc: Vector, out: Vector, nor: Normal, nor_g: Normal) -> (SpectralSample, f32); + fn evaluate( + &self, + inc: Vector, + out: Vector, + nor: Normal, + nor_g: Normal, + ) -> (SpectralSample, f32); /// Returns an estimate of the sum total energy that evaluate() would return /// when integrated over a spherical light source with a center at relative @@ -191,7 +197,13 @@ impl SurfaceClosure for EmitClosure { (Vector::new(0.0, 0.0, 0.0), self.col, 1.0) } - fn evaluate(&self, inc: Vector, out: Vector, nor: Normal, nor_g: Normal) -> (SpectralSample, f32) { + fn evaluate( + &self, + inc: Vector, + out: Vector, + nor: Normal, + nor_g: Normal, + ) -> (SpectralSample, f32) { let _ = (inc, out, nor, nor_g); // Not using these, silence warning (self.col, 1.0) @@ -257,7 +269,13 @@ impl SurfaceClosure for LambertClosure { } } - fn evaluate(&self, inc: Vector, out: Vector, nor: Normal, nor_g: Normal) -> (SpectralSample, f32) { + fn evaluate( + &self, + inc: Vector, + out: Vector, + nor: Normal, + nor_g: Normal, + ) -> (SpectralSample, f32) { let (nn, flipped_nor_g) = if dot(nor_g.into_vector(), inc) <= 0.0 { (nor.normalized().into_vector(), nor_g.into_vector()) } else { @@ -481,7 +499,13 @@ impl SurfaceClosure for GTRClosure { } } - fn evaluate(&self, inc: Vector, out: Vector, nor: Normal, nor_g: Normal) -> (SpectralSample, f32) { + fn evaluate( + &self, + inc: Vector, + out: Vector, + nor: Normal, + nor_g: Normal, + ) -> (SpectralSample, f32) { // Calculate needed vectors, normalized let aa = -inc.normalized(); // Vector pointing to where "in" came from let bb = out.normalized(); // Out @@ -634,7 +658,6 @@ impl SurfaceClosure for GTRClosure { } } - /// The GGX microfacet BRDF. #[derive(Debug, Copy, Clone)] pub struct GGXClosure { @@ -740,7 +763,13 @@ impl SurfaceClosure for GGXClosure { } } - fn evaluate(&self, inc: Vector, out: Vector, nor: Normal, nor_g: Normal) -> (SpectralSample, f32) { + fn evaluate( + &self, + inc: Vector, + out: Vector, + nor: Normal, + nor_g: Normal, + ) -> (SpectralSample, f32) { // Calculate needed vectors, normalized let aa = -inc.normalized(); // Vector pointing to where "in" came from let bb = out.normalized(); // Out @@ -872,4 +901,4 @@ impl SurfaceClosure for GGXClosure { fac * (1.0f32).min(1.0 - cos_theta_max) * INV_PI } -} \ No newline at end of file +}