Fix: Nearest root within tolerance
I found the fucker. The rays were bouncing incorrectly because I wasn't holding a value the way I should have. I thought I was being clever and using Rusts's ability to redeclare variables. But, no. That value is meant to be modified when the first conditional passes. The outcomes are 3 possibilities, where one is an early return. Shadowing the value that way meant I was giving back garbage. I don't know why this didn't have any obviously bad effects prior to making the dielectric material.
This commit is contained in:
@@ -27,9 +27,9 @@ impl Hittable for Sphere {
|
||||
let sqrtd = discriminant.sqrt();
|
||||
|
||||
// nearest root that lies within tolerance
|
||||
let root = (-half_b - sqrtd) / a;
|
||||
let mut root = (-half_b - sqrtd) / a;
|
||||
if root < t_min || root > t_max {
|
||||
let root = (-half_b + sqrtd) / a;
|
||||
root = (-half_b + sqrtd) / a;
|
||||
if root < t_min || root > t_max {
|
||||
return None;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user