cargo fmt.

This commit is contained in:
Bill Thiede 2022-07-28 21:39:00 -07:00
parent 51185e9e84
commit 78f7ca8956
41 changed files with 329 additions and 406 deletions

View File

@ -1,15 +1,6 @@
use std::fmt; use std::{fmt, time::SystemTime};
use std::time::SystemTime;
use actix_web::http; use actix_web::{http, middleware, server, App, HttpRequest, HttpResponse, Path, Query, Result};
use actix_web::middleware;
use actix_web::server;
use actix_web::App;
use actix_web::HttpRequest;
use actix_web::HttpResponse;
use actix_web::Path;
use actix_web::Query;
use actix_web::Result;
use askama::Template; use askama::Template;
use log::info; use log::info;
use rand::SeedableRng; use rand::SeedableRng;
@ -17,13 +8,12 @@ use rand_xorshift::XorShiftRng;
use serde_derive::Deserialize; use serde_derive::Deserialize;
use structopt::StructOpt; use structopt::StructOpt;
use renderer::noise; use renderer::{
use renderer::noise::lode::Lode; noise,
use renderer::noise::perlin::Perlin; noise::{lode::Lode, perlin::Perlin, NoiseType},
use renderer::noise::NoiseType; texture::{NoiseTexture, Texture},
use renderer::texture::NoiseTexture; vec3::Vec3,
use renderer::texture::Texture; };
use renderer::vec3::Vec3;
#[derive(StructOpt)] #[derive(StructOpt)]
#[structopt(name = "noise_explorer", about = "CLI for exploring Perlin noise")] #[structopt(name = "noise_explorer", about = "CLI for exploring Perlin noise")]
@ -453,16 +443,9 @@ fn main() -> Result<(), std::io::Error> {
mod tests { mod tests {
use std::str; use std::str;
use actix_web::http::Method; use actix_web::{http::Method, test::TestServer, HttpMessage, Path, Query};
use actix_web::test::TestServer;
use actix_web::HttpMessage;
use actix_web::Path;
use actix_web::Query;
use super::NoiseParamsMarble; use super::{NoiseParamsMarble, NoiseParamsScale, NoiseParamsTurbulence, OptionalParams};
use super::NoiseParamsScale;
use super::NoiseParamsTurbulence;
use super::OptionalParams;
#[test] #[test]
fn noise_param_from_req() { fn noise_param_from_req() {

View File

@ -1,15 +1,12 @@
#[macro_use] #[macro_use]
extern crate criterion; extern crate criterion;
use criterion::Criterion; use criterion::{Criterion, ParameterizedBenchmark};
use criterion::ParameterizedBenchmark;
use rtiow::hitable::Hit; use rtiow::{
use rtiow::material::Lambertian; hitable::Hit, material::Lambertian, ray::Ray, sphere::Sphere, texture::ConstantTexture,
use rtiow::ray::Ray; vec3::Vec3,
use rtiow::sphere::Sphere; };
use rtiow::texture::ConstantTexture;
use rtiow::vec3::Vec3;
fn criterion_benchmark(c: &mut Criterion) { fn criterion_benchmark(c: &mut Criterion) {
let sphere = Sphere::new( let sphere = Sphere::new(

View File

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

View File

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

View File

@ -1,11 +1,11 @@
use std::f32::consts::PI; use std::f32::consts::PI;
use rand; use rand::{self, Rng};
use rand::Rng;
use crate::ray::Ray; use crate::{
use crate::vec3::cross; ray::Ray,
use crate::vec3::Vec3; vec3::{cross, 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

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

View File

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

View File

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

View File

@ -1,9 +1,6 @@
use std::sync::Arc; use std::sync::Arc;
use crate::aabb::AABB; use crate::{aabb::AABB, material::Material, ray::Ray, vec3::Vec3};
use crate::material::Material;
use crate::ray::Ray;
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 crate::aabb::surrounding_box; use crate::{
use crate::aabb::AABB; aabb::{surrounding_box, AABB},
use crate::hitable::Hit; hitable::{Hit, HitRecord},
use crate::hitable::HitRecord; ray::Ray,
use crate::ray::Ray; vec3::Vec3,
use crate::vec3::Vec3; };
#[derive(Default)] #[derive(Default)]
pub struct HitableList { pub struct HitableList {

View File

@ -2,11 +2,11 @@ use std::fmt;
use log::info; use log::info;
use crate::aabb::surrounding_box; use crate::{
use crate::aabb::AABB; aabb::{surrounding_box, AABB},
use crate::hitable::Hit; hitable::{Hit, HitRecord},
use crate::hitable::HitRecord; ray::Ray,
use crate::ray::Ray; };
pub enum KDTree { pub enum KDTree {
Leaf(Box<dyn Hit>), Leaf(Box<dyn Hit>),

View File

@ -1,13 +1,13 @@
use std::sync::Arc; use std::sync::Arc;
use rand; use rand::{self, Rng};
use rand::Rng;
use crate::hitable::HitRecord; use crate::{
use crate::ray::Ray; hitable::HitRecord,
use crate::texture::Texture; ray::Ray,
use crate::vec3::dot; texture::Texture,
use crate::vec3::Vec3; vec3::{dot, 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();

View File

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

View File

@ -2,8 +2,7 @@ use log::trace;
/// 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 crate::noise::NoiseSource; use crate::{noise::NoiseSource, vec3::Vec3};
use crate::vec3::Vec3;
const NOISE_SIZE: usize = 128; const NOISE_SIZE: usize = 128;
pub struct Lode { pub struct Lode {

View File

@ -1,12 +1,12 @@
// 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.
#![allow(clippy::many_single_char_names)] #![allow(clippy::many_single_char_names)]
use log::trace; use log::trace;
use rand::seq::SliceRandom; use rand::{seq::SliceRandom, Rng};
use rand::Rng;
use crate::noise::NoiseSource; use crate::{
use crate::vec3::dot; noise::NoiseSource,
use crate::vec3::Vec3; vec3::{dot, Vec3},
};
pub struct Perlin { pub struct Perlin {
ran_vec: Vec<Vec3>, ran_vec: Vec<Vec3>,

View File

@ -1,10 +1,11 @@
use std::collections::HashMap; use std::{
use std::fs::File; collections::HashMap,
use std::io::BufWriter; fs::File,
use std::path::Path; io::BufWriter,
use std::sync::Arc; path::Path,
use std::sync::Mutex; sync::{Arc, Mutex},
use std::time; time,
};
use chrono::Local; use chrono::Local;
use image; use image;
@ -12,8 +13,7 @@ use lazy_static::lazy_static;
use log::info; use log::info;
use serde_derive::Serialize; use serde_derive::Serialize;
use crate::renderer::Scene; use crate::{renderer::Scene, vec3::Vec3};
use crate::vec3::Vec3;
// Main RGB image output from rendering the scene. // Main RGB image output from rendering the scene.
pub const MAIN_IMAGE: &str = "@final"; pub const MAIN_IMAGE: &str = "@final";

View File

@ -1,11 +1,12 @@
// 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.
#![allow(clippy::many_single_char_names)] #![allow(clippy::many_single_char_names)]
use crate::aabb::AABB; use crate::{
use crate::hitable::Hit; aabb::AABB,
use crate::hitable::HitRecord; hitable::{Hit, HitRecord},
use crate::material::Material; material::Material,
use crate::ray::Ray; ray::Ray,
use crate::vec3::Vec3; vec3::Vec3,
};
pub struct XYRect<M> pub struct XYRect<M>
where where

View File

@ -1,38 +1,34 @@
use std::fmt; use std::{
use std::ops::AddAssign; fmt,
use std::ops::Range; ops::{AddAssign, Range},
use std::path::Path; path::{Path, PathBuf},
use std::path::PathBuf; str, sync,
use std::str; sync::{
use std::sync; mpsc::{sync_channel, Receiver, SyncSender},
use std::sync::mpsc::sync_channel; Arc, Mutex,
use std::sync::mpsc::Receiver; },
use std::sync::mpsc::SyncSender; thread, time,
use std::sync::Arc; };
use std::sync::Mutex;
use std::thread;
use std::time;
use core_affinity; use core_affinity;
use log::info; use log::{info, trace};
use log::trace;
use num_cpus; use num_cpus;
use rand; use rand::{self, Rng};
use rand::Rng;
use serde_derive::Serialize; use serde_derive::Serialize;
use structopt::StructOpt; use structopt::StructOpt;
use crate::camera::Camera; use crate::{
use crate::hitable::Hit; camera::Camera,
use crate::human; hitable::Hit,
use crate::material::Lambertian; human,
use crate::output; material::Lambertian,
use crate::ray::Ray; output,
use crate::scenes; ray::Ray,
use crate::sphere::Sphere; scenes,
use crate::texture::ConstantTexture; sphere::Sphere,
use crate::texture::EnvMap; texture::{ConstantTexture, EnvMap},
use crate::vec3::Vec3; vec3::Vec3,
};
#[derive(Debug)] #[derive(Debug)]
pub enum Model { pub enum Model {

View File

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

View File

@ -1,18 +1,18 @@
use log::trace; use log::trace;
use rand; use rand::{self, Rng};
use rand::Rng;
use crate::bvh::BVH; use crate::{
use crate::camera::Camera; bvh::BVH,
use crate::hitable::Hit; camera::Camera,
use crate::hitable_list::HitableList; hitable::Hit,
use crate::kdtree::KDTree; hitable_list::HitableList,
use crate::material::Lambertian; kdtree::KDTree,
use crate::renderer::Opt; material::Lambertian,
use crate::renderer::Scene; renderer::{Opt, Scene},
use crate::sphere::Sphere; sphere::Sphere,
use crate::texture::ConstantTexture; texture::ConstantTexture,
use crate::vec3::Vec3; 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,16 @@
use rand; use rand::{self, Rng};
use rand::Rng;
use crate::camera::Camera; use crate::{
use crate::hitable::Hit; camera::Camera,
use crate::hitable_list::HitableList; hitable::Hit,
use crate::kdtree::KDTree; hitable_list::HitableList,
use crate::material::Dielectric; kdtree::KDTree,
use crate::material::Lambertian; material::{Dielectric, Lambertian, Material, Metal},
use crate::material::Material; renderer::{Opt, Scene},
use crate::material::Metal; sphere::Sphere,
use crate::renderer::Opt; texture::{CheckerTexture, ConstantTexture, EnvMap},
use crate::renderer::Scene; vec3::Vec3,
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 { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(13., 2., 3.); let lookfrom = Vec3::new(13., 2., 3.);

View File

@ -1,16 +1,16 @@
use log::trace; use log::trace;
use crate::bvh::BVH; use crate::{
use crate::camera::Camera; bvh::BVH,
use crate::hitable::Hit; camera::Camera,
use crate::material::Lambertian; hitable::Hit,
use crate::material::Metal; material::{Lambertian, Metal},
use crate::moving_sphere::MovingSphere; moving_sphere::MovingSphere,
use crate::renderer::Opt; renderer::{Opt, Scene},
use crate::renderer::Scene; sphere::Sphere,
use crate::sphere::Sphere; texture::ConstantTexture,
use crate::texture::ConstantTexture; 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,20 @@
use std::sync::Arc; use std::sync::Arc;
use crate::camera::Camera; use crate::{
use crate::cuboid::Cuboid; camera::Camera,
use crate::flip_normals::FlipNormals; cuboid::Cuboid,
use crate::hitable::Hit; flip_normals::FlipNormals,
use crate::hitable_list::HitableList; hitable::Hit,
use crate::kdtree::KDTree; hitable_list::HitableList,
use crate::material::DiffuseLight; kdtree::KDTree,
use crate::material::Lambertian; material::{DiffuseLight, Lambertian},
use crate::rect::XYRect; rect::{XYRect, XZRect, YZRect},
use crate::rect::XZRect; renderer::{Opt, Scene},
use crate::rect::YZRect; rotate::RotateY,
use crate::renderer::Opt; texture::ConstantTexture,
use crate::renderer::Scene; translate::Translate,
use crate::rotate::RotateY; vec3::Vec3,
use crate::texture::ConstantTexture; };
use crate::translate::Translate;
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,21 @@
use std::sync::Arc; use std::sync::Arc;
use crate::camera::Camera; use crate::{
use crate::constant_medium::ConstantMedium; camera::Camera,
use crate::cuboid::Cuboid; constant_medium::ConstantMedium,
use crate::flip_normals::FlipNormals; cuboid::Cuboid,
use crate::hitable::Hit; flip_normals::FlipNormals,
use crate::hitable_list::HitableList; hitable::Hit,
use crate::kdtree::KDTree; hitable_list::HitableList,
use crate::material::DiffuseLight; kdtree::KDTree,
use crate::material::Lambertian; material::{DiffuseLight, Lambertian, Material},
use crate::material::Material; rect::{XYRect, XZRect, YZRect},
use crate::rect::XYRect; renderer::{Opt, Scene},
use crate::rect::XZRect; rotate::RotateY,
use crate::rect::YZRect; texture::ConstantTexture,
use crate::renderer::Opt; translate::Translate,
use crate::renderer::Scene; vec3::Vec3,
use crate::rotate::RotateY; };
use crate::texture::ConstantTexture;
use crate::translate::Translate;
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,33 +1,26 @@
use std::sync::Arc; use std::sync::Arc;
use image; use image;
use rand; use rand::{self, Rng};
use rand::Rng;
use crate::camera::Camera; use crate::{
use crate::constant_medium::ConstantMedium; camera::Camera,
use crate::cuboid::Cuboid; constant_medium::ConstantMedium,
use crate::hitable::Hit; cuboid::Cuboid,
use crate::hitable_list::HitableList; hitable::Hit,
use crate::kdtree::KDTree; hitable_list::HitableList,
use crate::material::Dielectric; kdtree::KDTree,
use crate::material::DiffuseLight; material::{Dielectric, DiffuseLight, Lambertian, Material, Metal},
use crate::material::Lambertian; moving_sphere::MovingSphere,
use crate::material::Material; noise::{perlin::Perlin, NoiseType},
use crate::material::Metal; rect::XZRect,
use crate::moving_sphere::MovingSphere; renderer::{Opt, Scene},
use crate::noise::perlin::Perlin; rotate::RotateY,
use crate::noise::NoiseType; sphere::Sphere,
use crate::rect::XZRect; texture::{ConstantTexture, ImageTexture, NoiseTexture},
use crate::renderer::Opt; translate::Translate,
use crate::renderer::Scene; vec3::Vec3,
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 { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(478., 278., -600.); let lookfrom = Vec3::new(478., 278., -600.);

View File

@ -1,24 +1,18 @@
use rand; use rand;
use crate::camera::Camera; use crate::{
use crate::hitable::Hit; camera::Camera,
use crate::hitable_list::HitableList; hitable::Hit,
use crate::kdtree::KDTree; hitable_list::HitableList,
use crate::material::DiffuseLight; kdtree::KDTree,
use crate::material::Lambertian; material::{DiffuseLight, Lambertian},
use crate::noise::perlin::Perlin; noise::{perlin::Perlin, NoiseType},
use crate::noise::NoiseType; rect::{XYRect, XZRect, YZRect},
use crate::rect::XYRect; renderer::{Opt, Scene},
use crate::rect::XZRect; sphere::Sphere,
use crate::rect::YZRect; texture::{ConstantTexture, ImageTexture, Mandelbrot, NoiseTexture},
use crate::renderer::Opt; vec3::Vec3,
use crate::renderer::Scene; };
use crate::sphere::Sphere;
use crate::texture::ConstantTexture;
use crate::texture::ImageTexture;
use crate::texture::Mandelbrot;
use crate::texture::NoiseTexture;
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

@ -2,19 +2,18 @@ use std::sync::Arc;
use rand; use rand;
use crate::camera::Camera; use crate::{
use crate::hitable::Hit; camera::Camera,
use crate::hitable_list::HitableList; hitable::Hit,
use crate::kdtree::KDTree; hitable_list::HitableList,
use crate::material::Lambertian; kdtree::KDTree,
use crate::noise::perlin::Perlin; material::Lambertian,
use crate::noise::NoiseType; noise::{perlin::Perlin, NoiseType},
use crate::renderer::Opt; renderer::{Opt, Scene},
use crate::renderer::Scene; sphere::Sphere,
use crate::sphere::Sphere; texture::{NoiseTexture, Texture},
use crate::texture::NoiseTexture; vec3::Vec3,
use crate::texture::Texture; };
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,18 +1,15 @@
use crate::camera::Camera; use crate::{
use crate::hitable::Hit; camera::Camera,
use crate::hitable_list::HitableList; hitable::Hit,
use crate::material::Dielectric; hitable_list::HitableList,
use crate::material::Lambertian; material::{Dielectric, Lambertian, Metal},
use crate::material::Metal; moving_sphere::MovingSphere,
use crate::moving_sphere::MovingSphere; rect::XYRect,
use crate::rect::XYRect; renderer::{Opt, Scene},
use crate::renderer::Opt; sphere::Sphere,
use crate::renderer::Scene; texture::{CheckerTexture, ConstantTexture, EnvMap},
use crate::sphere::Sphere; vec3::Vec3,
use crate::texture::CheckerTexture; };
use crate::texture::ConstantTexture;
use crate::texture::EnvMap;
use crate::vec3::Vec3;
// Draws many spheres along each positive axis. // Draws many spheres along each positive axis.
// Blue X-positive // Blue X-positive

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,7 @@
#![allow(clippy::many_single_char_names)] #![allow(clippy::many_single_char_names)]
use rand; use rand::{self, Rng};
use rand::Rng;
use crate::texture::Texture; use crate::{texture::Texture, vec3::Vec3};
use crate::vec3::Vec3;
pub struct Mandelbrot { pub struct Mandelbrot {
palette: Vec<Vec3>, palette: Vec<Vec3>,

View File

@ -4,12 +4,10 @@ mod envmap;
mod image; mod image;
mod mandelbrot; mod mandelbrot;
mod noise; mod noise;
pub use crate::texture::checker::CheckerTexture; pub use crate::texture::{
pub use crate::texture::constant::ConstantTexture; checker::CheckerTexture, constant::ConstantTexture, envmap::EnvMap, image::ImageTexture,
pub use crate::texture::envmap::EnvMap; mandelbrot::Mandelbrot, noise::NoiseTexture,
pub use crate::texture::image::ImageTexture; };
pub use crate::texture::mandelbrot::Mandelbrot;
pub use crate::texture::noise::NoiseTexture;
use std::sync::Arc; use std::sync::Arc;

View File

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

View File

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

View File

@ -1,16 +1,12 @@
use std::convert::From; use std::{
use std::fmt; convert::From,
use std::num::ParseFloatError; fmt,
use std::ops::Add; num::ParseFloatError,
use std::ops::Div; ops::{Add, Div, Index, Mul, Neg, Sub},
use std::ops::Index; str,
use std::ops::Mul; };
use std::ops::Neg;
use std::ops::Sub;
use std::str;
use serde_derive::Deserialize; use serde_derive::{Deserialize, Serialize};
use serde_derive::Serialize;
#[derive(Default, Debug, Deserialize, Serialize, PartialEq, Copy, Clone)] #[derive(Default, Debug, Deserialize, Serialize, PartialEq, Copy, Clone)]
pub struct Vec3 { pub struct Vec3 {
@ -207,8 +203,7 @@ impl Sub for Vec3 {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::f32::consts::PI; use std::{f32::consts::PI, str::FromStr};
use std::str::FromStr;
use super::*; use super::*;

View File

@ -6,8 +6,7 @@ use cpuprofiler::PROFILER;
use log::info; use log::info;
use structopt::StructOpt; use structopt::StructOpt;
use renderer::renderer::render; use renderer::renderer::{render, Opt};
use renderer::renderer::Opt;
#[cfg(not(feature = "profile"))] #[cfg(not(feature = "profile"))]
struct MockTimer; struct MockTimer;