Skip to main content
gamedev.net
🔒 Locked

Quick (Easy) QuadTree question

Started by Balaam 0 replies 600+ views
Original Post
Balaam
Balaam
Let's say I have a one layer quadtree Root[child-1, child-2, child-3, child-4] So a square divided into four equals chunks. Now let's say I want to add an item to my quad tree - let's say it's big and exists partially in child-1 and child-2. Is it best to store the object in both children (this is what I'm thinking of doing). And what if the object happens to to hit all 4 children - store in all the children? Would I ever store objects in the root node? (I can imagine it would be worth it, if the object was at least as big as the root node) I'll probably be moving my items around reasonably often. Pretty basic :D Just a little unsure.
I'm writing a book about How To Make An RPG, check it out! | Blog
rikibee
rikibee
If you can't subdivise the object into smaller parts, I guess the quadtree should store the object into its root node.

That is, you start with a single square. Then you subdivise it in 4 only if some objects can be completly contained into one children. If it overlapses more than one children node, the subdivision stops there.

Never made a QuadTree algorithm, but this is what I understand from literature.

Have fun

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.