diff options
author | Rosyid Haryadi <rosyid_haryadi@protonmail.com> | 2025-03-01 18:41:07 +0700 |
---|---|---|
committer | Rosyid Haryadi <rosyid_haryadi@protonmail.com> | 2025-03-01 18:41:07 +0700 |
commit | 5e61a588a59008705846326956ff0b1f8ee43b16 (patch) | |
tree | 7436a2140247465c9559853c99ce43e030a05b81 /src/object.rs | |
parent | 084875ac8e9aa12cf6cc1892def9e4bc5fd4cdda (diff) |
fix normal
Diffstat (limited to 'src/object.rs')
-rw-r--r-- | src/object.rs | 4 |
1 files changed, 2 insertions, 2 deletions
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); |