From 5e61a588a59008705846326956ff0b1f8ee43b16 Mon Sep 17 00:00:00 2001 From: Rosyid Haryadi Date: Sat, 1 Mar 2025 18:41:07 +0700 Subject: fix normal --- src/object.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/object.rs') 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); -- cgit v1.2.3-70-g09d2