cargo fix --edition and add edition="2018" to Cargo.toml.

This commit is contained in:
Bill Thiede 2019-02-07 16:36:55 -08:00
parent 1be9c800a7
commit c8f5bf9e19
36 changed files with 265 additions and 263 deletions

View File

@ -2,6 +2,8 @@
name = "rtiow" name = "rtiow"
version = "0.1.0" version = "0.1.0"
authors = ["Bill Thiede <rust@xinu.tv>"] authors = ["Bill Thiede <rust@xinu.tv>"]
edition = "2018"
[dependencies] [dependencies]
rand = "0.5.5" rand = "0.5.5"

View File

@ -1,7 +1,7 @@
use std::fmt; use std::fmt;
use ray::Ray; use crate::ray::Ray;
use vec3::Vec3; use crate::vec3::Vec3;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub struct AABB { pub struct AABB {

View File

@ -5,11 +5,11 @@ use std::time::Instant;
use rand; use rand;
use rand::Rng; use rand::Rng;
use aabb::surrounding_box; use crate::aabb::surrounding_box;
use aabb::AABB; use crate::aabb::AABB;
use hitable::Hit; use crate::hitable::Hit;
use hitable::HitRecord; use crate::hitable::HitRecord;
use ray::Ray; use crate::ray::Ray;
enum BVHNode { enum BVHNode {
Leaf(Box<Hit>), Leaf(Box<Hit>),
@ -229,12 +229,12 @@ impl Hit for BVH {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use aabb::AABB; use crate::aabb::AABB;
use material::Lambertian; use crate::material::Lambertian;
use material::Metal; use crate::material::Metal;
use sphere::Sphere; use crate::sphere::Sphere;
use texture::ConstantTexture; use crate::texture::ConstantTexture;
use vec3::Vec3; use crate::vec3::Vec3;
use super::*; use super::*;

View File

@ -3,9 +3,9 @@ use std::f32::consts::PI;
use self::rand::Rng; use self::rand::Rng;
use ray::Ray; use crate::ray::Ray;
use vec3::cross; use crate::vec3::cross;
use vec3::Vec3; use crate::vec3::Vec3;
fn random_in_unit_disk() -> Vec3 { fn random_in_unit_disk() -> Vec3 {
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();

View File

@ -3,13 +3,13 @@ use std;
use rand; use rand;
use rand::Rng; use rand::Rng;
use aabb::AABB; use crate::aabb::AABB;
use hitable::Hit; use crate::hitable::Hit;
use hitable::HitRecord; use crate::hitable::HitRecord;
use material::Isotropic; use crate::material::Isotropic;
use ray::Ray; use crate::ray::Ray;
use texture::Texture; use crate::texture::Texture;
use vec3::Vec3; use crate::vec3::Vec3;
pub struct ConstantMedium<H, T> pub struct ConstantMedium<H, T>
where where

View File

@ -1,16 +1,16 @@
use std::sync::Arc; use std::sync::Arc;
use aabb::AABB; use crate::aabb::AABB;
use flip_normals::FlipNormals; use crate::flip_normals::FlipNormals;
use hitable::Hit; use crate::hitable::Hit;
use hitable::HitRecord; use crate::hitable::HitRecord;
use hitable_list::HitableList; use crate::hitable_list::HitableList;
use material::Material; use crate::material::Material;
use ray::Ray; use crate::ray::Ray;
use rect::XYRect; use crate::rect::XYRect;
use rect::XZRect; use crate::rect::XZRect;
use rect::YZRect; use crate::rect::YZRect;
use vec3::Vec3; use crate::vec3::Vec3;
pub struct Cuboid { pub struct Cuboid {
p_min: Vec3, p_min: Vec3,

View File

@ -1,7 +1,7 @@
use aabb::AABB; use crate::aabb::AABB;
use hitable::Hit; use crate::hitable::Hit;
use hitable::HitRecord; use crate::hitable::HitRecord;
use ray::Ray; use crate::ray::Ray;
pub struct FlipNormals<H> pub struct FlipNormals<H>
where where

View File

@ -1,9 +1,9 @@
use std::sync::Arc; use std::sync::Arc;
use aabb::AABB; use crate::aabb::AABB;
use material::Material; use crate::material::Material;
use ray::Ray; use crate::ray::Ray;
use vec3::Vec3; use crate::vec3::Vec3;
pub struct HitRecord<'m> { pub struct HitRecord<'m> {
pub t: f32, pub t: f32,

View File

@ -1,11 +1,11 @@
use std; use std;
use aabb::surrounding_box; use crate::aabb::surrounding_box;
use aabb::AABB; use crate::aabb::AABB;
use hitable::Hit; use crate::hitable::Hit;
use hitable::HitRecord; use crate::hitable::HitRecord;
use ray::Ray; use crate::ray::Ray;
use vec3::Vec3; use crate::vec3::Vec3;
#[derive(Default)] #[derive(Default)]
pub struct HitableList { pub struct HitableList {

View File

@ -1,10 +1,10 @@
use std::fmt; use std::fmt;
use aabb::surrounding_box; use crate::aabb::surrounding_box;
use aabb::AABB; use crate::aabb::AABB;
use hitable::Hit; use crate::hitable::Hit;
use hitable::HitRecord; use crate::hitable::HitRecord;
use ray::Ray; use crate::ray::Ray;
pub enum KDTree { pub enum KDTree {
Leaf(Box<Hit>), Leaf(Box<Hit>),

View File

@ -3,11 +3,11 @@ use std::sync::Arc;
extern crate rand; extern crate rand;
use self::rand::Rng; use self::rand::Rng;
use hitable::HitRecord; use crate::hitable::HitRecord;
use ray::Ray; use crate::ray::Ray;
use texture::Texture; use crate::texture::Texture;
use vec3::dot; use crate::vec3::dot;
use vec3::Vec3; use crate::vec3::Vec3;
fn random_in_unit_sphere() -> Vec3 { fn random_in_unit_sphere() -> Vec3 {
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
@ -253,7 +253,7 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use texture::ConstantTexture; use crate::texture::ConstantTexture;
#[test] #[test]
fn arc_material() { fn arc_material() {

View File

@ -1,12 +1,12 @@
use aabb::surrounding_box; use crate::aabb::surrounding_box;
use aabb::AABB; use crate::aabb::AABB;
use hitable::Hit; use crate::hitable::Hit;
use hitable::HitRecord; use crate::hitable::HitRecord;
use material::Material; use crate::material::Material;
use ray::Ray; use crate::ray::Ray;
use sphere::get_sphere_uv; use crate::sphere::get_sphere_uv;
use vec3::dot; use crate::vec3::dot;
use vec3::Vec3; use crate::vec3::Vec3;
pub struct MovingSphere<M> pub struct MovingSphere<M>
where where

View File

@ -1,8 +1,8 @@
/// Implements the concepts from https://lodev.org/cgtutor/randomnoise.html /// Implements the concepts from https://lodev.org/cgtutor/randomnoise.html
use rand; use rand;
use noise::NoiseSource; use crate::noise::NoiseSource;
use vec3::Vec3; use crate::vec3::Vec3;
const NOISE_SIZE: usize = 128; const NOISE_SIZE: usize = 128;
pub struct Lode { pub struct Lode {

View File

@ -3,7 +3,7 @@ pub mod perlin;
use std::f32::consts::PI; use std::f32::consts::PI;
use vec3::Vec3; use crate::vec3::Vec3;
pub trait NoiseSource: Send + Sync { pub trait NoiseSource: Send + Sync {
/// value returns noise on the interval [0., 1.). /// value returns noise on the interval [0., 1.).

View File

@ -2,9 +2,9 @@
#![cfg_attr(feature = "cargo-clippy", allow(many_single_char_names))] #![cfg_attr(feature = "cargo-clippy", allow(many_single_char_names))]
use rand::Rng; use rand::Rng;
use noise::NoiseSource; use crate::noise::NoiseSource;
use vec3::dot; use crate::vec3::dot;
use vec3::Vec3; use crate::vec3::Vec3;
pub struct Perlin { pub struct Perlin {
ran_vec: Vec<Vec3>, ran_vec: Vec<Vec3>,

View File

@ -1,4 +1,4 @@
use vec3::Vec3; use crate::vec3::Vec3;
#[derive(Copy, Clone, Debug, Default)] #[derive(Copy, Clone, Debug, Default)]
pub struct Ray { pub struct Ray {

View File

@ -1,11 +1,11 @@
// There are many math functions in this file, so we allow single letter variable names. // There are many math functions in this file, so we allow single letter variable names.
#![cfg_attr(feature = "cargo-clippy", allow(many_single_char_names))] #![cfg_attr(feature = "cargo-clippy", allow(many_single_char_names))]
use aabb::AABB; use crate::aabb::AABB;
use hitable::Hit; use crate::hitable::Hit;
use hitable::HitRecord; use crate::hitable::HitRecord;
use material::Material; use crate::material::Material;
use ray::Ray; use crate::ray::Ray;
use vec3::Vec3; use crate::vec3::Vec3;
pub struct XYRect<M> pub struct XYRect<M>
where where

View File

@ -15,12 +15,12 @@ use num_cpus;
use rand; use rand;
use rand::Rng; use rand::Rng;
use camera::Camera; use crate::camera::Camera;
use hitable::Hit; use crate::hitable::Hit;
use ray::Ray; use crate::ray::Ray;
use scenes; use crate::scenes;
use texture::EnvMap; use crate::texture::EnvMap;
use vec3::Vec3; use crate::vec3::Vec3;
#[derive(Debug)] #[derive(Debug)]
pub enum Model { pub enum Model {

View File

@ -2,11 +2,11 @@ use std::f32::consts::PI;
use std::f32::MAX; use std::f32::MAX;
use std::f32::MIN; use std::f32::MIN;
use aabb::AABB; use crate::aabb::AABB;
use hitable::Hit; use crate::hitable::Hit;
use hitable::HitRecord; use crate::hitable::HitRecord;
use ray::Ray; use crate::ray::Ray;
use vec3::Vec3; use crate::vec3::Vec3;
pub struct RotateY<H> pub struct RotateY<H>
where where

View File

@ -1,17 +1,17 @@
use rand; use rand;
use rand::Rng; use rand::Rng;
use bvh::BVH; use crate::bvh::BVH;
use camera::Camera; use crate::camera::Camera;
use hitable::Hit; use crate::hitable::Hit;
use hitable_list::HitableList; use crate::hitable_list::HitableList;
use kdtree::KDTree; use crate::kdtree::KDTree;
use material::Lambertian; use crate::material::Lambertian;
use renderer::Opt; use crate::renderer::Opt;
use renderer::Scene; use crate::renderer::Scene;
use sphere::Sphere; use crate::sphere::Sphere;
use texture::ConstantTexture; use crate::texture::ConstantTexture;
use vec3::Vec3; use crate::vec3::Vec3;
pub fn new(opt: &Opt) -> Scene { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(20., 20., 20.); let lookfrom = Vec3::new(20., 20., 20.);

View File

@ -1,21 +1,21 @@
use rand; use rand;
use rand::Rng; use rand::Rng;
use camera::Camera; use crate::camera::Camera;
use hitable::Hit; use crate::hitable::Hit;
use hitable_list::HitableList; use crate::hitable_list::HitableList;
use kdtree::KDTree; use crate::kdtree::KDTree;
use material::Dielectric; use crate::material::Dielectric;
use material::Lambertian; use crate::material::Lambertian;
use material::Material; use crate::material::Material;
use material::Metal; use crate::material::Metal;
use renderer::Opt; use crate::renderer::Opt;
use renderer::Scene; use crate::renderer::Scene;
use sphere::Sphere; use crate::sphere::Sphere;
use texture::CheckerTexture; use crate::texture::CheckerTexture;
use texture::ConstantTexture; use crate::texture::ConstantTexture;
use texture::EnvMap; use crate::texture::EnvMap;
use vec3::Vec3; use crate::vec3::Vec3;
pub fn new(opt: &Opt) -> Scene { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(13., 2., 3.); let lookfrom = Vec3::new(13., 2., 3.);

View File

@ -1,14 +1,14 @@
use bvh::BVH; use crate::bvh::BVH;
use camera::Camera; use crate::camera::Camera;
use hitable::Hit; use crate::hitable::Hit;
use material::Lambertian; use crate::material::Lambertian;
use material::Metal; use crate::material::Metal;
use moving_sphere::MovingSphere; use crate::moving_sphere::MovingSphere;
use renderer::Opt; use crate::renderer::Opt;
use renderer::Scene; use crate::renderer::Scene;
use sphere::Sphere; use crate::sphere::Sphere;
use texture::ConstantTexture; use crate::texture::ConstantTexture;
use vec3::Vec3; use crate::vec3::Vec3;
pub fn new(opt: &Opt) -> Scene { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(3., 3., 2.); let lookfrom = Vec3::new(3., 3., 2.);

View File

@ -1,22 +1,22 @@
use std::sync::Arc; use std::sync::Arc;
use camera::Camera; use crate::camera::Camera;
use cuboid::Cuboid; use crate::cuboid::Cuboid;
use flip_normals::FlipNormals; use crate::flip_normals::FlipNormals;
use hitable::Hit; use crate::hitable::Hit;
use hitable_list::HitableList; use crate::hitable_list::HitableList;
use kdtree::KDTree; use crate::kdtree::KDTree;
use material::DiffuseLight; use crate::material::DiffuseLight;
use material::Lambertian; use crate::material::Lambertian;
use rect::XYRect; use crate::rect::XYRect;
use rect::XZRect; use crate::rect::XZRect;
use rect::YZRect; use crate::rect::YZRect;
use renderer::Opt; use crate::renderer::Opt;
use renderer::Scene; use crate::renderer::Scene;
use rotate::RotateY; use crate::rotate::RotateY;
use texture::ConstantTexture; use crate::texture::ConstantTexture;
use translate::Translate; use crate::translate::Translate;
use vec3::Vec3; use crate::vec3::Vec3;
pub fn new(opt: &Opt) -> Scene { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(278., 278., -800.); let lookfrom = Vec3::new(278., 278., -800.);

View File

@ -1,24 +1,24 @@
use std::sync::Arc; use std::sync::Arc;
use camera::Camera; use crate::camera::Camera;
use constant_medium::ConstantMedium; use crate::constant_medium::ConstantMedium;
use cuboid::Cuboid; use crate::cuboid::Cuboid;
use flip_normals::FlipNormals; use crate::flip_normals::FlipNormals;
use hitable::Hit; use crate::hitable::Hit;
use hitable_list::HitableList; use crate::hitable_list::HitableList;
use kdtree::KDTree; use crate::kdtree::KDTree;
use material::DiffuseLight; use crate::material::DiffuseLight;
use material::Lambertian; use crate::material::Lambertian;
use material::Material; use crate::material::Material;
use rect::XYRect; use crate::rect::XYRect;
use rect::XZRect; use crate::rect::XZRect;
use rect::YZRect; use crate::rect::YZRect;
use renderer::Opt; use crate::renderer::Opt;
use renderer::Scene; use crate::renderer::Scene;
use rotate::RotateY; use crate::rotate::RotateY;
use texture::ConstantTexture; use crate::texture::ConstantTexture;
use translate::Translate; use crate::translate::Translate;
use vec3::Vec3; use crate::vec3::Vec3;
pub fn new(opt: &Opt) -> Scene { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(278., 278., -800.); let lookfrom = Vec3::new(278., 278., -800.);

View File

@ -4,30 +4,30 @@ use image;
use rand; use rand;
use rand::Rng; use rand::Rng;
use camera::Camera; use crate::camera::Camera;
use constant_medium::ConstantMedium; use crate::constant_medium::ConstantMedium;
use cuboid::Cuboid; use crate::cuboid::Cuboid;
use hitable::Hit; use crate::hitable::Hit;
use hitable_list::HitableList; use crate::hitable_list::HitableList;
use kdtree::KDTree; use crate::kdtree::KDTree;
use material::Dielectric; use crate::material::Dielectric;
use material::DiffuseLight; use crate::material::DiffuseLight;
use material::Lambertian; use crate::material::Lambertian;
use material::Material; use crate::material::Material;
use material::Metal; use crate::material::Metal;
use moving_sphere::MovingSphere; use crate::moving_sphere::MovingSphere;
use noise::perlin::Perlin; use crate::noise::perlin::Perlin;
use noise::NoiseType; use crate::noise::NoiseType;
use rect::XZRect; use crate::rect::XZRect;
use renderer::Opt; use crate::renderer::Opt;
use renderer::Scene; use crate::renderer::Scene;
use rotate::RotateY; use crate::rotate::RotateY;
use sphere::Sphere; use crate::sphere::Sphere;
use texture::ConstantTexture; use crate::texture::ConstantTexture;
use texture::ImageTexture; use crate::texture::ImageTexture;
use texture::NoiseTexture; use crate::texture::NoiseTexture;
use translate::Translate; use crate::translate::Translate;
use vec3::Vec3; use crate::vec3::Vec3;
pub fn new(opt: &Opt) -> Scene { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(478., 278., -600.); let lookfrom = Vec3::new(478., 278., -600.);

View File

@ -2,19 +2,19 @@ use std::sync::Arc;
use rand; use rand;
use camera::Camera; use crate::camera::Camera;
use hitable::Hit; use crate::hitable::Hit;
use hitable_list::HitableList; use crate::hitable_list::HitableList;
use kdtree::KDTree; use crate::kdtree::KDTree;
use material::Lambertian; use crate::material::Lambertian;
use noise::perlin::Perlin; use crate::noise::perlin::Perlin;
use noise::NoiseType; use crate::noise::NoiseType;
use renderer::Opt; use crate::renderer::Opt;
use renderer::Scene; use crate::renderer::Scene;
use sphere::Sphere; use crate::sphere::Sphere;
use texture::NoiseTexture; use crate::texture::NoiseTexture;
use texture::Texture; use crate::texture::Texture;
use vec3::Vec3; use crate::vec3::Vec3;
pub fn new(opt: &Opt) -> Scene { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(13., 2., 3.); let lookfrom = Vec3::new(13., 2., 3.);

View File

@ -1,24 +1,24 @@
use image; use image;
use rand; use rand;
use camera::Camera; use crate::camera::Camera;
use hitable::Hit; use crate::hitable::Hit;
use hitable_list::HitableList; use crate::hitable_list::HitableList;
use kdtree::KDTree; use crate::kdtree::KDTree;
use material::DiffuseLight; use crate::material::DiffuseLight;
use material::Lambertian; use crate::material::Lambertian;
use noise::perlin::Perlin; use crate::noise::perlin::Perlin;
use noise::NoiseType; use crate::noise::NoiseType;
use rect::XYRect; use crate::rect::XYRect;
use rect::XZRect; use crate::rect::XZRect;
use rect::YZRect; use crate::rect::YZRect;
use renderer::Opt; use crate::renderer::Opt;
use renderer::Scene; use crate::renderer::Scene;
use sphere::Sphere; use crate::sphere::Sphere;
use texture::ConstantTexture; use crate::texture::ConstantTexture;
use texture::ImageTexture; use crate::texture::ImageTexture;
use texture::NoiseTexture; use crate::texture::NoiseTexture;
use vec3::Vec3; use crate::vec3::Vec3;
pub fn new(opt: &Opt) -> Scene { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(20., 20., 20.); let lookfrom = Vec3::new(20., 20., 20.);

View File

@ -1,15 +1,15 @@
use camera::Camera; use crate::camera::Camera;
use hitable::Hit; use crate::hitable::Hit;
use hitable_list::HitableList; use crate::hitable_list::HitableList;
use kdtree::KDTree; use crate::kdtree::KDTree;
use material::Lambertian; use crate::material::Lambertian;
use material::Metal; use crate::material::Metal;
use moving_sphere::MovingSphere; use crate::moving_sphere::MovingSphere;
use renderer::Opt; use crate::renderer::Opt;
use renderer::Scene; use crate::renderer::Scene;
use sphere::Sphere; use crate::sphere::Sphere;
use texture::ConstantTexture; use crate::texture::ConstantTexture;
use vec3::Vec3; use crate::vec3::Vec3;
pub fn new(opt: &Opt) -> Scene { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(3., 3., 2.); let lookfrom = Vec3::new(3., 3., 2.);

View File

@ -1,12 +1,12 @@
use std::f32::consts::PI; use std::f32::consts::PI;
use aabb::AABB; use crate::aabb::AABB;
use hitable::Hit; use crate::hitable::Hit;
use hitable::HitRecord; use crate::hitable::HitRecord;
use material::Material; use crate::material::Material;
use ray::Ray; use crate::ray::Ray;
use vec3::dot; use crate::vec3::dot;
use vec3::Vec3; use crate::vec3::Vec3;
pub struct Sphere<M> pub struct Sphere<M>
where where

View File

@ -1,5 +1,5 @@
use texture::Texture; use crate::texture::Texture;
use vec3::Vec3; use crate::vec3::Vec3;
pub struct CheckerTexture<T> pub struct CheckerTexture<T>
where where

View File

@ -1,5 +1,5 @@
use texture::Texture; use crate::texture::Texture;
use vec3::Vec3; use crate::vec3::Vec3;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub struct ConstantTexture { pub struct ConstantTexture {

View File

@ -2,9 +2,9 @@ use std::f32;
use image::RgbImage; use image::RgbImage;
use texture::ImageTexture; use crate::texture::ImageTexture;
use texture::Texture; use crate::texture::Texture;
use vec3::Vec3; use crate::vec3::Vec3;
#[derive(Debug)] #[derive(Debug)]
pub struct EnvMap { pub struct EnvMap {

View File

@ -1,7 +1,7 @@
use image::RgbImage; use image::RgbImage;
use texture::Texture; use crate::texture::Texture;
use vec3::Vec3; use crate::vec3::Vec3;
#[derive(Debug)] #[derive(Debug)]
pub struct ImageTexture { pub struct ImageTexture {

View File

@ -3,15 +3,15 @@ mod constant;
mod image; mod image;
mod noise; mod noise;
mod envmap; mod envmap;
pub use texture::checker::CheckerTexture; pub use crate::texture::checker::CheckerTexture;
pub use texture::constant::ConstantTexture; pub use crate::texture::constant::ConstantTexture;
pub use texture::envmap::EnvMap; pub use crate::texture::envmap::EnvMap;
pub use texture::image::ImageTexture; pub use crate::texture::image::ImageTexture;
pub use texture::noise::NoiseTexture; pub use crate::texture::noise::NoiseTexture;
use std::sync::Arc; use std::sync::Arc;
use vec3::Vec3; use crate::vec3::Vec3;
pub trait Texture: Send + Sync { pub trait Texture: Send + Sync {
fn value(&self, u: f32, v: f32, p: Vec3) -> Vec3; fn value(&self, u: f32, v: f32, p: Vec3) -> Vec3;

View File

@ -1,7 +1,7 @@
use noise::NoiseSource; use crate::noise::NoiseSource;
use noise::NoiseType; use crate::noise::NoiseType;
use texture::Texture; use crate::texture::Texture;
use vec3::Vec3; use crate::vec3::Vec3;
pub struct NoiseTexture<N> pub struct NoiseTexture<N>
where where

View File

@ -1,8 +1,8 @@
use aabb::AABB; use crate::aabb::AABB;
use hitable::Hit; use crate::hitable::Hit;
use hitable::HitRecord; use crate::hitable::HitRecord;
use ray::Ray; use crate::ray::Ray;
use vec3::Vec3; use crate::vec3::Vec3;
pub struct Translate<H> pub struct Translate<H>
where where