Cleanup
This commit is contained in:
@ -2,8 +2,10 @@ use crate::{Point3, Ray, Vec3};
|
||||
use crate::material::{Material};
|
||||
use crate::aabb::Aabb;
|
||||
use std::f64::consts::PI;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub type HittableList = Vec<Box<dyn Hittable + Sync>>;
|
||||
pub type HittableObject = Arc<dyn Hittable + Sync + Send>;
|
||||
pub type HittableList = Vec<HittableObject>;
|
||||
|
||||
//#[derive(Debug, Clone, Copy)]
|
||||
#[derive(Clone, Copy)]
|
||||
@ -14,7 +16,7 @@ pub struct HitRecord<'material> {
|
||||
pub u: f64,
|
||||
pub v: f64,
|
||||
pub front_face: bool,
|
||||
pub material: &'material Material
|
||||
pub material: &'material Arc<Material>
|
||||
}
|
||||
|
||||
pub trait Hittable {
|
||||
@ -26,10 +28,10 @@ pub trait Hittable {
|
||||
pub struct Sphere {
|
||||
pub center: Point3,
|
||||
pub radius: f64,
|
||||
pub material: Material
|
||||
pub material: Arc<Material>
|
||||
}
|
||||
impl Sphere {
|
||||
pub fn new(center: Point3, radius: f64, material: Material) -> Sphere {
|
||||
pub fn new(center: Point3, radius: f64, material: Arc<Material>) -> Sphere {
|
||||
Sphere { center, radius, material }
|
||||
}
|
||||
pub fn uv(point: &Point3) -> (f64, f64) {
|
||||
@ -51,7 +53,7 @@ impl Default for Sphere {
|
||||
Sphere {
|
||||
center: Point3::default(),
|
||||
radius: 0.0,
|
||||
material: Material::default()
|
||||
material: Arc::new(Material::default())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -100,7 +102,7 @@ pub struct MovableSphere {
|
||||
pub center0: Point3,
|
||||
pub center1: Point3,
|
||||
pub radius: f64,
|
||||
pub material: Material,
|
||||
pub material: Arc<Material>,
|
||||
pub time0: f64,
|
||||
pub time1: f64,
|
||||
}
|
||||
@ -109,7 +111,7 @@ impl MovableSphere {
|
||||
center0: Point3,
|
||||
center1: Point3,
|
||||
radius: f64,
|
||||
material: Material,
|
||||
material: Arc<Material>,
|
||||
time0: f64,
|
||||
time1: f64) -> Self {
|
||||
MovableSphere { center0, center1, radius, material, time0, time1 }
|
||||
@ -124,7 +126,7 @@ impl Default for MovableSphere {
|
||||
center0: Point3::default(),
|
||||
center1: Point3::default(),
|
||||
radius: 0.0,
|
||||
material: Material::default(),
|
||||
material: Arc::new(Material::default()),
|
||||
time0: 0.0,
|
||||
time1: 0.0
|
||||
}
|
||||
|
Reference in New Issue
Block a user