From 97b5ef77f8ac65476cbc86cfe275a6c73a494f46 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Sat, 20 Aug 2016 18:10:55 -0700 Subject: [PATCH] Code cosmetics: organize and alphabetize crate/mod/use statements. --- src/algorithm.rs | 4 +- src/assembly.rs | 16 +++---- src/bbox.rs | 5 ++- src/boundable.rs | 1 + src/bvh.rs | 8 ++-- src/camera.rs | 7 +-- src/color/mod.rs | 4 +- src/float4.rs | 3 +- src/image.rs | 11 ++--- src/light/mod.rs | 13 +++--- src/light/rectangle_light.rs | 6 ++- src/light/sphere_light.rs | 9 ++-- src/light_accel/light_tree.rs | 7 +-- src/light_accel/mod.rs | 3 +- src/main.rs | 81 +++++++++++++++++----------------- src/math/mod.rs | 9 ++-- src/math/normal.rs | 5 ++- src/math/point.rs | 7 +-- src/math/vector.rs | 5 ++- src/parse/data_tree.rs | 3 +- src/parse/mod.rs | 4 +- src/parse/psy.rs | 13 +++--- src/parse/psy_assembly.rs | 11 ++--- src/parse/psy_light.rs | 7 +-- src/parse/psy_mesh_surface.rs | 7 +-- src/ray.rs | 1 + src/renderer.rs | 28 ++++++------ src/sah.rs | 3 +- src/sampling.rs | 7 +-- src/scene.rs | 2 +- src/shading/surface_closure.rs | 9 ++-- src/surface/mod.rs | 10 ++--- src/surface/triangle_mesh.rs | 11 ++--- src/timer.rs | 6 ++- src/tracer.rs | 3 +- src/transform_stack.rs | 3 +- src/triangle.rs | 4 +- 37 files changed, 190 insertions(+), 146 deletions(-) diff --git a/src/algorithm.rs b/src/algorithm.rs index 8c81e6a..1a06d4d 100644 --- a/src/algorithm.rs +++ b/src/algorithm.rs @@ -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 diff --git a/src/assembly.rs b/src/assembly.rs index 6708057..44484e5 100644 --- a/src/assembly.rs +++ b/src/assembly.rs @@ -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)] diff --git a/src/bbox.rs b/src/bbox.rs index aa070e7..1133ca1 100644 --- a/src/bbox.rs +++ b/src/bbox.rs @@ -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. diff --git a/src/boundable.rs b/src/boundable.rs index ff30d8e..3643d36 100644 --- a/src/boundable.rs +++ b/src/boundable.rs @@ -2,6 +2,7 @@ use bbox::BBox; + pub trait Boundable { fn bounds<'a>(&'a self) -> &'a [BBox]; } diff --git a/src/bvh.rs b/src/bvh.rs index a3b5b97..2427380 100644 --- a/src/bvh.rs +++ b/src/bvh.rs @@ -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)] diff --git a/src/camera.rs b/src/camera.rs index c000956..a2929aa 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -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 { diff --git a/src/color/mod.rs b/src/color/mod.rs index fd4252e..224bec2 100644 --- a/src/color/mod.rs +++ b/src/color/mod.rs @@ -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; diff --git a/src/float4.rs b/src/float4.rs index 961b84d..3c991f2 100644 --- a/src/float4.rs +++ b/src/float4.rs @@ -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")] diff --git a/src/image.rs b/src/image.rs index 07c73e2..4d00640 100644 --- a/src/image.rs +++ b/src/image.rs @@ -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>, diff --git a/src/light/mod.rs b/src/light/mod.rs index 21df3a4..f24f434 100644 --- a/src/light/mod.rs +++ b/src/light/mod.rs @@ -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. diff --git a/src/light/rectangle_light.rs b/src/light/rectangle_light.rs index 5e0fc4e..c5dccc6 100644 --- a/src/light/rectangle_light.rs +++ b/src/light/rectangle_light.rs @@ -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)>, diff --git a/src/light/sphere_light.rs b/src/light/sphere_light.rs index 9cc4c51..25ba4a3 100644 --- a/src/light/sphere_light.rs +++ b/src/light/sphere_light.rs @@ -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 { diff --git a/src/light_accel/light_tree.rs b/src/light_accel/light_tree.rs index 2bb0eb0..2f9896e 100644 --- a/src/light_accel/light_tree.rs +++ b/src/light_accel/light_tree.rs @@ -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, diff --git a/src/light_accel/mod.rs b/src/light_accel/mod.rs index e3cc702..1dbeba6 100644 --- a/src/light_accel/mod.rs +++ b/src/light_accel/mod.rs @@ -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, diff --git a/src/main.rs b/src/main.rs index 92cb5fa..7f0e2f4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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; + // ---------------------------------------------------------------- diff --git a/src/math/mod.rs b/src/math/mod.rs index ca9dff1..77cf8b6 100644 --- a/src/math/mod.rs +++ b/src/math/mod.rs @@ -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 { diff --git a/src/math/normal.rs b/src/math/normal.rs index 2c07876..2cc68d7 100644 --- a/src/math/normal.rs +++ b/src/math/normal.rs @@ -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 { diff --git a/src/math/point.rs b/src/math/point.rs index 96d100e..36b0f65 100644 --- a/src/math/point.rs +++ b/src/math/point.rs @@ -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)] diff --git a/src/math/vector.rs b/src/math/vector.rs index 0dba7f4..31b7ba1 100644 --- a/src/math/vector.rs +++ b/src/math/vector.rs @@ -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 { diff --git a/src/parse/data_tree.rs b/src/parse/data_tree.rs index 3c9127f..00b4b68 100644 --- a/src/parse/data_tree.rs +++ b/src/parse/data_tree.rs @@ -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 { diff --git a/src/parse/mod.rs b/src/parse/mod.rs index 54ba968..7feb859 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -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; diff --git a/src/parse/psy.rs b/src/parse/psy.rs index 564711e..de4a321 100644 --- a/src/parse/psy.rs +++ b/src/parse/psy.rs @@ -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 { diff --git a/src/parse/psy_assembly.rs b/src/parse/psy_assembly.rs index c9fbc43..d79f697 100644 --- a/src/parse/psy_assembly.rs +++ b/src/parse/psy_assembly.rs @@ -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 { let mut builder = AssemblyBuilder::new(); diff --git a/src/parse/psy_light.rs b/src/parse/psy_light.rs index d686299..43ee716 100644 --- a/src/parse/psy_light.rs +++ b/src/parse/psy_light.rs @@ -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 { if let &DataTree::Internal { ref children, .. } = tree { diff --git a/src/parse/psy_mesh_surface.rs b/src/parse/psy_mesh_surface.rs index 052cdcb..6865768 100644 --- a/src/parse/psy_mesh_surface.rs +++ b/src/parse/psy_mesh_surface.rs @@ -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, diff --git a/src/ray.rs b/src/ray.rs index e4f905f..d75e1d6 100644 --- a/src/ray.rs +++ b/src/ray.rs @@ -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; diff --git a/src/renderer.rs b/src/renderer.rs index 8214203..27ac69f 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -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 { diff --git a/src/sah.rs b/src/sah.rs index 61ede52..51168cb 100644 --- a/src/sah.rs +++ b/src/sah.rs @@ -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 diff --git a/src/sampling.rs b/src/sampling.rs index 6e8df13..2124a83 100644 --- a/src/sampling.rs +++ b/src/sampling.rs @@ -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], diff --git a/src/scene.rs b/src/scene.rs index 4968fba..28bd2ca 100644 --- a/src/scene.rs +++ b/src/scene.rs @@ -1,5 +1,5 @@ -use camera::Camera; use assembly::Assembly; +use camera::Camera; use color::XYZ; diff --git a/src/shading/surface_closure.rs b/src/shading/surface_closure.rs index ddd05da..d76a5d5 100644 --- a/src/shading/surface_closure.rs +++ b/src/shading/surface_closure.rs @@ -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; diff --git a/src/surface/mod.rs b/src/surface/mod.rs index cb1e1c0..186a13b 100644 --- a/src/surface/mod.rs +++ b/src/surface/mod.rs @@ -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)] diff --git a/src/surface/triangle_mesh.rs b/src/surface/triangle_mesh.rs index 9504b95..147e115 100644 --- a/src/surface/triangle_mesh.rs +++ b/src/surface/triangle_mesh.rs @@ -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, diff --git a/src/timer.rs b/src/timer.rs index c81eb4c..d838dea 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -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 { diff --git a/src/tracer.rs b/src/tracer.rs index 5d171ce..4ea0c64 100644 --- a/src/tracer.rs +++ b/src/tracer.rs @@ -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, inner: TracerInner<'a>, diff --git a/src/transform_stack.rs b/src/transform_stack.rs index 1f0ec03..b285241 100644 --- a/src/transform_stack.rs +++ b/src/transform_stack.rs @@ -1,7 +1,8 @@ use std::cmp; -use math::Matrix4x4; use algorithm::merge_slices_to; +use math::Matrix4x4; + pub struct TransformStack { stack: Vec, diff --git a/src/triangle.rs b/src/triangle.rs index 9b0a0e6..e935127 100644 --- a/src/triangle.rs +++ b/src/triangle.rs @@ -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)> {