Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to build Bounding Volume Hierarchy? #36

Open
RdlP opened this issue Oct 1, 2015 · 1 comment
Open

How to build Bounding Volume Hierarchy? #36

RdlP opened this issue Oct 1, 2015 · 1 comment

Comments

@RdlP
Copy link

RdlP commented Oct 1, 2015

I understand BVH and the code to create the hierarchy and I understand the code to insert nodes in the BVH but I don't understand how to insert bodies in the hierarchy. I mean I have a list with many bodies and I want to create the BVH.

To insert bodies is it enought with the follow?

BVHNode root;
for (int i=0; i<bodies.length; i++){
    RigidBody currentBody = bodies.get(i);
    root.insert(currentBody, volume);
}

The question is, to create the BVH is it engouth with create a node and iterate over all bodies and insert the bodies in the created BVH node (root)?
Note: I have used a java syntax.

@YukinoHayakawa
Copy link

Yes if you just want a working BVH, no if you have many objects and chase for better performance.
It's a sad truth that BVH is never used in demos come along with cyclone codes. I rolled my own BVH class and haven't used it neither. Also note that there are some errors in its implementation which may lead to missing of contacts (see other issues).
For the insertion method which is used in the book, inserting objects one by one is sufficient to build a hierarchy. But for the greedy character (put object to the best position for it but not for the whole tree) of insertion method, using the final hierarchy is not guaranteed to be more effective than using brute-force detection between every possible pair, especially when objects are distributed and inserted in a random manner.
If you want to take performance into consideration, you may want to do some research on BVH optimization (may be some quick algorithms to adjust BVH structure dynamically) or other building methods such as SAH-based methods (performed in a top-bottom manner, may not be useful if you use a dynamic BVH, which is very common in physics simulations).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants