dilevin / computer-graphics-bounding-volume-hierarchy

Computer Graphics Assignment about Bounding Volume Hierarchies
6 stars 5 forks source link

Method for splitting objects into subtrees in AABBTree::AABBTree #68

Open AditMeh opened 9 months ago

AditMeh commented 9 months ago

Assignment readme says:

"Construct an axis-aligned bounding box tree given a list of objects. Use the midpoint along the longest axis of the box containing the given objects to determine the left-right split."

Does this mean that we first compute the midpoint of the axis, and then assign objects to left or right subtrees based on whether they are greater than or equal to the midpoint? I found that this method gets stuck in cases where the midpoint is less than the center all of the objects, and so all objects go into the right subtree. Then the bounding box for the right subtree is the same as the parent, so the situation continues infinitely (and I hit recursion limit). Am I doing something wrong or misunderstood how to implement this method?

The method in page 304 works very well for me, as it does not get stuck in these situations since it splits the objects into two halves.

Zhecheng-Wang commented 9 months ago

Yes, your interpretation is correct. This is a good suggestion, sometimes the centers of mass of both objects can be on the same side.

I would suggest you follow the method on page 304 too. For those wondering the same, it is sorting object centers along the longest axis.

AditMeh commented 9 months ago

@Zhecheng-Wang If I use the method on page 304, I am doing something differently from what is outlined in the README.

How should I indicate this to the TA marking my assignment so I don't lose marks for doing something different?

Zhecheng-Wang commented 9 months ago

I am the TA marking BVH so don't worry lol I will bring this up with the prof so we can change README later.

Zhecheng-Wang commented 9 months ago

On second thought: how did you compute the center of the object? If you are using the triangle bounding box to compute the center, I think by construction there will always be a left node and a right node on both sides of the midpoint.

nicholas3d2 commented 8 months ago

Hi, I did something like suggested in https://github.com/dilevin/computer-graphics-bounding-volume-hierarchy/issues/44 and all the programs run fine, is that ok?

Zhecheng-Wang commented 8 months ago

Hi, I did something like suggested in #44 and all the programs run fine, is that ok?

Using either #44 or #68 is fine.