equal
deleted
inserted
replaced
93 } |
93 } |
94 |
94 |
95 bool Sphere::intersect(const Ray &ray, Float &dist) const |
95 bool Sphere::intersect(const Ray &ray, Float &dist) const |
96 { |
96 { |
97 Vector3 V = ray.o - center; |
97 Vector3 V = ray.o - center; |
98 register Float d = -dot(V, ray.dir); |
98 register Float d = dot(V, ray.dir); |
99 register Float Det = d * d - (dot(V,V) - sqr_radius); |
99 register Float Det = d * d - (dot(V,V) - sqr_radius); |
100 if (Det > 0) { |
100 if (Det > 0) { |
101 d -= sqrtf(Det); |
101 d = -d - sqrtf(Det); |
102 if (d > 0 && d < dist) |
102 if (d > 0 && d < dist) |
103 { |
103 { |
104 dist = d; |
104 dist = d; |
105 return true; |
105 return true; |
106 } |
106 } |