Skip to main content
2 of 2
added 267 characters in body
aaaaaaaaaaaa
  • 8.9k
  • 1
  • 23
  • 35

It sounds like you need an octree, binary trees really only work for sorting stuff in one dimension. Note that you still will have to travel down multiple branches to find all objects within an arbitrary zone, no data structure can prevent that.

Of course, it would be possible to store items in a standard search tree according to their position on a 3D Hilbert curve, that would be kinda the same thing as an octree, just more convoluted to implement.

aaaaaaaaaaaa
  • 8.9k
  • 1
  • 23
  • 35