For objects of more than 40.000 faces picking a face by iterating trough every face/triangle and checking if it intersects with the camera ray should slow down the program by a lot but it still works instantly. Looking at the source code didn't help much. What trick does blender use to pick the face you are pointing at?
1 Answers
Blender uses BVH tree search, it is quite standard for ray casting.
A bounding volume hierarchy (BVH) is a tree structure on a set of geometric objects. All geometric objects, that form the leaf nodes of the tree, are wrapped in bounding volumes. These nodes are then grouped as small sets and enclosed within larger bounding volumes. These, in turn, are also grouped and enclosed within other larger bounding volumes in a recursive fashion, eventually resulting in a tree structure with a single bounding volume at the top of the tree.
BVHs are often used in ray tracing to eliminate potential intersection candidates within a scene by omitting geometric objects located in bounding volumes which are not intersected by the current ray.
Moreover, BVH is exposed to python API:
https://docs.blender.org/api/current/mathutils.bvhtree.html
Also, I suppose selection should be provided by OpenGL
- 35,244
- 2
- 37
- 89