Auios / Auios.QuadTree

MIT License
37 stars 5 forks source link

Question about updating the tree #2

Closed Dankerprouduct closed 2 years ago

Dankerprouduct commented 2 years ago

How do you update which leaf the item is in in your demo GIFs? Is this done automatically, or do you have to remove and re-add the item to the tree if it is beyond the limits of its current node?

Auios commented 2 years ago

Every frame I destroy and rebuild the entire QuadTree. This is not ideal for a real application but just happened to be how I implemented it for the demo since it was a lightweight simulation. Ideally you'll rebuild it only when you need to or at larger time intervals. But overall - you will rebuild the entire QuadTree, not just a section of it. In the future it would be nice to be able to select a region of the tree and clear it, then only re-insert items that are in that space which you just reset.

Dankerprouduct commented 2 years ago

Thanks!