[FEAT] Add a new intersections objects
This commit is contained in:
@@ -63,11 +63,11 @@ TEST_CASE("[05][Rays] a ray intersects a sphere at two points", "[Sphere]")
|
||||
{
|
||||
Ray r(Tuple::Point(0, 0, -5), Tuple::Vector(0, 0, 1));
|
||||
Sphere s;
|
||||
auto xs = r.intersect(s);
|
||||
Intersections xs = r.intersect(s);
|
||||
|
||||
REQUIRE(xs.size() == 2);
|
||||
REQUIRE(xs[0] == 4.0);
|
||||
REQUIRE(xs[1] == 6.0);
|
||||
REQUIRE(xs.count() == 2);
|
||||
REQUIRE(xs[0].distance_t() == 4.0);
|
||||
REQUIRE(xs[1].distance_t() == 6.0);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@@ -76,11 +76,11 @@ TEST_CASE("[05][Rays] a ray intersects a sphere at a tangent", "[Sphere]")
|
||||
{
|
||||
Ray r(Tuple::Point(0, 1, -5), Tuple::Vector(0, 0, 1));
|
||||
Sphere s;
|
||||
auto xs = r.intersect(s);
|
||||
Intersections xs = r.intersect(s);
|
||||
|
||||
REQUIRE(xs.size() == 2);
|
||||
REQUIRE(xs[0] == 5.0);
|
||||
REQUIRE(xs[1] == 5.0);
|
||||
REQUIRE(xs.count() == 2);
|
||||
REQUIRE(xs[0].distance_t() == 5.0);
|
||||
REQUIRE(xs[1].distance_t() == 5.0);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@@ -89,9 +89,9 @@ TEST_CASE("[05][Rays] a ray misses a sphere", "[Sphere]")
|
||||
{
|
||||
Ray r(Tuple::Point(0, 2, -5), Tuple::Vector(0, 0, 1));
|
||||
Sphere s;
|
||||
auto xs = r.intersect(s);
|
||||
Intersections xs = r.intersect(s);
|
||||
|
||||
REQUIRE(xs.size() == 0);
|
||||
REQUIRE(xs.count() == 0);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@@ -100,11 +100,11 @@ TEST_CASE("[05][Rays] a originates inside a sphere", "[Sphere]")
|
||||
{
|
||||
Ray r(Tuple::Point(0, 0, 0), Tuple::Vector(0, 0, 1));
|
||||
Sphere s;
|
||||
auto xs = r.intersect(s);
|
||||
Intersections xs = r.intersect(s);
|
||||
|
||||
REQUIRE(xs.size() == 2);
|
||||
REQUIRE(xs[0] == -1.0);
|
||||
REQUIRE(xs[1] == 1.0);
|
||||
REQUIRE(xs.count() == 2);
|
||||
REQUIRE(xs[0].distance_t() == -1.0);
|
||||
REQUIRE(xs[1].distance_t() == 1.0);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@@ -113,11 +113,11 @@ TEST_CASE("[05][Rays] a sphere is behind a ray", "[Sphere]")
|
||||
{
|
||||
Ray r(Tuple::Point(0, 0, 5), Tuple::Vector(0, 0, 1));
|
||||
Sphere s;
|
||||
auto xs = r.intersect(s);
|
||||
Intersections xs = r.intersect(s);
|
||||
|
||||
REQUIRE(xs.size() == 2);
|
||||
REQUIRE(xs[0] == -6.0);
|
||||
REQUIRE(xs[1] == -4.0);
|
||||
REQUIRE(xs.count() == 2);
|
||||
REQUIRE(xs[0].distance_t() == -6.0);
|
||||
REQUIRE(xs[1].distance_t() == -4.0);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@@ -143,7 +143,6 @@ TEST_CASE("[05][Rays] An intersection encapsulates t and object", "[Intersection
|
||||
REQUIRE(i.object() == s);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TEST_CASE("[05][Rays] Aggregating intersections", "[Intersections]")
|
||||
@@ -154,7 +153,19 @@ TEST_CASE("[05][Rays] Aggregating intersections", "[Intersections]")
|
||||
Intersections xs = Intersections(i1, i2);
|
||||
|
||||
REQUIRE(xs.count() == 2);
|
||||
REQUIRE(xs[0].t() == 1);
|
||||
REQUIRE(xs[1].t() == 2);
|
||||
REQUIRE(xs[0].distance_t() == 1);
|
||||
REQUIRE(xs[1].distance_t() == 2);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
TEST_CASE("[05][Rays] Intersect set the object on the intersection", "[Intersections]")
|
||||
{
|
||||
Ray r(Tuple::Point(0, 0, 5), Tuple::Vector(0, 0, 1));
|
||||
Sphere s;
|
||||
Intersections xs = r.intersect(s);
|
||||
|
||||
REQUIRE(xs.count() == 2);
|
||||
REQUIRE(xs[0].object() == s);
|
||||
REQUIRE(xs[1].object() == s);
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user