|
Post by simianarmy on Oct 21, 2019 1:17:35 GMT
Hello! I'm nearing the end of the book and coming up with a strange failing test result.
The test is
“Scenario: A ray hits a CSG object Given s1 ← sphere() And s2 ← sphere() And set_transform(s2, translation(0, 0, 0.5)) And c ← csg("union", s1, s2) And r ← ray(point(0, 0, -5), vector(0, 0, 1)) When xs ← local_intersect(c, r) Then xs.count = 2 And xs[0].t = 4 And xs[0].object = s1 And xs[1].t = 6.5 And xs[1].object = s2”
When I run it on my implementation, it fails at the xs[1].t check because 6 != 6.5
I checked & rechecked everything but can't figure out why t would be 6 for the 2nd object's intersection...
Pretty sure my Sphere intersection code is correct, and all prior tests pass.
|
|
|
Post by Jamis on Oct 21, 2019 14:26:24 GMT
Hello simianarmy -- can you share more of your code? It looks like either the translation for sphere s2 isn't working, or that your CSG object isn't respecting the transformations of its children.
|
|
|
Post by simianarmy on Oct 23, 2019 1:41:12 GMT
Thanks - you were right! My Csg's localIntersect function was calling localIntersect instead of intersect() on the children! Tests pass now
|
|
|
Post by Jamis on Oct 28, 2019 13:53:53 GMT
Great! I'm glad you got it figured out.
|
|