Run latest rustfmt. No functional changes.
This commit is contained in:
parent
caeb1d9c67
commit
c002514ddf
|
@ -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;
|
||||
|
|
|
@ -55,7 +55,8 @@ impl<'a> Camera<'a> {
|
|||
}
|
||||
|
||||
// Convert angle fov into linear fov.
|
||||
let tfovs: Vec<f32> = fovs.iter()
|
||||
let tfovs: Vec<f32> = fovs
|
||||
.iter()
|
||||
.map(|n| (n / 2.0).sin() / (n / 2.0).cos())
|
||||
.collect();
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user