Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ray-mesh intersection or AABB tree implementation in C++ with little overhead?

Can you recommend me...

  • either a proven lightweight C / C++ implementation of an AABB tree?
  • or, alternatively, another efficient data-structure, plus a lightweight C / C++ implementation, to solve the problem of intersecting a large number of rays with a large number of triangles?

"Large number" means several 100k for both rays and triangles.

I am aware that AABB trees are part of the CGAL library and probably of game physics libraries like Bullet. However, I don't want the overhead of an enormous additional library in my project. Ideally, I'd like to use a small float-type templated header-only implementation. I would also go for something with a bunch of CPP files, as long as it integrated easily in my project. Dependency on boost is ok.

Yes, I have googled, but without success.

I should mention that my application context is mesh processing, and not rendering. In a nutshell, I'm transferring the topology of a reference mesh to the geometry of a mesh from a 3D scan. I'm shooting rays from vertices and along the normals of the reference mesh towards the 3D scan, and I need to recover the intersection of these rays with the scan.

Edit

Several answers / comments pointed to nearest-neighbor data structures. I have created a small illustration regarding the problems that arise when ray-mesh intersections are approached with nearest neighbor methods. Nearest neighbors methods can be used as heuristics that work in many cases, but I'm not convinced that they actually solve the problem systematically, like AABB trees do.

enter image description here

like image 898
DCS Avatar asked Feb 08 '13 07:02

DCS


1 Answers

While this code is a bit old and using the 3DS Max SDK, it gives a fairly good tree system for object-object collision deformations in C++. Can't tell at a glance if it is Quad-tree, AABB-tree, or even OBB-tree (comments are a bit skimpy too).

http://www.max3dstuff.com/max4/objectDeform/help.html

It will require translation from Max to your own system but it may be worth the effort.

like image 99
Robert Templeton Avatar answered Oct 20 '22 11:10

Robert Templeton