34

I've been searching high and low (mostly on google) for a fast, efficient, templated (ie. with STL-like properties) octree implementation, without success. I want to use this in the context of a 3D scene graph.

Does such a thing exist, or do people generally roll their own? I'm hoping my friends at stackoverflow will know where to find one.

Robinson
  • 9,666
  • 16
  • 71
  • 115
  • Generally I feel like, if you want the fastest solution, you have to roll your own because the use cases vary wildly, from octrees storing points, octrees storing elements with sizes, loose octrees that more efficiently store elements with sizes, SVOs for voxel data, octrees that use SPFP, octrees that use DPFP, octrees that use integers to exploit more bitwise operations, etc. etc. etc. The list goes on and on and if you found a single generic octree that satisfied all possible criteria very efficiently, it would probably be horrific to use.. like a policy class template... –  Jan 23 '18 at 12:17
  • ... with 16 different policies to specify as template parameters, e.g., at which point just using such a clunky thing might take more time than rolling your own or finding a simple but efficient example of something more narrowly applicable which is closer to your needs and tweaking it as necessary. Generic data structures tend to work well for simpler things like `std::vector` abstracting the idea of a variable-sized dynamic array with little/no performance penalty (only reason I can think of anyone wanting something else [...] –  Jan 23 '18 at 12:18
  • [...] is if they want a different reallocation/reserving policy, like being able to control how much memory the vector reallocates when it's full, or using smaller than 64-bit integers to store size and capacity) -- very fussy stuff. But as you get towards more complex structures like spatial indexes, and especially data structures that tend to come in a wide variety of shapes and sizes based on the domain in which they're used, it becomes pretty unwieldy to try to search for general-purpose thing that's perfect, since at that point "general-purpose" and "made-for-my-purpose" are incompatible. –  Jan 23 '18 at 12:22

3 Answers3

15
Janus Troelsen
  • 20,267
  • 14
  • 135
  • 196
10

Also recently released: http://www.openvdb.org/

A volume hierarchy format by Dreamworks.

Jeroen Baert
  • 1,273
  • 2
  • 12
  • 28
8

Check this one out: http://svn.pointclouds.org/pcl/trunk/octree/

Updated link: https://github.com/PointCloudLibrary/pcl/tree/master/octree

scribbleink
  • 355
  • 2
  • 7
Lou Franco
  • 87,846
  • 14
  • 132
  • 192