Running latest rustfmt. No functional change.
This commit is contained in:
parent
ab637e3bd5
commit
498c1ea8d9
|
@ -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;
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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 {
|
||||
|
|
33
src/main.rs
33
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") {
|
||||
|
|
|
@ -207,7 +207,8 @@ fn parse_output_info(tree: &DataTree) -> Result<String, PsyParseError> {
|
|||
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<Camera<'a
|
|||
type_name,
|
||||
contents,
|
||||
byte_offset,
|
||||
} if type_name == "Fov" =>
|
||||
}
|
||||
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<Camera<'a
|
|||
type_name,
|
||||
contents,
|
||||
byte_offset,
|
||||
} if type_name == "FocalDistance" =>
|
||||
}
|
||||
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<Camera<'a
|
|||
type_name,
|
||||
contents,
|
||||
byte_offset,
|
||||
} if type_name == "ApertureRadius" =>
|
||||
}
|
||||
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<Camera<'a
|
|||
type_name,
|
||||
contents,
|
||||
byte_offset,
|
||||
} if type_name == "Transform" =>
|
||||
}
|
||||
if type_name == "Transform" =>
|
||||
{
|
||||
if let Ok(mat) = parse_matrix(contents) {
|
||||
mats.push(mat);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -255,8 +255,7 @@ fn get_faure_permutation(faure: &Vec<Vec<usize>>, b: usize) -> Vec<usize> {
|
|||
|
||||
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<Vec<usize>>, b: usize) -> Vec<usize> {
|
|||
} else {
|
||||
2 * faure[c][i - c] + 1
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
}).collect();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user