Is there a space-partitioning data structure?

Take a look at the TOctree<> class.