Code cosmetics: organize and alphabetize crate/mod/use statements.

This commit is contained in:
Nathan Vegdahl 2016-08-20 18:10:55 -07:00
parent f75c0c78fe
commit 97b5ef77f8
37 changed files with 190 additions and 146 deletions

View File

@ -3,8 +3,10 @@
use std;
use std::cmp;
use std::cmp::Ordering;
use lerp::{Lerp, lerp_slice};
use hash::hash_u64;
use lerp::{Lerp, lerp_slice};
/// Partitions a slice in-place with the given unary predicate, returning
/// the index of the first element for which the predicate evaluates

View File

@ -1,14 +1,14 @@
use std::collections::HashMap;
use math::{Matrix4x4, Vector};
use lerp::lerp_slice;
use bvh::BVH;
use light_accel::{LightAccel, LightTree};
use boundable::Boundable;
use surface::{Surface, SurfaceIntersection};
use light::LightSource;
use color::SpectralSample;
use bbox::{BBox, transform_bbox_slice_from};
use boundable::Boundable;
use bvh::BVH;
use color::SpectralSample;
use lerp::lerp_slice;
use light_accel::{LightAccel, LightTree};
use light::LightSource;
use math::{Matrix4x4, Vector};
use surface::{Surface, SurfaceIntersection};
#[derive(Debug)]

View File

@ -1,13 +1,14 @@
#![allow(dead_code)]
use std;
use std::ops::{BitOr, BitOrAssign};
use std::iter::Iterator;
use std::ops::{BitOr, BitOrAssign};
use math::{Point, Matrix4x4, fast_minf32, fast_maxf32};
use lerp::{lerp, lerp_slice, Lerp};
use math::{Point, Matrix4x4, fast_minf32, fast_maxf32};
use ray::AccelRay;
const BBOX_MAXT_ADJUST: f32 = 1.00000024;
/// A 3D axis-aligned bounding box.

View File

@ -2,6 +2,7 @@
use bbox::BBox;
pub trait Boundable {
fn bounds<'a>(&'a self) -> &'a [BBox];
}

View File

@ -2,14 +2,16 @@
use std;
use std::cmp::Ordering;
use lerp::lerp_slice;
use algorithm::{partition, quick_select, merge_slices_append};
use bbox::BBox;
use boundable::Boundable;
use ray::AccelRay;
use algorithm::{partition, quick_select, merge_slices_append};
use lerp::lerp_slice;
use math::log2_64;
use ray::AccelRay;
use sah::sah_split;
const BVH_MAX_DEPTH: usize = 64;
#[derive(Debug)]

View File

@ -1,9 +1,10 @@
#![allow(dead_code)]
use math::{Vector, Point, Matrix4x4};
use sampling::square_to_circle;
use ray::Ray;
use lerp::lerp_slice;
use math::{Vector, Point, Matrix4x4};
use ray::Ray;
use sampling::square_to_circle;
#[derive(Debug)]
pub struct Camera {

View File

@ -2,11 +2,13 @@ mod spectra_xyz;
use std::ops::{Add, AddAssign, Mul, MulAssign, Div, DivAssign};
use math::faster_exp;
use float4::Float4;
use lerp::Lerp;
use math::faster_exp;
use self::spectra_xyz::{spectrum_xyz_to_p, EQUAL_ENERGY_REFLECTANCE};
// Minimum and maximum wavelength of light we care about, in nanometers
const WL_MIN: f32 = 380.0;
const WL_MAX: f32 = 700.0;

View File

@ -1,11 +1,12 @@
#![allow(dead_code)]
use std::ops::{Add, Sub, Mul, Div};
use std::cmp::PartialEq;
use std::ops::{Add, Sub, Mul, Div};
#[cfg(feature = "simd_perf")]
use simd::f32x4;
/// Essentially a tuple of four floats, which will use SIMD operations
/// where possible on a platform.
#[cfg(feature = "simd_perf")]

View File

@ -1,19 +1,20 @@
#![allow(dead_code)]
use std::cell::{RefCell, UnsafeCell};
use std::cmp;
use std::fs::File;
use std::io;
use std::io::Write;
use std::path::Path;
use std::fs::File;
use std::marker::PhantomData;
use std::sync::Mutex;
use std::cell::{RefCell, UnsafeCell};
use std::mem;
use std::cmp;
use std::path::Path;
use std::sync::Mutex;
use lodepng;
use color::{XYZ, xyz_to_rec709e};
#[derive(Debug)]
pub struct Image {
data: UnsafeCell<Vec<XYZ>>,

View File

@ -1,14 +1,15 @@
mod sphere_light;
mod rectangle_light;
mod sphere_light;
use std::fmt::Debug;
pub use self::sphere_light::SphereLight;
pub use self::rectangle_light::RectangleLight;
use math::{Vector, Point, Matrix4x4};
use color::SpectralSample;
use boundable::Boundable;
use color::SpectralSample;
use math::{Vector, Point, Matrix4x4};
pub use self::rectangle_light::RectangleLight;
pub use self::sphere_light::SphereLight;
pub trait LightSource: Boundable + Debug + Sync {
/// Samples the light source for a given point to be illuminated.

View File

@ -1,11 +1,13 @@
use math::{Vector, Point, Matrix4x4};
use bbox::BBox;
use boundable::Boundable;
use color::{XYZ, SpectralSample, Color};
use super::LightSource;
use lerp::lerp_slice;
use math::{Vector, Point, Matrix4x4};
use sampling::{spherical_triangle_solid_angle, uniform_sample_spherical_triangle};
use super::LightSource;
#[derive(Debug)]
pub struct RectangleLight {
dimensions: Vec<(f32, f32)>,

View File

@ -1,11 +1,14 @@
use math::{Vector, Point, Matrix4x4, coordinate_system_from_vector};
use std::f64::consts::PI as PI_64;
use bbox::BBox;
use boundable::Boundable;
use color::{XYZ, SpectralSample, Color};
use super::LightSource;
use lerp::lerp_slice;
use math::{Vector, Point, Matrix4x4, coordinate_system_from_vector};
use sampling::{uniform_sample_cone, uniform_sample_cone_pdf, uniform_sample_sphere};
use std::f64::consts::PI as PI_64;
use super::LightSource;
#[derive(Debug)]
pub struct SphereLight {

View File

@ -1,12 +1,13 @@
use bbox::BBox;
use sah::sah_split;
use lerp::lerp_slice;
use algorithm::merge_slices_append;
use bbox::BBox;
use lerp::lerp_slice;
use math::{Vector, Point, Normal};
use sah::sah_split;
use shading::surface_closure::SurfaceClosure;
use super::LightAccel;
#[derive(Debug)]
pub struct LightTree {
nodes: Vec<Node>,

View File

@ -1,11 +1,12 @@
mod light_tree;
use math::{Vector, Point, Normal};
use bbox::BBox;
use math::{Vector, Point, Normal};
use shading::surface_closure::SurfaceClosure;
pub use self::light_tree::LightTree;
pub trait LightAccel {
/// Returns (index_of_light, selection_pdf, whittled_n)
fn select(&self,

View File

@ -1,58 +1,59 @@
extern crate rustc_serialize;
extern crate time;
extern crate docopt;
extern crate scoped_threadpool;
extern crate crossbeam;
extern crate num_cpus;
extern crate docopt;
extern crate lodepng;
#[cfg(feature = "simd_perf")]
extern crate simd;
extern crate num_cpus;
extern crate rustc_serialize;
extern crate scoped_threadpool;
extern crate time;
#[macro_use]
extern crate nom;
mod timer;
mod math;
mod hilbert;
mod algorithm;
mod lerp;
mod float4;
mod ray;
mod bbox;
mod camera;
mod parse;
mod renderer;
mod tracer;
mod image;
mod boundable;
mod triangle;
mod surface;
mod light;
mod bvh;
mod sah;
mod light_accel;
mod scene;
mod assembly;
mod halton;
mod sampling;
mod hash;
mod color;
mod shading;
mod transform_stack;
#[cfg(feature = "simd_perf")]
extern crate simd;
use std::mem;
mod algorithm;
mod assembly;
mod bbox;
mod boundable;
mod bvh;
mod camera;
mod color;
mod float4;
mod halton;
mod hash;
mod hilbert;
mod image;
mod lerp;
mod light_accel;
mod light;
mod math;
mod parse;
mod ray;
mod renderer;
mod sah;
mod sampling;
mod scene;
mod shading;
mod surface;
mod timer;
mod tracer;
mod transform_stack;
mod triangle;
use std::fs::File;
use std::io;
use std::io::Read;
use std::fs::File;
use std::mem;
use std::path::Path;
use docopt::Docopt;
use timer::Timer;
use parse::{parse_scene, DataTree};
use ray::{Ray, AccelRay};
use renderer::LightPath;
use parse::{parse_scene, DataTree};
use timer::Timer;
// ----------------------------------------------------------------

View File

@ -1,14 +1,15 @@
#![allow(dead_code)]
mod vector;
mod matrix;
mod normal;
mod point;
mod matrix;
mod vector;
pub use self::vector::Vector;
pub use self::matrix::Matrix4x4;
pub use self::normal::Normal;
pub use self::point::Point;
pub use self::matrix::Matrix4x4;
pub use self::vector::Vector;
/// Trait for calculating dot products.
pub trait DotProduct {

View File

@ -1,14 +1,15 @@
#![allow(dead_code)]
use std::ops::{Add, Sub, Mul, Div, Neg};
use std::cmp::PartialEq;
use std::ops::{Add, Sub, Mul, Div, Neg};
use lerp::Lerp;
use float4::Float4;
use lerp::Lerp;
use super::{DotProduct, CrossProduct};
use super::{Matrix4x4, Vector};
/// A surface normal in 3d homogeneous space.
#[derive(Debug, Copy, Clone)]
pub struct Normal {

View File

@ -1,13 +1,14 @@
#![allow(dead_code)]
use std::ops::{Add, Sub, Mul};
use std::cmp::PartialEq;
use std::ops::{Add, Sub, Mul};
use lerp::Lerp;
use float4::Float4;
use lerp::Lerp;
use super::Vector;
use super::Matrix4x4;
use super::Vector;
/// A position in 3d homogeneous space.
#[derive(Debug, Copy, Clone)]

View File

@ -1,14 +1,15 @@
#![allow(dead_code)]
use std::ops::{Add, Sub, Mul, Div, Neg};
use std::cmp::PartialEq;
use std::ops::{Add, Sub, Mul, Div, Neg};
use lerp::Lerp;
use float4::Float4;
use lerp::Lerp;
use super::{DotProduct, CrossProduct};
use super::{Matrix4x4, Normal};
/// A direction vector in 3d homogeneous space.
#[derive(Debug, Copy, Clone)]
pub struct Vector {

View File

@ -1,9 +1,10 @@
#![allow(dead_code)]
use std::result::Result;
use std::iter::Iterator;
use std::result::Result;
use std::slice;
#[derive(Debug, Eq, PartialEq)]
pub enum DataTree<'a> {
Internal {

View File

@ -1,8 +1,8 @@
mod data_tree;
mod psy;
mod psy_assembly;
mod psy_mesh_surface;
mod psy_light;
mod psy_mesh_surface;
mod psy;
pub mod basics;
pub use self::data_tree::DataTree;

View File

@ -5,15 +5,16 @@ use std::result::Result;
use nom;
use nom::IResult;
use super::DataTree;
use super::basics::{ws_u32, ws_f32};
use super::psy_assembly::parse_assembly;
use math::Matrix4x4;
use camera::Camera;
use color::{XYZ, rec709e_to_xyz};
use math::Matrix4x4;
use renderer::Renderer;
use scene::Scene;
use color::{XYZ, rec709e_to_xyz};
use super::basics::{ws_u32, ws_f32};
use super::DataTree;
use super::psy_assembly::parse_assembly;
#[derive(Copy, Clone, Debug)]
pub enum PsyParseError {

View File

@ -2,13 +2,14 @@
use std::result::Result;
use super::DataTree;
use super::psy::{parse_matrix, PsyParseError};
use super::psy_mesh_surface::parse_mesh_surface;
use super::psy_light::{parse_sphere_light, parse_rectangle_light};
use assembly::{Assembly, AssemblyBuilder, Object};
use super::DataTree;
use super::psy_light::{parse_sphere_light, parse_rectangle_light};
use super::psy_mesh_surface::parse_mesh_surface;
use super::psy::{parse_matrix, PsyParseError};
pub fn parse_assembly(tree: &DataTree) -> Result<Assembly, PsyParseError> {
let mut builder = AssemblyBuilder::new();

View File

@ -4,12 +4,13 @@ use std::result::Result;
use nom::IResult;
use super::DataTree;
use color::{XYZ, rec709e_to_xyz};
use light::{SphereLight, RectangleLight};
use super::basics::ws_f32;
use super::DataTree;
use super::psy::PsyParseError;
use light::{SphereLight, RectangleLight};
use color::{XYZ, rec709e_to_xyz};
pub fn parse_sphere_light(tree: &DataTree) -> Result<SphereLight, PsyParseError> {
if let &DataTree::Internal { ref children, .. } = tree {

View File

@ -4,12 +4,13 @@ use std::result::Result;
use nom::IResult;
use super::DataTree;
use math::Point;
use surface::triangle_mesh::TriangleMesh;
use super::basics::{ws_usize, ws_f32};
use super::DataTree;
use super::psy::PsyParseError;
use surface::triangle_mesh::TriangleMesh;
use math::Point;
// pub struct TriangleMesh {
// time_samples: usize,

View File

@ -5,6 +5,7 @@ use std;
use float4::Float4;
use math::{Vector, Point, Matrix4x4};
const OCCLUSION_FLAG: u32 = 1;
const DONE_FLAG: u32 = 1 << 1;

View File

@ -1,22 +1,24 @@
use std::cmp;
use std::io::{self, Write};
use std::cmp::min;
use std::cell::Cell;
use std::cmp;
use std::cmp::min;
use std::io::{self, Write};
use std::sync::{RwLock, Mutex};
use scoped_threadpool::Pool;
use crossbeam::sync::MsQueue;
use scoped_threadpool::Pool;
use algorithm::partition_pair;
use ray::Ray;
use tracer::Tracer;
use halton;
use hilbert;
use hash::hash_u32;
use math::{fast_logit, upper_power_of_two};
use image::Image;
use surface;
use scene::Scene;
use color::{Color, XYZ, SpectralSample, map_0_1_to_wavelength};
use halton;
use hash::hash_u32;
use hilbert;
use image::Image;
use math::{fast_logit, upper_power_of_two};
use ray::Ray;
use scene::Scene;
use surface;
use tracer::Tracer;
#[derive(Debug)]
pub struct Renderer {

View File

@ -1,8 +1,9 @@
use std;
use algorithm::partition;
use bbox::BBox;
use lerp::lerp_slice;
use algorithm::partition;
const SAH_BIN_COUNT: usize = 13; // Prime numbers work best, for some reason

View File

@ -1,10 +1,11 @@
#![allow(dead_code)]
use std::f32::consts::FRAC_PI_4 as QPI_32;
use std::f32::consts::PI as PI_32;
use std::f64::consts::PI as PI_64;
use math::{Vector, dot};
use std::f64::consts::PI as PI_64;
use std::f32::consts::PI as PI_32;
use std::f32::consts::FRAC_PI_4 as QPI_32;
/// Maps the unit square to the unit circle.
/// NOTE: x and y should be distributed within [-1, 1],

View File

@ -1,5 +1,5 @@
use camera::Camera;
use assembly::Assembly;
use camera::Camera;
use color::XYZ;

View File

@ -1,7 +1,10 @@
use math::{Vector, Normal, dot, zup_to_vec};
use color::{XYZ, SpectralSample, Color};
use sampling::cosine_sample_hemisphere;
use std::f32::consts::PI as PI_32;
use color::{XYZ, SpectralSample, Color};
use math::{Vector, Normal, dot, zup_to_vec};
use sampling::cosine_sample_hemisphere;
const INV_PI: f32 = 1.0 / PI_32;
const H_PI: f32 = PI_32 / 2.0;

View File

@ -1,13 +1,13 @@
#![allow(dead_code)]
use std::fmt::Debug;
pub mod triangle_mesh;
use shading::surface_closure::SurfaceClosureUnion;
use ray::{Ray, AccelRay};
use math::{Point, Vector, Normal, Matrix4x4};
use std::fmt::Debug;
use boundable::Boundable;
use math::{Point, Vector, Normal, Matrix4x4};
use ray::{Ray, AccelRay};
use shading::surface_closure::SurfaceClosureUnion;
#[derive(Debug, Copy, Clone)]

View File

@ -1,17 +1,18 @@
#![allow(dead_code)]
use lerp::{lerp, lerp_slice, lerp_slice_with};
use math::{Point, Matrix4x4, cross};
use ray::{Ray, AccelRay};
use triangle;
use bbox::BBox;
use boundable::Boundable;
use bvh::BVH;
use shading::surface_closure::{SurfaceClosureUnion, LambertClosure};
use color::XYZ;
use lerp::{lerp, lerp_slice, lerp_slice_with};
use math::{Point, Matrix4x4, cross};
use ray::{Ray, AccelRay};
use shading::surface_closure::{SurfaceClosureUnion, LambertClosure};
use triangle;
use super::{Surface, SurfaceIntersection};
#[derive(Debug)]
pub struct TriangleMesh {
time_samples: usize,

View File

@ -1,8 +1,10 @@
#![allow(dead_code)]
use time;
use std::time::Duration;
use std::thread;
use std::time::Duration;
use time;
#[derive(Copy, Clone)]
pub struct Timer {

View File

@ -1,12 +1,13 @@
use std::iter;
use algorithm::partition;
use lerp::lerp_slice;
use assembly::{Assembly, Object, InstanceType};
use lerp::lerp_slice;
use ray::{Ray, AccelRay};
use surface::SurfaceIntersection;
use transform_stack::TransformStack;
pub struct Tracer<'a> {
rays: Vec<AccelRay>,
inner: TracerInner<'a>,

View File

@ -1,7 +1,8 @@
use std::cmp;
use math::Matrix4x4;
use algorithm::merge_slices_to;
use math::Matrix4x4;
pub struct TransformStack {
stack: Vec<Matrix4x4>,

View File

@ -1,8 +1,10 @@
#![allow(dead_code)]
use std;
use ray::Ray;
use math::{Point, cross, dot};
use ray::Ray;
/// Intersects ray with tri, returning (t, u, v), or None if no intersection.
pub fn intersect_ray(ray: &Ray, tri: (Point, Point, Point)) -> Option<(f32, f32, f32)> {