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"
version = "0.1.0"
authors = ["Bill Thiede <rust@xinu.tv>"]
edition = "2018"
[dependencies]
rand = "0.5.5"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,11 +1,11 @@
// 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))]
use aabb::AABB;
use hitable::Hit;
use hitable::HitRecord;
use material::Material;
use ray::Ray;
use vec3::Vec3;
use crate::aabb::AABB;
use crate::hitable::Hit;
use crate::hitable::HitRecord;
use crate::material::Material;
use crate::ray::Ray;
use crate::vec3::Vec3;
pub struct XYRect<M>
where

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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