From 8deb1e87bb8c9f599f4ed97922d22b234e9b5a77 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Sun, 16 Dec 2018 12:02:20 -0800 Subject: [PATCH] First step transitioning to Rust 2018. --- src/accel/bvh.rs | 12 +++++------ src/accel/bvh4.rs | 12 +++++------ src/accel/bvh_base.rs | 8 +++---- src/accel/light_array.rs | 6 +++--- src/accel/light_tree.rs | 10 ++++----- src/accel/mod.rs | 4 ++-- src/accel/objects_split.rs | 10 ++++----- src/algorithm.rs | 4 ++-- src/bbox.rs | 6 +++--- src/boundable.rs | 2 +- src/camera.rs | 8 +++---- src/color.rs | 6 +++--- src/fp_utils.rs | 2 +- src/image.rs | 12 +++++------ src/light/distant_disk_light.rs | 8 +++---- src/light/mod.rs | 6 +++--- src/light/rectangle_light.rs | 20 ++++++++--------- src/light/sphere_light.rs | 20 ++++++++--------- src/main.rs | 14 ++++++------ src/parse/basics.rs | 1 - src/parse/psy.rs | 14 ++++++------ src/parse/psy_assembly.rs | 2 +- src/parse/psy_light.rs | 6 +++--- src/parse/psy_mesh_surface.rs | 4 ++-- src/parse/psy_surface_shader.rs | 4 ++-- src/ray.rs | 2 +- src/renderer.rs | 36 +++++++++++++++---------------- src/sampling/monte_carlo.rs | 2 +- src/scene/assembly.rs | 22 +++++++++---------- src/scene/mod.rs | 14 ++++++------ src/scene/world.rs | 4 ++-- src/shading/mod.rs | 4 ++-- src/shading/surface_closure.rs | 8 +++---- src/surface/mod.rs | 10 ++++----- src/surface/triangle.rs | 6 +++--- src/surface/triangle_mesh.rs | 14 ++++++------ src/tracer.rs | 16 +++++++------- src/transform_stack.rs | 4 ++-- sub_crates/float4/src/lib.rs | 2 +- sub_crates/sobol/src/lib.rs | 4 ++-- sub_crates/spectra_xyz/src/lib.rs | 6 ++++-- 41 files changed, 178 insertions(+), 177 deletions(-) diff --git a/src/accel/bvh.rs b/src/accel/bvh.rs index 30215b6..731a3f1 100644 --- a/src/accel/bvh.rs +++ b/src/accel/bvh.rs @@ -4,12 +4,12 @@ use std; use mem_arena::MemArena; -use algorithm::partition; -use bbox::BBox; -use boundable::Boundable; -use lerp::lerp_slice; -use ray::AccelRay; -use timer::Timer; +use crate::algorithm::partition; +use crate::bbox::BBox; +use crate::boundable::Boundable; +use crate::lerp::lerp_slice; +use crate::ray::AccelRay; +use crate::timer::Timer; use super::bvh_base::{BVHBase, BVHBaseNode, BVH_MAX_DEPTH}; use super::ACCEL_NODE_RAY_TESTS; diff --git a/src/accel/bvh4.rs b/src/accel/bvh4.rs index 881f390..47595a7 100644 --- a/src/accel/bvh4.rs +++ b/src/accel/bvh4.rs @@ -4,12 +4,12 @@ use std; use mem_arena::MemArena; -use algorithm::partition; -use bbox::BBox; -use boundable::Boundable; -use lerp::lerp_slice; -use ray::AccelRay; -use timer::Timer; +use crate::algorithm::partition; +use crate::bbox::BBox; +use crate::boundable::Boundable; +use crate::lerp::lerp_slice; +use crate::ray::AccelRay; +use crate::timer::Timer; use super::bvh_base::{BVHBase, BVHBaseNode, BVH_MAX_DEPTH}; use super::ACCEL_NODE_RAY_TESTS; diff --git a/src/accel/bvh_base.rs b/src/accel/bvh_base.rs index afecff0..57e836f 100644 --- a/src/accel/bvh_base.rs +++ b/src/accel/bvh_base.rs @@ -1,9 +1,9 @@ #![allow(dead_code)] -use algorithm::merge_slices_append; -use bbox::BBox; -use lerp::lerp_slice; -use math::log2_64; +use crate::algorithm::merge_slices_append; +use crate::bbox::BBox; +use crate::lerp::lerp_slice; +use crate::math::log2_64; use super::objects_split::{median_split, sah_split}; diff --git a/src/accel/light_array.rs b/src/accel/light_array.rs index 7625820..a8b1a4e 100644 --- a/src/accel/light_array.rs +++ b/src/accel/light_array.rs @@ -1,8 +1,8 @@ use mem_arena::MemArena; -use bbox::BBox; -use math::{Normal, Point, Vector}; -use shading::surface_closure::SurfaceClosure; +use crate::bbox::BBox; +use crate::math::{Normal, Point, Vector}; +use crate::shading::surface_closure::SurfaceClosure; use super::LightAccel; diff --git a/src/accel/light_tree.rs b/src/accel/light_tree.rs index be3bab6..fb8f873 100644 --- a/src/accel/light_tree.rs +++ b/src/accel/light_tree.rs @@ -1,10 +1,10 @@ use mem_arena::MemArena; -use algorithm::merge_slices_append; -use bbox::BBox; -use lerp::lerp_slice; -use math::{Normal, Point, Vector}; -use shading::surface_closure::SurfaceClosure; +use crate::algorithm::merge_slices_append; +use crate::bbox::BBox; +use crate::lerp::lerp_slice; +use crate::math::{Normal, Point, Vector}; +use crate::shading::surface_closure::SurfaceClosure; use super::objects_split::sah_split; use super::LightAccel; diff --git a/src/accel/mod.rs b/src/accel/mod.rs index 6309f55..a5d20cc 100644 --- a/src/accel/mod.rs +++ b/src/accel/mod.rs @@ -7,8 +7,8 @@ mod objects_split; use std::cell::Cell; -use math::{Normal, Point, Vector}; -use shading::surface_closure::SurfaceClosure; +use crate::math::{Normal, Point, Vector}; +use crate::shading::surface_closure::SurfaceClosure; pub use self::bvh::{BVHNode, BVH}; pub use self::bvh4::{BVH4Node, BVH4}; diff --git a/src/accel/objects_split.rs b/src/accel/objects_split.rs index 9c50506..f4f72c2 100644 --- a/src/accel/objects_split.rs +++ b/src/accel/objects_split.rs @@ -5,11 +5,11 @@ use std::cmp::Ordering; use halton; -use algorithm::{partition, quick_select}; -use bbox::BBox; -use lerp::lerp_slice; -use math::{dot, Vector}; -use sampling::uniform_sample_hemisphere; +use crate::algorithm::{partition, quick_select}; +use crate::bbox::BBox; +use crate::lerp::lerp_slice; +use crate::math::{dot, Vector}; +use crate::sampling::uniform_sample_hemisphere; const SAH_BIN_COUNT: usize = 13; // Prime numbers work best, for some reason const SPLIT_PLANE_COUNT: usize = 5; diff --git a/src/algorithm.rs b/src/algorithm.rs index 017a561..67f8535 100644 --- a/src/algorithm.rs +++ b/src/algorithm.rs @@ -4,8 +4,8 @@ use std; use std::cmp; use std::cmp::Ordering; -use hash::hash_u64; -use lerp::{lerp_slice, Lerp}; +use crate::hash::hash_u64; +use crate::lerp::{lerp_slice, Lerp}; /// Selects an item from a slice based on a weighting function and a /// number (n) between 0.0 and 1.0. Returns the index of the selected diff --git a/src/bbox.rs b/src/bbox.rs index 45f4de3..4e7cb83 100644 --- a/src/bbox.rs +++ b/src/bbox.rs @@ -4,9 +4,9 @@ use std; use std::iter::Iterator; use std::ops::{BitOr, BitOrAssign}; -use lerp::{lerp, lerp_slice, Lerp}; -use math::{fast_minf32, Matrix4x4, Point}; -use ray::AccelRay; +use crate::lerp::{lerp, lerp_slice, Lerp}; +use crate::math::{fast_minf32, Matrix4x4, Point}; +use crate::ray::AccelRay; const BBOX_MAXT_ADJUST: f32 = 1.000_000_24; diff --git a/src/boundable.rs b/src/boundable.rs index 9be6859..40bca45 100644 --- a/src/boundable.rs +++ b/src/boundable.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] -use bbox::BBox; +use crate::bbox::BBox; pub trait Boundable { fn bounds(&self) -> &[BBox]; diff --git a/src/camera.rs b/src/camera.rs index 17c4a56..ba4d879 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -2,10 +2,10 @@ use mem_arena::MemArena; -use lerp::lerp_slice; -use math::{Matrix4x4, Point, Vector}; -use ray::Ray; -use sampling::square_to_circle; +use crate::lerp::lerp_slice; +use crate::math::{Matrix4x4, Point, Vector}; +use crate::ray::Ray; +use crate::sampling::square_to_circle; #[derive(Copy, Clone, Debug)] pub struct Camera<'a> { diff --git a/src/color.rs b/src/color.rs index ac87e31..8e9d711 100644 --- a/src/color.rs +++ b/src/color.rs @@ -2,11 +2,11 @@ use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign}; use spectra_xyz::{spectrum_xyz_to_p_4, EQUAL_ENERGY_REFLECTANCE}; +use crate::lerp::Lerp; +use crate::math::fast_exp; use float4::Float4; -use lerp::Lerp; -use math::fast_exp; -pub use color_util::{rec709_e_to_xyz, rec709_to_xyz, xyz_to_rec709, xyz_to_rec709_e}; +pub use crate::color_util::{rec709_e_to_xyz, rec709_to_xyz, xyz_to_rec709, xyz_to_rec709_e}; // Minimum and maximum wavelength of light we care about, in nanometers const WL_MIN: f32 = 380.0; diff --git a/src/fp_utils.rs b/src/fp_utils.rs index 0665e1d..40aa252 100644 --- a/src/fp_utils.rs +++ b/src/fp_utils.rs @@ -3,7 +3,7 @@ //! This is based on the work in section 3.9 of "Physically Based Rendering: //! From Theory to Implementation" 3rd edition by Pharr et al. -use math::{dot, Normal, Point, Vector}; +use crate::math::{dot, Normal, Point, Vector}; #[inline(always)] pub fn fp_gamma(n: u32) -> f32 { diff --git a/src/image.rs b/src/image.rs index fbfd96f..ec9ecf2 100644 --- a/src/image.rs +++ b/src/image.rs @@ -13,7 +13,7 @@ use half::f16; use openexr; use png_encode_mini; -use color::{xyz_to_rec709_e, XYZ}; +use crate::color::{xyz_to_rec709_e, XYZ}; #[derive(Debug)] #[allow(clippy::type_complexity)] @@ -100,15 +100,15 @@ impl Image { let mut f = io::BufWriter::new(File::create(path)?); // Write header - try!(write!(f, "P3\n{} {}\n255\n", self.res.0, self.res.1)); + r#try!(write!(f, "P3\n{} {}\n255\n", self.res.0, self.res.1)); // Write pixels for y in 0..self.res.1 { for x in 0..self.res.0 { let (r, g, b) = quantize_tri_255(xyz_to_srgbe(self.get(x, y).to_tuple())); - try!(write!(f, "{} {} {} ", r, g, b)); + r#try!(write!(f, "{} {} {} ", r, g, b)); } - try!(write!(f, "\n")); + r#try!(write!(f, "\n")); } // Done @@ -120,14 +120,14 @@ impl Image { let mut f = io::BufWriter::new(File::create(path)?); // Write header - try!(write!(f, "P6\n{} {}\n255\n", self.res.0, self.res.1)); + r#try!(write!(f, "P6\n{} {}\n255\n", self.res.0, self.res.1)); // Write pixels for y in 0..self.res.1 { for x in 0..self.res.0 { let (r, g, b) = quantize_tri_255(xyz_to_srgbe(self.get(x, y).to_tuple())); let d = [r, g, b]; - try!(f.write_all(&d)); + r#try!(f.write_all(&d)); } } diff --git a/src/light/distant_disk_light.rs b/src/light/distant_disk_light.rs index 6c8566a..a3a59da 100644 --- a/src/light/distant_disk_light.rs +++ b/src/light/distant_disk_light.rs @@ -2,10 +2,10 @@ use std::f64::consts::PI as PI_64; use mem_arena::MemArena; -use color::{Color, SpectralSample, XYZ}; -use lerp::lerp_slice; -use math::{coordinate_system_from_vector, Vector}; -use sampling::{uniform_sample_cone, uniform_sample_cone_pdf}; +use crate::color::{Color, SpectralSample, XYZ}; +use crate::lerp::lerp_slice; +use crate::math::{coordinate_system_from_vector, Vector}; +use crate::sampling::{uniform_sample_cone, uniform_sample_cone_pdf}; use super::WorldLightSource; diff --git a/src/light/mod.rs b/src/light/mod.rs index dc199a0..3e74691 100644 --- a/src/light/mod.rs +++ b/src/light/mod.rs @@ -4,9 +4,9 @@ mod sphere_light; use std::fmt::Debug; -use color::SpectralSample; -use math::{Matrix4x4, Normal, Point, Vector}; -use surface::Surface; +use crate::color::SpectralSample; +use crate::math::{Matrix4x4, Normal, Point, Vector}; +use crate::surface::Surface; pub use self::distant_disk_light::DistantDiskLight; pub use self::rectangle_light::RectangleLight; diff --git a/src/light/rectangle_light.rs b/src/light/rectangle_light.rs index 90704c7..e472039 100644 --- a/src/light/rectangle_light.rs +++ b/src/light/rectangle_light.rs @@ -1,18 +1,18 @@ use mem_arena::MemArena; -use bbox::BBox; -use boundable::Boundable; -use color::{Color, SpectralSample, XYZ}; -use lerp::lerp_slice; -use math::{cross, dot, Matrix4x4, Normal, Point, Vector}; -use ray::{AccelRay, Ray}; -use sampling::{ +use crate::bbox::BBox; +use crate::boundable::Boundable; +use crate::color::{Color, SpectralSample, XYZ}; +use crate::lerp::lerp_slice; +use crate::math::{cross, dot, Matrix4x4, Normal, Point, Vector}; +use crate::ray::{AccelRay, Ray}; +use crate::sampling::{ spherical_triangle_solid_angle, triangle_surface_area, uniform_sample_spherical_triangle, uniform_sample_triangle, }; -use shading::surface_closure::{EmitClosure, SurfaceClosureUnion}; -use shading::SurfaceShader; -use surface::{triangle, Surface, SurfaceIntersection, SurfaceIntersectionData}; +use crate::shading::surface_closure::{EmitClosure, SurfaceClosureUnion}; +use crate::shading::SurfaceShader; +use crate::surface::{triangle, Surface, SurfaceIntersection, SurfaceIntersectionData}; use super::SurfaceLight; diff --git a/src/light/sphere_light.rs b/src/light/sphere_light.rs index 9401774..ac04c60 100644 --- a/src/light/sphere_light.rs +++ b/src/light/sphere_light.rs @@ -2,16 +2,16 @@ use std::f64::consts::PI as PI_64; use mem_arena::MemArena; -use bbox::BBox; -use boundable::Boundable; -use color::{Color, SpectralSample, XYZ}; -use lerp::lerp_slice; -use math::{coordinate_system_from_vector, dot, Matrix4x4, Normal, Point, Vector}; -use ray::{AccelRay, Ray}; -use sampling::{uniform_sample_cone, uniform_sample_cone_pdf, uniform_sample_sphere}; -use shading::surface_closure::{EmitClosure, SurfaceClosureUnion}; -use shading::SurfaceShader; -use surface::{Surface, SurfaceIntersection, SurfaceIntersectionData}; +use crate::bbox::BBox; +use crate::boundable::Boundable; +use crate::color::{Color, SpectralSample, XYZ}; +use crate::lerp::lerp_slice; +use crate::math::{coordinate_system_from_vector, dot, Matrix4x4, Normal, Point, Vector}; +use crate::ray::{AccelRay, Ray}; +use crate::sampling::{uniform_sample_cone, uniform_sample_cone_pdf, uniform_sample_sphere}; +use crate::shading::surface_closure::{EmitClosure, SurfaceClosureUnion}; +use crate::shading::SurfaceShader; +use crate::surface::{Surface, SurfaceIntersection, SurfaceIntersectionData}; use super::SurfaceLight; diff --git a/src/main.rs b/src/main.rs index 601a2c9..89b05ee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,13 +72,13 @@ use clap::{App, Arg}; use mem_arena::MemArena; -use accel::{BVH4Node, BVHNode}; -use bbox::BBox; -use parse::{parse_scene, DataTree}; -use ray::{AccelRay, Ray}; -use renderer::LightPath; -use surface::SurfaceIntersection; -use timer::Timer; +use crate::accel::{BVH4Node, BVHNode}; +use crate::bbox::BBox; +use crate::parse::{parse_scene, DataTree}; +use crate::ray::{AccelRay, Ray}; +use crate::renderer::LightPath; +use crate::surface::SurfaceIntersection; +use crate::timer::Timer; const VERSION: &str = env!("CARGO_PKG_VERSION"); diff --git a/src/parse/basics.rs b/src/parse/basics.rs index 1da2e24..94d4db3 100644 --- a/src/parse/basics.rs +++ b/src/parse/basics.rs @@ -156,7 +156,6 @@ fn take_decimal_real(i: &[u8]) -> IResult<&[u8], &[u8]> { mod test { use super::take_decimal_real; use super::*; - use nom::IResult::*; #[test] fn ws_u32_1() { diff --git a/src/parse/psy.rs b/src/parse/psy.rs index eb89597..9b3e53e 100644 --- a/src/parse/psy.rs +++ b/src/parse/psy.rs @@ -7,13 +7,13 @@ use nom::IResult; use mem_arena::MemArena; -use camera::Camera; -use color::{rec709_e_to_xyz, XYZ}; -use light::WorldLightSource; -use math::Matrix4x4; -use renderer::Renderer; -use scene::Scene; -use scene::World; +use crate::camera::Camera; +use crate::color::{rec709_e_to_xyz, XYZ}; +use crate::light::WorldLightSource; +use crate::math::Matrix4x4; +use crate::renderer::Renderer; +use crate::scene::Scene; +use crate::scene::World; use super::basics::{ws_f32, ws_u32}; use super::psy_assembly::parse_assembly; diff --git a/src/parse/psy_assembly.rs b/src/parse/psy_assembly.rs index a9e27be..cf603ff 100644 --- a/src/parse/psy_assembly.rs +++ b/src/parse/psy_assembly.rs @@ -4,7 +4,7 @@ use std::result::Result; use mem_arena::MemArena; -use scene::{Assembly, AssemblyBuilder, Object}; +use crate::scene::{Assembly, AssemblyBuilder, Object}; use super::psy::{parse_matrix, PsyParseError}; use super::psy_light::{parse_rectangle_light, parse_sphere_light}; diff --git a/src/parse/psy_light.rs b/src/parse/psy_light.rs index ff0c35e..d13fe22 100644 --- a/src/parse/psy_light.rs +++ b/src/parse/psy_light.rs @@ -6,9 +6,9 @@ use nom::IResult; use mem_arena::MemArena; -use color::{rec709_e_to_xyz, XYZ}; -use light::{DistantDiskLight, RectangleLight, SphereLight}; -use math::Vector; +use crate::color::{rec709_e_to_xyz, XYZ}; +use crate::light::{DistantDiskLight, RectangleLight, SphereLight}; +use crate::math::Vector; use super::basics::ws_f32; use super::psy::PsyParseError; diff --git a/src/parse/psy_mesh_surface.rs b/src/parse/psy_mesh_surface.rs index 8e694c0..b321464 100644 --- a/src/parse/psy_mesh_surface.rs +++ b/src/parse/psy_mesh_surface.rs @@ -6,8 +6,8 @@ use nom::IResult; use mem_arena::MemArena; -use math::{Normal, Point}; -use surface::triangle_mesh::TriangleMesh; +use crate::math::{Normal, Point}; +use crate::surface::triangle_mesh::TriangleMesh; use super::basics::{ws_f32, ws_usize}; use super::psy::PsyParseError; diff --git a/src/parse/psy_surface_shader.rs b/src/parse/psy_surface_shader.rs index f289c25..d117829 100644 --- a/src/parse/psy_surface_shader.rs +++ b/src/parse/psy_surface_shader.rs @@ -6,8 +6,8 @@ use nom::IResult; use mem_arena::MemArena; -use color::{rec709_e_to_xyz, XYZ}; -use shading::{SimpleSurfaceShader, SurfaceShader}; +use crate::color::{rec709_e_to_xyz, XYZ}; +use crate::shading::{SimpleSurfaceShader, SurfaceShader}; use super::basics::ws_f32; use super::psy::PsyParseError; diff --git a/src/ray.rs b/src/ray.rs index 40e37c0..e7f9235 100644 --- a/src/ray.rs +++ b/src/ray.rs @@ -2,8 +2,8 @@ use std; +use crate::math::{Matrix4x4, Point, Vector}; use float4::Float4; -use math::{Matrix4x4, Point, Vector}; const OCCLUSION_FLAG: u32 = 1; const DONE_FLAG: u32 = 1 << 1; diff --git a/src/renderer.rs b/src/renderer.rs index 3c0bf36..7fbbfa3 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -10,22 +10,22 @@ use scoped_threadpool::Pool; use halton; -use accel::{ACCEL_NODE_RAY_TESTS, ACCEL_TRAV_TIME}; -use algorithm::partition_pair; -use color::{map_0_1_to_wavelength, Color, SpectralSample, XYZ}; +use crate::accel::{ACCEL_NODE_RAY_TESTS, ACCEL_TRAV_TIME}; +use crate::algorithm::partition_pair; +use crate::color::{map_0_1_to_wavelength, Color, SpectralSample, XYZ}; +use crate::fp_utils::robust_ray_origin; +use crate::hash::hash_u32; +use crate::hilbert; +use crate::image::Image; +use crate::math::{fast_logit, upper_power_of_two}; +use crate::mis::power_heuristic; +use crate::ray::Ray; +use crate::scene::{Scene, SceneLightSample}; +use crate::surface; +use crate::timer::Timer; +use crate::tracer::Tracer; +use crate::transform_stack::TransformStack; use float4::Float4; -use fp_utils::robust_ray_origin; -use hash::hash_u32; -use hilbert; -use image::Image; -use math::{fast_logit, upper_power_of_two}; -use mis::power_heuristic; -use ray::Ray; -use scene::{Scene, SceneLightSample}; -use surface; -use timer::Timer; -use tracer::Tracer; -use transform_stack::TransformStack; #[derive(Debug)] pub struct Renderer<'a> { @@ -299,7 +299,7 @@ impl<'a> Renderer<'a> { // Pre-calculate base64 encoding if needed let base64_enc = if do_blender_output { - use color::xyz_to_rec709_e; + use crate::color::xyz_to_rec709_e; Some(img_bucket.rgba_base64(xyz_to_rec709_e)) } else { None @@ -445,7 +445,7 @@ impl LightPath { // If it's an emission closure, handle specially: // - Collect light from the emission. // - Terminate the path. - use shading::surface_closure::SurfaceClosureUnion; + use crate::shading::surface_closure::SurfaceClosureUnion; if let SurfaceClosureUnion::EmitClosure(ref clsr) = *closure { if let LightPathEvent::CameraRay = self.event { self.color += clsr.emitted_color().e; @@ -657,7 +657,7 @@ impl LightPath { /// LDS samples aren't available. #[inline(always)] fn get_sample(dimension: u32, i: u32) -> f32 { - use hash::hash_u32_to_f32; + use crate::hash::hash_u32_to_f32; if dimension < halton::MAX_DIMENSION { halton::sample(dimension, i) } else { diff --git a/src/sampling/monte_carlo.rs b/src/sampling/monte_carlo.rs index f19acee..71dfa18 100644 --- a/src/sampling/monte_carlo.rs +++ b/src/sampling/monte_carlo.rs @@ -4,7 +4,7 @@ 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::{cross, dot, Point, Vector}; +use crate::math::{cross, dot, Point, Vector}; /// Maps the unit square to the unit circle. /// NOTE: x and y should be distributed within [-1, 1], diff --git a/src/scene/assembly.rs b/src/scene/assembly.rs index 45b252b..3092af0 100644 --- a/src/scene/assembly.rs +++ b/src/scene/assembly.rs @@ -2,17 +2,17 @@ use std::collections::HashMap; use mem_arena::MemArena; -use accel::BVH4; -use accel::{LightAccel, LightTree}; -use bbox::{transform_bbox_slice_from, BBox}; -use boundable::Boundable; -use color::SpectralSample; -use lerp::lerp_slice; -use light::SurfaceLight; -use math::{Matrix4x4, Normal, Point}; -use shading::SurfaceShader; -use surface::{Surface, SurfaceIntersection}; -use transform_stack::TransformStack; +use crate::accel::BVH4; +use crate::accel::{LightAccel, LightTree}; +use crate::bbox::{transform_bbox_slice_from, BBox}; +use crate::boundable::Boundable; +use crate::color::SpectralSample; +use crate::lerp::lerp_slice; +use crate::light::SurfaceLight; +use crate::math::{Matrix4x4, Normal, Point}; +use crate::shading::SurfaceShader; +use crate::surface::{Surface, SurfaceIntersection}; +use crate::transform_stack::TransformStack; #[derive(Copy, Clone, Debug)] pub struct Assembly<'a> { diff --git a/src/scene/mod.rs b/src/scene/mod.rs index 1c5c49e..b063324 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -1,13 +1,13 @@ mod assembly; mod world; -use accel::LightAccel; -use algorithm::weighted_choice; -use camera::Camera; -use color::SpectralSample; -use math::{Normal, Point, Vector}; -use surface::SurfaceIntersection; -use transform_stack::TransformStack; +use crate::accel::LightAccel; +use crate::algorithm::weighted_choice; +use crate::camera::Camera; +use crate::color::SpectralSample; +use crate::math::{Normal, Point, Vector}; +use crate::surface::SurfaceIntersection; +use crate::transform_stack::TransformStack; pub use self::assembly::{Assembly, AssemblyBuilder, InstanceType, Object}; pub use self::world::World; diff --git a/src/scene/world.rs b/src/scene/world.rs index d7387b1..2f6cdda 100644 --- a/src/scene/world.rs +++ b/src/scene/world.rs @@ -1,5 +1,5 @@ -use color::XYZ; -use light::WorldLightSource; +use crate::color::XYZ; +use crate::light::WorldLightSource; #[derive(Debug)] pub struct World<'a> { diff --git a/src/shading/mod.rs b/src/shading/mod.rs index 07e62d9..3cbb737 100644 --- a/src/shading/mod.rs +++ b/src/shading/mod.rs @@ -5,8 +5,8 @@ use std::fmt::Debug; use self::surface_closure::{ EmitClosure, GGXClosure, GTRClosure, LambertClosure, SurfaceClosureUnion, }; -use color::{Color, XYZ}; -use surface::SurfaceIntersectionData; +use crate::color::{Color, XYZ}; +use crate::surface::SurfaceIntersectionData; /// Trait for surface shaders. pub trait SurfaceShader: Debug + Sync { diff --git a/src/shading/surface_closure.rs b/src/shading/surface_closure.rs index 7e6a08d..8b316d2 100644 --- a/src/shading/surface_closure.rs +++ b/src/shading/surface_closure.rs @@ -2,10 +2,10 @@ use std::f32::consts::PI as PI_32; -use color::SpectralSample; -use lerp::lerp; -use math::{clamp, dot, zup_to_vec, Normal, Vector}; -use sampling::cosine_sample_hemisphere; +use crate::color::SpectralSample; +use crate::lerp::lerp; +use crate::math::{clamp, dot, zup_to_vec, Normal, Vector}; +use crate::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 8af0c56..acc77e3 100644 --- a/src/surface/mod.rs +++ b/src/surface/mod.rs @@ -5,11 +5,11 @@ pub mod triangle_mesh; use std::fmt::Debug; -use boundable::Boundable; -use math::{Matrix4x4, Normal, Point, Vector}; -use ray::{AccelRay, Ray}; -use shading::surface_closure::SurfaceClosureUnion; -use shading::SurfaceShader; +use crate::boundable::Boundable; +use crate::math::{Matrix4x4, Normal, Point, Vector}; +use crate::ray::{AccelRay, Ray}; +use crate::shading::surface_closure::SurfaceClosureUnion; +use crate::shading::SurfaceShader; pub trait Surface: Boundable + Debug + Sync { fn intersect_rays( diff --git a/src/surface/triangle.rs b/src/surface/triangle.rs index 1380a56..cec17a1 100644 --- a/src/surface/triangle.rs +++ b/src/surface/triangle.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] -use fp_utils::fp_gamma; -use math::Point; -use ray::Ray; +use crate::fp_utils::fp_gamma; +use crate::math::Point; +use crate::ray::Ray; /// Intersects `ray` with `tri`, returning `Some((t, b0, b1, b2))`, or `None` /// if no intersection. diff --git a/src/surface/triangle_mesh.rs b/src/surface/triangle_mesh.rs index ed2eecc..d3e0ca7 100644 --- a/src/surface/triangle_mesh.rs +++ b/src/surface/triangle_mesh.rs @@ -4,13 +4,13 @@ use std; use mem_arena::MemArena; -use accel::BVH4; -use bbox::BBox; -use boundable::Boundable; -use lerp::lerp_slice; -use math::{cross, dot, Matrix4x4, Normal, Point}; -use ray::{AccelRay, Ray}; -use shading::SurfaceShader; +use crate::accel::BVH4; +use crate::bbox::BBox; +use crate::boundable::Boundable; +use crate::lerp::lerp_slice; +use crate::math::{cross, dot, Matrix4x4, Normal, Point}; +use crate::ray::{AccelRay, Ray}; +use crate::shading::SurfaceShader; use super::triangle; use super::{Surface, SurfaceIntersection, SurfaceIntersectionData}; diff --git a/src/tracer.rs b/src/tracer.rs index b5d9c42..6f6f547 100644 --- a/src/tracer.rs +++ b/src/tracer.rs @@ -1,13 +1,13 @@ use std::iter; -use algorithm::partition; -use color::{rec709_to_xyz, XYZ}; -use lerp::lerp_slice; -use ray::{AccelRay, Ray}; -use scene::{Assembly, InstanceType, Object}; -use shading::{SimpleSurfaceShader, SurfaceShader}; -use surface::SurfaceIntersection; -use transform_stack::TransformStack; +use crate::algorithm::partition; +use crate::color::{rec709_to_xyz, XYZ}; +use crate::lerp::lerp_slice; +use crate::ray::{AccelRay, Ray}; +use crate::scene::{Assembly, InstanceType, Object}; +use crate::shading::{SimpleSurfaceShader, SurfaceShader}; +use crate::surface::SurfaceIntersection; +use crate::transform_stack::TransformStack; pub struct Tracer<'a> { rays: Vec, diff --git a/src/transform_stack.rs b/src/transform_stack.rs index 3041e4a..b425192 100644 --- a/src/transform_stack.rs +++ b/src/transform_stack.rs @@ -1,7 +1,7 @@ use std::cmp; -use algorithm::merge_slices_to; -use math::Matrix4x4; +use crate::algorithm::merge_slices_to; +use crate::math::Matrix4x4; pub struct TransformStack { stack: Vec, diff --git a/sub_crates/float4/src/lib.rs b/sub_crates/float4/src/lib.rs index e3a48f7..f51485b 100644 --- a/sub_crates/float4/src/lib.rs +++ b/sub_crates/float4/src/lib.rs @@ -1204,7 +1204,7 @@ mod fallback { //=========================================================================== #[cfg(all(target_arch = "x86_64", target_feature = "sse"))] -pub use x86_64_sse::{invert, transpose, v_max, v_min, Bool4, Float4}; +pub use crate::x86_64_sse::{invert, transpose, v_max, v_min, Bool4, Float4}; #[cfg(not(all(target_arch = "x86_64", target_feature = "sse")))] pub use fallback::{invert, transpose, v_max, v_min, Bool4, Float4}; diff --git a/sub_crates/sobol/src/lib.rs b/sub_crates/sobol/src/lib.rs index fee2c6d..c615306 100644 --- a/sub_crates/sobol/src/lib.rs +++ b/sub_crates/sobol/src/lib.rs @@ -22,8 +22,8 @@ mod matrices; -pub use matrices::NUM_DIMENSIONS; -use matrices::{MATRICES, SIZE}; +pub use crate::matrices::NUM_DIMENSIONS; +use crate::matrices::{MATRICES, SIZE}; /// Compute one component of the Sobol'-sequence, where the component /// corresponds to the dimension parameter, and the index specifies diff --git a/sub_crates/spectra_xyz/src/lib.rs b/sub_crates/spectra_xyz/src/lib.rs index c2fb120..43689c1 100644 --- a/sub_crates/spectra_xyz/src/lib.rs +++ b/sub_crates/spectra_xyz/src/lib.rs @@ -11,9 +11,11 @@ use std::f32; mod spectra_tables; -pub use spectra_tables::{EQUAL_ENERGY_REFLECTANCE, SPECTRUM_SAMPLE_MAX, SPECTRUM_SAMPLE_MIN}; +pub use crate::spectra_tables::{ + EQUAL_ENERGY_REFLECTANCE, SPECTRUM_SAMPLE_MAX, SPECTRUM_SAMPLE_MIN, +}; -use spectra_tables::{ +use crate::spectra_tables::{ SPECTRUM_DATA_POINTS, // CMF_X, // CMF_Y,