Huge speed up by changing how Intersect are shared.

This commit is contained in:
Godzil
2020-03-12 00:11:26 +00:00
parent 0aa949c60b
commit b00bb75189
38 changed files with 116 additions and 153 deletions

View File

@@ -14,9 +14,9 @@ class SmoothTriTest : public SmoothTriangle
{
public:
SmoothTriTest(Point p1, Point p2, Point p3, Vector n1, Vector n2, Vector n3) : SmoothTriangle(p1, p2, p3, n1, n2, n3) {};
Intersect doLocalIntersect(Ray ray)
void doLocalIntersect(Ray ray, Intersect &xs)
{
return this->localIntersect(ray);
this->localIntersect(ray, xs);
};
Tuple doLocalNormalAt(Tuple point, Intersection *hit)
@@ -48,7 +48,7 @@ TEST(SmoothTriangleTest, An_intersection_with_a_smooth_triangle_stores_u_v)
{
Ray r = Ray(Point(-0.2, 0.3, -2), Vector(0, 0, 1));
Intersect xs = tri.doLocalIntersect(r);
Intersect xs; tri.doLocalIntersect(r, xs);
ASSERT_TRUE(double_equal(xs[0].u, 0.45));
ASSERT_TRUE(double_equal(xs[0].v, 0.25));