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

@@ -18,8 +18,8 @@
class CSGTest : public CSG
{
public:
Intersect doLocalIntersect(Ray r) {
return this->localIntersect(r);
void doLocalIntersect(Ray r, Intersect &xs) {
return this->localIntersect(r, xs);
};
Tuple doLocalNormalAt(Tuple point, Intersection *hit = nullptr) {
return this->localNormalAt(point, hit);
@@ -202,7 +202,7 @@ TEST(CSGTest, A_ray_misses_a_csg_object)
CSGTest c = CSGTest(CSG::UNION, &s1, &s2);
Ray r = Ray(Point(0, 2, -5), Vector(0, 0, 1));
Intersect xs = c.doLocalIntersect(r);
Intersect xs; c.doLocalIntersect(r, xs);
ASSERT_EQ(xs.count(), 0);
}
@@ -217,7 +217,7 @@ TEST(CSGTest, A_ray_hits_a_csg_object)
CSGTest c = CSGTest(CSG::UNION, &s1, &s2);
Ray r = Ray(Point(0, 0, -5), Vector(0, 0, 1));
Intersect xs = c.doLocalIntersect(r);
Intersect xs; c.doLocalIntersect(r, xs);
ASSERT_EQ(xs.count(), 2);
ASSERT_TRUE(double_equal(xs[0].t, 4));