Auto-formatting code with new version of rustfmt.

This commit is contained in:
Nathan Vegdahl 2016-06-02 22:43:35 -07:00
parent c3d3145817
commit 039943e0cb
12 changed files with 65 additions and 77 deletions

View File

@ -93,18 +93,16 @@ impl AssemblyBuilder {
instance_type: InstanceType::Object,
data_index: self.object_map[name],
id: self.instances.len(),
transform_indices: xforms.map(|xf| {
(self.xforms.len(), self.xforms.len() + xf.len())
}),
transform_indices:
xforms.map(|xf| (self.xforms.len(), self.xforms.len() + xf.len())),
}
} else {
Instance {
instance_type: InstanceType::Assembly,
data_index: self.assembly_map[name],
id: self.instances.len(),
transform_indices: xforms.map(|xf| {
(self.xforms.len(), self.xforms.len() + xf.len())
}),
transform_indices:
xforms.map(|xf| (self.xforms.len(), self.xforms.len() + xf.len())),
}
};

View File

@ -1,8 +1,7 @@
#![allow(dead_code)]
/// Trait for allowing a type to be linearly interpolated.
pub trait Lerp
{
pub trait Lerp {
fn lerp(self, other: Self, alpha: f32) -> Self;
}

View File

@ -11,8 +11,7 @@ pub use self::point::Point;
pub use self::matrix::{Matrix4x4, multiply_matrix_slices};
/// Trait for calculating dot products.
pub trait DotProduct
{
pub trait DotProduct {
fn dot(self, other: Self) -> f32;
}
@ -22,8 +21,7 @@ pub fn dot<T: DotProduct>(a: T, b: T) -> f32 {
/// Trait for calculating cross products.
pub trait CrossProduct
{
pub trait CrossProduct {
fn cross(self, other: Self) -> Self;
}

View File

@ -366,8 +366,7 @@ fn parse_leaf_content<'a>(source_text: (usize, &'a str)) -> (&'a str, (usize, &'
si = source_text.1.len();
}
return (&source_text.1[0..si],
(source_text.0 + si, &source_text.1[si..]));
return (&source_text.1[0..si], (source_text.0 + si, &source_text.1[si..]));
}
@ -414,8 +413,7 @@ fn next_token<'a>(source_text: (usize, &'a str)) -> (Token<'a>, (usize, &'a str)
si = text1.1.len();
}
return (Token::Ident(&text1.1[0..si]),
(text1.0 + si, &text1.1[si..]));
return (Token::Ident(&text1.1[0..si]), (text1.0 + si, &text1.1[si..]));
}
_ => {
@ -435,8 +433,7 @@ fn next_token<'a>(source_text: (usize, &'a str)) -> (Token<'a>, (usize, &'a str)
si = text1.1.len();
}
return (Token::TypeName(&text1.1[0..si]),
(text1.0 + si, &text1.1[si..]));
return (Token::TypeName(&text1.1[0..si]), (text1.0 + si, &text1.1[si..]));
}
}

View File

@ -87,8 +87,7 @@ pub fn parse_scene(tree: &DataTree) -> Result<Renderer, PsyParseError> {
// Put renderer together
let renderer = Renderer {
output_file: output_info.clone(),
resolution: ((render_settings.0).0 as usize,
(render_settings.0).1 as usize),
resolution: ((render_settings.0).0 as usize, (render_settings.0).1 as usize),
spp: render_settings.1 as usize,
scene: scene,
};

View File

@ -66,13 +66,11 @@ impl Renderer {
let mut g = 0.0;
let mut b = 0.0;
for isect in isects.iter() {
if let &surface::SurfaceIntersection::Hit{
t: _,
if let &surface::SurfaceIntersection::Hit { t: _,
pos: _,
nor: _,
space: _,
uv,
} = isect {
uv } = isect {
r += uv.0;
g += uv.1;
b += (1.0 - uv.0 - uv.1).max(0.0);

View File

@ -62,12 +62,11 @@ impl Surface for TriangleMesh {
fn intersect_rays(&self, rays: &mut [Ray], isects: &mut [SurfaceIntersection]) {
self.accel.traverse(&mut rays[..], &self.indices, |tri_i, rs| {
for r in rs {
let tri = lerp_slice_with(&self.geo[*tri_i..(*tri_i + self.time_samples)],
let tri =
lerp_slice_with(&self.geo[*tri_i..(*tri_i + self.time_samples)],
r.time,
|a, b, t| {
(lerp(a.0, b.0, t),
lerp(a.1, b.1, t),
lerp(a.2, b.2, t))
(lerp(a.0, b.0, t), lerp(a.1, b.1, t), lerp(a.2, b.2, t))
});
if let Some((t, tri_u, tri_v)) = triangle::intersect_ray(r, tri) {
if t < r.max_t {