Auto-formatting code with new version of rustfmt.
This commit is contained in:
parent
c3d3145817
commit
039943e0cb
|
@ -93,18 +93,16 @@ impl AssemblyBuilder {
|
||||||
instance_type: InstanceType::Object,
|
instance_type: InstanceType::Object,
|
||||||
data_index: self.object_map[name],
|
data_index: self.object_map[name],
|
||||||
id: self.instances.len(),
|
id: self.instances.len(),
|
||||||
transform_indices: xforms.map(|xf| {
|
transform_indices:
|
||||||
(self.xforms.len(), self.xforms.len() + xf.len())
|
xforms.map(|xf| (self.xforms.len(), self.xforms.len() + xf.len())),
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Instance {
|
Instance {
|
||||||
instance_type: InstanceType::Assembly,
|
instance_type: InstanceType::Assembly,
|
||||||
data_index: self.assembly_map[name],
|
data_index: self.assembly_map[name],
|
||||||
id: self.instances.len(),
|
id: self.instances.len(),
|
||||||
transform_indices: xforms.map(|xf| {
|
transform_indices:
|
||||||
(self.xforms.len(), self.xforms.len() + xf.len())
|
xforms.map(|xf| (self.xforms.len(), self.xforms.len() + xf.len())),
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
/// Trait for allowing a type to be linearly interpolated.
|
/// Trait for allowing a type to be linearly interpolated.
|
||||||
pub trait Lerp
|
pub trait Lerp {
|
||||||
{
|
|
||||||
fn lerp(self, other: Self, alpha: f32) -> Self;
|
fn lerp(self, other: Self, alpha: f32) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,7 @@ pub use self::point::Point;
|
||||||
pub use self::matrix::{Matrix4x4, multiply_matrix_slices};
|
pub use self::matrix::{Matrix4x4, multiply_matrix_slices};
|
||||||
|
|
||||||
/// Trait for calculating dot products.
|
/// Trait for calculating dot products.
|
||||||
pub trait DotProduct
|
pub trait DotProduct {
|
||||||
{
|
|
||||||
fn dot(self, other: Self) -> f32;
|
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.
|
/// Trait for calculating cross products.
|
||||||
pub trait CrossProduct
|
pub trait CrossProduct {
|
||||||
{
|
|
||||||
fn cross(self, other: Self) -> Self;
|
fn cross(self, other: Self) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -366,8 +366,7 @@ fn parse_leaf_content<'a>(source_text: (usize, &'a str)) -> (&'a str, (usize, &'
|
||||||
si = source_text.1.len();
|
si = source_text.1.len();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (&source_text.1[0..si],
|
return (&source_text.1[0..si], (source_text.0 + si, &source_text.1[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();
|
si = text1.1.len();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (Token::Ident(&text1.1[0..si]),
|
return (Token::Ident(&text1.1[0..si]), (text1.0 + si, &text1.1[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();
|
si = text1.1.len();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (Token::TypeName(&text1.1[0..si]),
|
return (Token::TypeName(&text1.1[0..si]), (text1.0 + si, &text1.1[si..]));
|
||||||
(text1.0 + si, &text1.1[si..]));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,8 +87,7 @@ pub fn parse_scene(tree: &DataTree) -> Result<Renderer, PsyParseError> {
|
||||||
// Put renderer together
|
// Put renderer together
|
||||||
let renderer = Renderer {
|
let renderer = Renderer {
|
||||||
output_file: output_info.clone(),
|
output_file: output_info.clone(),
|
||||||
resolution: ((render_settings.0).0 as usize,
|
resolution: ((render_settings.0).0 as usize, (render_settings.0).1 as usize),
|
||||||
(render_settings.0).1 as usize),
|
|
||||||
spp: render_settings.1 as usize,
|
spp: render_settings.1 as usize,
|
||||||
scene: scene,
|
scene: scene,
|
||||||
};
|
};
|
||||||
|
|
|
@ -66,13 +66,11 @@ impl Renderer {
|
||||||
let mut g = 0.0;
|
let mut g = 0.0;
|
||||||
let mut b = 0.0;
|
let mut b = 0.0;
|
||||||
for isect in isects.iter() {
|
for isect in isects.iter() {
|
||||||
if let &surface::SurfaceIntersection::Hit{
|
if let &surface::SurfaceIntersection::Hit { t: _,
|
||||||
t: _,
|
|
||||||
pos: _,
|
pos: _,
|
||||||
nor: _,
|
nor: _,
|
||||||
space: _,
|
space: _,
|
||||||
uv,
|
uv } = isect {
|
||||||
} = isect {
|
|
||||||
r += uv.0;
|
r += uv.0;
|
||||||
g += uv.1;
|
g += uv.1;
|
||||||
b += (1.0 - uv.0 - uv.1).max(0.0);
|
b += (1.0 - uv.0 - uv.1).max(0.0);
|
||||||
|
|
|
@ -62,12 +62,11 @@ impl Surface for TriangleMesh {
|
||||||
fn intersect_rays(&self, rays: &mut [Ray], isects: &mut [SurfaceIntersection]) {
|
fn intersect_rays(&self, rays: &mut [Ray], isects: &mut [SurfaceIntersection]) {
|
||||||
self.accel.traverse(&mut rays[..], &self.indices, |tri_i, rs| {
|
self.accel.traverse(&mut rays[..], &self.indices, |tri_i, rs| {
|
||||||
for r in 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,
|
r.time,
|
||||||
|a, b, t| {
|
|a, b, t| {
|
||||||
(lerp(a.0, b.0, t),
|
(lerp(a.0, b.0, t), lerp(a.1, b.1, t), lerp(a.2, b.2, 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 let Some((t, tri_u, tri_v)) = triangle::intersect_ray(r, tri) {
|
||||||
if t < r.max_t {
|
if t < r.max_t {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user