quad tree confusion
Posted: Thu Oct 07, 2010 8:37 pm
okay so i just sent a pm to someone asking about a quad tree and figured why not ask it on here, maybe it will help someone else too. message copied below:
Hey man, I have been doing a little research on quad trees lately and have a pretty good understanding of how to compose and create the tree and divide the space containing the objects What I am having a hard time with is accessing the objects in the same node that need to be compared for collision. So i am using a quad tree that puts objects in their own leaf and keeps dividing the space until they are in their own leaf (to a certain maximum) but how do i access or store the correct list that the overlapping objects are in? You can probably sense my confusion not being able to explain what exactly im trying to ask hah. In simpler terms maybe, I have a quadtree class and it works fine in putting all the objects in the appropriate nodes/leafs and i have a list of all the objects but how do I get only the leafs which contain colliding objects? If i were to check every object and see if it were in the same node as all the other objects it would kind of defeat the purpose. If you have made it this far in reading my message I thank you hah, i just am so frusterated why i cannot figure out what i'm not understanding here.
Thanks guys
Ed
EDIT---------------------------
I do this a lot, when I think about how to ask a question i think about the problem differently. I think i figured it out, making a list for each of the collidable objects which share the same leaf and just check those objects positions. Also will add any objects in the parent rectangle and so on up the tree. I dont kno why i was confusing myself for something so simple. If there is a better more efficient way please let me know. thanks
Hey man, I have been doing a little research on quad trees lately and have a pretty good understanding of how to compose and create the tree and divide the space containing the objects What I am having a hard time with is accessing the objects in the same node that need to be compared for collision. So i am using a quad tree that puts objects in their own leaf and keeps dividing the space until they are in their own leaf (to a certain maximum) but how do i access or store the correct list that the overlapping objects are in? You can probably sense my confusion not being able to explain what exactly im trying to ask hah. In simpler terms maybe, I have a quadtree class and it works fine in putting all the objects in the appropriate nodes/leafs and i have a list of all the objects but how do I get only the leafs which contain colliding objects? If i were to check every object and see if it were in the same node as all the other objects it would kind of defeat the purpose. If you have made it this far in reading my message I thank you hah, i just am so frusterated why i cannot figure out what i'm not understanding here.
Thanks guys
Ed
EDIT---------------------------
I do this a lot, when I think about how to ask a question i think about the problem differently. I think i figured it out, making a list for each of the collidable objects which share the same leaf and just check those objects positions. Also will add any objects in the parent rectangle and so on up the tree. I dont kno why i was confusing myself for something so simple. If there is a better more efficient way please let me know. thanks