Added ray-plane intersection.

This commit is contained in:
2016-12-26 17:43:57 -04:00
parent 2d437f07bc
commit dd4faafc15
6 changed files with 191 additions and 39 deletions

View File

@@ -30,7 +30,8 @@ bool Sphere::intersect(Ray & r, float & t, vec3 & n) const {
t = (-b - sqrt(d)) / (2 * a);
i = vec3(r.m_origin + (t * r.m_direction));
n = normalize(vec3((i - m_center) / m_radius));
}
return t >= 0.0f;
return d >= 0.0f;
} else
return false;
}