[FIX] Fix an issue on cylinder
This commit is contained in:
@@ -95,14 +95,15 @@ Intersections Cylinder::local_intersect(const Ray &a_ray)
|
||||
|
||||
Tuple Cylinder::local_normal_at(const Tuple &a_local_point) const
|
||||
{
|
||||
|
||||
double the_distance;
|
||||
// Compute the sqare of the distance from the y axis
|
||||
// Compute the square of the distance from the y axis
|
||||
the_distance = std::pow(a_local_point.x(), 2) + std::pow(a_local_point.z(), 2);
|
||||
if ((the_distance < 1) && (a_local_point.y() >= m_maximum - kEpsilon))
|
||||
{
|
||||
return Tuple::Vector(0, 1, 0);
|
||||
}
|
||||
else if ((the_distance < 1) && (a_local_point.y() <= m_maximum + kEpsilon))
|
||||
else if ((the_distance < 1) && (a_local_point.y() <= m_minimum + kEpsilon))
|
||||
{
|
||||
return Tuple::Vector(0, -1, 0);
|
||||
}
|
||||
@@ -172,6 +173,7 @@ bool Cylinder::check_cap(const Ray &a_ray, double a_distance_t)
|
||||
void Cylinder::intersect_caps(const Ray &a_ray, Intersections &an_xs)
|
||||
{
|
||||
double the_distance_t;
|
||||
|
||||
// Caps only matter if the cylinder is closed. and might possibility be intersected the ray.
|
||||
if ((m_closed == false) or (double_equal(a_ray.direction().y(), 0)))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user