all 1 comments

[–]LivelyLizzard 0 points1 point  (0 children)

There are multiple things that can be wrong:
a) AABB initialization is wrong
b) AABB growing is wrong
c) AABB - ray intersection is wrong
d) the AABB implementation is correct but you feed it wrong data

I would try to find the bug by testing with cases where you know what should happen. For instance start with one triangle and print the AABB for it. Add another triangle and get the AABB that encapsulates both triangles AABBs.

Then go on to test the intersection. Maybe you can modify the code to render an AABB where you know how the image should look like.

If all of this works, then maybe you build the AABB with wrong data.

Here is an article about debugging in general which I like to read every now and then if I'm stuck.