Sign in to follow this  
samp20

Best Spatial Indexing Algorithm

Recommended Posts

samp20    102
Hi,
I'm currently working on a regions (cuboid) plugin for Bukkit (minecraft server API). What I'd like to know is what the best Spatial indexing algorithm would be. There's two main options that I can think of:
[list][*]R-Tree. This is probably the most complicated to implement. I would probably use Linear splitting when nodes get too full, however I'm struggling to understand how the algorithm works. If anyone could provide some pseudocode that would be great.[*]Spatial Hashing. This seems like a more viable option. Minecraft is divided into 16x16x128 chunks, and so I can use a HashMultimap to store which regions are within which chunk. This seems fine for small regions, however would probably start to use a lot of memory when regions span multiple chunks.[/list]
Maybe there's an option to use both of these methods. Most likely there will be very few large regions, however many small ones. Heck I could probably get away with storing the large regions in an array, and iterate through them. Probably a better idea though would be to use something like this: [url="http://khelekore.org/prtree/"]http://khelekore.org/prtree/[/url]. Although it only works in 2 dimensions I feel that should be enough for the larger regions since it's unlikely for there to be many large regions stacked on top of eachother.

Writing this post has already helped me to come to a decision, but if anybody can give me some better guidance I'd be very grateful.

Thanks,
Sam

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this