Bounding Volume performance test: AABB vs OBB vs sphere

Source: Internet
Author: User

Any real-time 3D InteractionProgramIf there is no collision detection, it is of no value or even unusable. The most common Collision Detection Technology in the game is bounding volume collision detection. For games running at 60pfs, it takes only about 0.0167s to process each frame of data. For different games, collision detection takes about 10-seconds ~ 30% of the time, that is, all collision detection must be between 0.002 and ~ Within s, it was a huge challenge. Therefore, any box should meet the following requirements:

1. Fast Collision Detection
2. Closely covering the surrounded objects
3. The box should be very easy to calculate
4. Easy coordinate rotation and Transformation
5. low memory usage

The most common boxes are sphere, AABB, and OBB, and a special frustum. Sphere can meet the requirements of 1, 3, and 4, but usually contains too much useless space, which may easily lead to incorrect collision results. AABB should be a solution between sphere and OBB while taking into account both efficiency and Space coverage. OBB is the most accurate among the three, but the detection cost is also the highest.

Which kind of box is used in the end is a very painful process. We need to make a trade-off between efficiency and accuracy. The basic collision detection function was just completed a few days ago. The following are some of my test data, which can be used as a reference to a certain extent. Pure C #CodeImplementation, without any GPU acceleration, a single thread runs on q6600.

Sphere-sphere: 1 million tests, about 16000 collisions, which took 0.016 S.

AABB-AABB: 1 million tests, 1000 collisions, 0.014 S elapsed.

OBB-OBB: using traditional separate axisAlgorithm, 1 million tests, 0.3 million collisions, about seconds. In the case of no collision, the detection can be completed almost in the first six axes, that is, about 0.5 million (50%) tests are completed before the seventh axis is detected.

Vertical-agliened OBB-Vertical-agliened OBB: special version of normal OBB, which can only be rotated around the Y axis. 0.3 million tests and 0.08 collisions took s, almost twice as much as normal OBB.

Finally, frustum-AABB: using the algorithm in <optimized view frustum culling algorithms for Bounding Boxes>, 60 thousand tests and 0.096 collisions took S. At present, the method for calculating N-vertex and p-vertex is the bottleneck, and it takes about 0.016s to calculate these two points. Compared with boundingfrustum. intersects in xNa, the same test takes about seconds.
(The above are tests on random data. Therefore, the actual number of collisions between different boxes is not comparable, nor does it represent the accuracy of different types of boxes)

Obviously, AABB is the most cost-effective. Although OBB has high precision, it is not cost-effective compared with its computing cost. We can consider using multiple AABB to approximate OBB, or use a relatively low-cost vertical-agliened OBB. Sphere looks simple, Computing involves the open party (although math. SQRT will be directly compiled as the fsqrt command), so AABB is still not fast (only 6 logical comparison commands are required ).

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.