Click here to Skip to main content
15,886,795 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I'm given thousands of triangles (3D vertices & of different sizes) and a particular bounding box size...besides doing AABB-triangle intersection test for "each" triangle (which is very slow when it comes to millions of triangles), is there any quicker way to accomplish this as in minimising the number of intersection test to be done...? Really need your help for this as I just left out this piece of puzzle to solve my project...I've the complete code for the AABB-triangle intersection test....just that I want to minimise the number of test to be done...I'm not using VTK, OpenGL, TetGen, CGAL, or any other complex libraries....just basic C++ software which is CodeBlocks.
Posted
Comments
Sergey Alexandrovich Kryukov 4-Feb-15 21:18pm    
To figure out if there is any quicker way, it would be good to know what is your "slower" way. Isn't it logical?
—SA
Amos Chew 4-Feb-15 21:32pm    
slower way as in the standard brute force of testing every single triangle for intersection with bounding box....a quicker way as in is it possible to select the nearest triangle to the bounding box n perform the intersection test...
Amos Chew 4-Feb-15 21:36pm    
i've tried storing the triangles into an octree and then test for intersection between a particular triangle and a query box....BUT that is only for triangles that are smaller than the query box....what IF the triangle size is larger than the query box (does not contain any of the vertices but still intersects with the triangle)...?
ZurdoDev 4-Feb-15 22:30pm    
Sounds more like a math question than a code question.
Fredrik Bornander 5-Feb-15 5:07am    
Are you applying SAT before you do the line-line intersection checks?

1 solution

I guess not. You will have to test all your triangles separately, except you triangles have something in common which would allow to simplify the intersection test by performing one of its steps for multiple triangles at the same time.

As to your comments: "... is [it] possible to select the nearest triangle to the bounding box and perform the intersection test?". How would you define nearest? If you define it as: distance between the triangles center and the bounding box's center: No, that doesn't help you. You can easily construct two triangles and have the nearer one not intersect and the further one do well intersect. If you defined the distance as: The closest distance of any point of the triangle surface to any point inside the bounding box, then you are basically performing the same test as for your intersection test.

So, in a nutshell, no, there is no shortcut. But you could work on the speed of your intersection test, which you haven't shown here. If you are dealing with millions of triangles, most of which fall wide outside the range of the bounding box, your intersection test should be structured, such that these trivial cases are handled in minimum time. For example, you could place the test that are aligned along the coordinate grid up first, so that non-overlaps appear within the first couple of test steps.
 
Share this answer
 
Comments
Amos Chew 5-Feb-15 10:13am    
i guessed that's the only way then....thank you so much anyways...^^

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900