Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Efficient Position Search #66

Open
sunjay opened this issue Nov 4, 2018 · 0 comments
Open

Efficient Position Search #66

sunjay opened this issue Nov 4, 2018 · 0 comments

Comments

@sunjay
Copy link
Owner

sunjay commented Nov 4, 2018

This is probably only necessary to do once we start getting a lot of entities.

Using a VecStorage for storing positions is pretty inefficient to search. Would be better if we implemented a kd tree 2D grid of points within each cell. Basically a bucket hash map implementation at that point.

TODO: Look into R trees

https://stoeoef.gitbooks.io/spade-user-manual/content/

Some considerations:

  • All nodes can be stored in a Vec and can refer to siblings using indices
  • Needs to support the storage API: https://docs.rs/specs/0.14.0/src/specs/storage/storages.rs.html#49
    • add, remove, get, get_mut
    • To implement get_mut, we can keep a queue of items that may need to be reinserted and then do that at the start of other operations
  • Must allow duplicates in case multiple entities are at the same position (could use a Small Vec at each point in the grid to optimize cache usage)
  • Use the num crate to be generic over the element type
  • Insert anything that can be converted into (T, T)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant