mourner / rbush

RBush — a high-performance JavaScript R-tree-based 2D spatial index for points and rectangles

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

moving items within the tree?

seiyria opened this issue · comments

hey! just found your library and I'm trying to figure out if it meets my needs. I have a game with moving creatures and I'm looking to optimize spatial searches, which this looks great at. One thing, though, is that creatures move around a lot, and I'm not sure how performant it would be to constantly remove/add the entry back into the tree. It could be theoretically 1000 times per second.

If it would still perform ok I'd be ok using it, but I'm not sure if there's a fast way to move something in an r-tree as opposed to adding/removing it.

Try adding/removing — it may be fast enough for your needs. But if not, there's a proposal for a new API for this kind of things here: #28 (will close this issue as a duplicate)

Sounds good, thanks for pointing me there. Some good reading. Like others, I'm not sure how good it will be or if it could be better, but anything beats my current approach. I'll have a try at implementing it as is.