There is not a single answer, but large worlds are often divided in space, using something along the lines of quadtree or kd-tree , which gives the search time to find the nearest neighbors below linear time (fractional power or in the worst case O (N ^ (2 / 3)) for a 3D game). These methods are often called BSPs for binary partitioning.
As for collision detection, each object also has a limited volume grid associated with it (many polygons forming a convex hull). These highly simplified grids (sometimes only a cube) are not drawn, but are used to detect collisions. The most primitive method is to create a plane perpendicular to the line connecting the midpoints of each object with a plane crossing the line at the midpoint of the line. If the object bounding volume has points on both sides of this plane, this is a collision (you only need to check one of the two bounding volumes on the plane). Another method is the advanced GJK algorithm. If you want the tutorial to go through, check out OpenGL NeHe Productions Lesson # 30 .
Incidentally, bounding volumes can also be used for other optimizations, such as so-called occlusal queries. This is the process of determining which objects are behind other objects (occluders), and therefore they do not need to be processed / visualized. Bounding volumes can also be used to reject a truncated cone, which is the process of determining which objects are outside the prospective scope of the view (too close, too far, or outside the field of view) and therefore need not be visualized.
As Kilotan noted, using a bounding volume can generate false positives when occlusion is detected and simply does not work at all for some types of objects, such as toroids (for example, looking at a hole in a donut). The presence of objects like these is correctly closed, this is a whole different thread when choosing a portal.
charstar Dec 25 '09 at 6:51 2009-12-25 06:51
source share