summaryrefslogtreecommitdiff
path: root/src/object.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/object.rs')
-rw-r--r--src/object.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/object.rs b/src/object.rs
index d9e2cc4..2192703 100644
--- a/src/object.rs
+++ b/src/object.rs
@@ -11,6 +11,7 @@ pub struct HitRecord {
pub front_face: bool,
pub material: MaterialType,
pub color: Color,
+ pub fuzz: f32,
}
impl Default for HitRecord {
@@ -22,6 +23,7 @@ impl Default for HitRecord {
front_face: false,
material: MaterialType::Diffuse,
color:Color::new(0.0, 0.0, 0.0),
+ fuzz: 1.0,
}
}
}
@@ -41,13 +43,14 @@ pub struct Sphere {
center: Point3,
radius: f32,
material: MaterialType,
- color: Color
+ color: Color,
+ fuzz: f32,
}
impl Sphere {
- pub fn new(center: Vec3, radius: f32, material: MaterialType, color: Color) -> Self {
+ pub fn new(center: Vec3, radius: f32, material: MaterialType, color: Color, fuzz: f32) -> Self {
let radius = f32::max(0.0, radius);
- Self { center, radius, material, color }
+ Self { center, radius, material, color, fuzz }
}
}
@@ -80,6 +83,7 @@ impl Hittable for Sphere {
rec.set_face_normal(r, outward_normal);
rec.material = self.material.clone();
rec.color = self.color.clone();
+ rec.fuzz = self.fuzz;
true
}