diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/calculus.rs | 2 | ||||
-rw-r--r-- | src/object.rs | 4 | ||||
-rw-r--r-- | src/renderer.rs | 6 |
3 files changed, 6 insertions, 6 deletions
diff --git a/src/calculus.rs b/src/calculus.rs index 67138d1..c9b0574 100644 --- a/src/calculus.rs +++ b/src/calculus.rs @@ -1,5 +1,5 @@ pub mod calculus { - #[derive(Copy, Clone)] + #[derive(Copy, Clone, Debug)] pub struct Vec3 { pub x: f32, pub y: f32, diff --git a/src/object.rs b/src/object.rs index ff965f0..0da9148 100644 --- a/src/object.rs +++ b/src/object.rs @@ -37,7 +37,7 @@ pub struct Sphere { impl Sphere { pub fn new(center: Vec3, radius: f32) -> Self { - let r = f32::max(0.0, radius); + let radius = f32::max(0.0, radius); Self { center, radius } } } @@ -65,7 +65,7 @@ impl Hittable for Sphere { rec.t = root; rec.position = r.at(rec.t); - let outward_normal = rec.normal + let outward_normal = rec.position .sub(&self.center) .scalar_mul(1.0 / self.radius); rec.set_face_normal(r, outward_normal); diff --git a/src/renderer.rs b/src/renderer.rs index 2fb76d2..4936d9e 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -43,9 +43,9 @@ pub fn render(display_buffer: &mut DisplayBuffer) { Sphere::new(Point3::new(0.0, 0.0, -1.0), 0.5) ); - // world.push( - // Sphere::new(Point3::new(0.0, -100.5, -1.0), 100.0) - // ); + world.push( + Sphere::new(Point3::new(0.0, -100.5, -1.0), 100.0) + ); (0..IMG_HEIGHT).for_each(|j| { |