I had thought I could do it with octrees but I can't really see them working. The first issue is that I can't just have 1 octree for the whole world, because I have to deal with multiplayer and having multiple players that could potentially be very very far away from each other. If I instead do 1 octree per region, that leads to more problems: if an entity is in region 1 and 2, and I query a position inside region 2 which the entity overlaps, region 2 won't have an entry for it.
I could possibly duplicate the entries so that both octrees have the same entry and it wouldn't matter which you queried, but then I run into another problem: I can't add entries to a region which isn't loaded yet.
Another solution might be to query all the neighbor regions' octrees if nothing is found within the octree of the original region. That means even more time taken to find an entity and either require that entities be no larger than a single region or I'd have to keep expanding the search outwards. Overall not a terrible solution, but not one I'm particularly happy with.
Anyone else have some better solutions? Whatever structure is used needs to be buildable in realtime, these entities are dynamically placed.
Edited by Telanor, 16 January 2014 - 08:38 PM.