<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.xna.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Game Algorithms</title><link>http://forums.xna.com/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 0.0)</generator><item><title>Re: Large objects in QuadTrees</title><link>http://forums.xna.com/forums/thread/196394.aspx</link><pubDate>Sat, 04 Jul 2009 19:37:41 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:196394</guid><dc:creator>Zeta Two</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/196394.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=45&amp;PostID=196394</wfw:commentRss><description>I ended up putting the objects in the parent node. I still only have half the number of collision tests/frame vs using only a linked list.

EDIT:
also, with some further optimization (only moving objects in the quad tree which acctually have moved), I&amp;#39;m down to 1/5 the tests/frame vs simple list.</description></item><item><title>Re: Large objects in QuadTrees</title><link>http://forums.xna.com/forums/thread/195973.aspx</link><pubDate>Fri, 03 Jul 2009 05:47:27 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:195973</guid><dc:creator>Eckish</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/195973.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=45&amp;PostID=195973</wfw:commentRss><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://forums.xna.com//Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;BenC:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;
&lt;div&gt;Aright so I&amp;#39;ve just finished updating my code to place any intersecting objects within the leaf nodes they intersects with... So far so good...except.&lt;/div&gt;
&lt;div&gt;...there are instances where lets say two objects intersect with the same leaf nodes... hence via tree traversing, those objects are checked against each other twice.&lt;/div&gt;
&lt;div&gt;Besides creating a list of already checked pairs and checking against it, is there anything else I can do to remedy this situation?&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;
&lt;div&gt;I am using the tree for 2d collision detection by the way.&lt;/div&gt;
&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;br /&gt;
&lt;br /&gt;
You will get extra checks like that if you go the route of putting large objects into multiple nodes.  However, the increase will be constant and shouldn&amp;#39;t affect your performance significantly.  &lt;br /&gt;
&lt;br /&gt;
One thing you can do is to give each object a unique id.  And then only allow objects to only check against objects with a higher id.  That way you would get multiple checks from big objects only once.&lt;br /&gt;
&lt;br /&gt;
I also track the collisions instead of acting on them immediately.  So, on each collision sweep, my objects only check against every other collision candidate in one direction.  And then they also only register one collision against them.  Tracking them instead of immediately performing actions (which can mean destroying the object) also means that all of the objects will still exist if a third object happened to also be colliding with them that frame.</description></item><item><title>Re: Large objects in QuadTrees</title><link>http://forums.xna.com/forums/thread/195948.aspx</link><pubDate>Fri, 03 Jul 2009 03:12:57 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:195948</guid><dc:creator>Craig Martin</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/195948.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=45&amp;PostID=195948</wfw:commentRss><description>Sometimes it&amp;#39;s worth just not using a quad tree for certain objects. If you have only a few &amp;#39;extra large&amp;#39; objects it might be worth just leaving them out of the quadtree. Depends how determined you are to generalise I guess.&lt;br /&gt;</description></item><item><title>Re: Large objects in QuadTrees</title><link>http://forums.xna.com/forums/thread/195927.aspx</link><pubDate>Fri, 03 Jul 2009 01:53:54 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:195927</guid><dc:creator>BenC</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/195927.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=45&amp;PostID=195927</wfw:commentRss><description>&lt;span&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://forums.xna.com//Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;Eckish:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;You should put it in every low level cell that it collides with, if you are going to go that route.  And then no, it won&amp;#39;t be complicated to check against it.  It will exist in more than one cell and may get checked multiple times as a result, but the algorithm doesn&amp;#39;t change with that respect.   &lt;br /&gt;&lt;br /&gt;What gets complicated by that method is the return reference.  A good tree design will have a two way reference. The cell nodes will reference the objects, so if a collision exists on the cell, then you know you should check the child objects for collisions too.  The objects themselves should also have a reference to the cell it belongs to.  Thats for allowing you to remove the object from the cell quickly.  Otherwise, you would have to search the tree again in order to find the cell it is located in to remove it.  So, if you go with a design that allows the object to exist in more than one cell, then you also need to design the object to hold multiple cell references.&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/span&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Aright so I&amp;#39;ve just finished updating my code to place any intersecting objects within the leaf nodes they intersects with... So far so good...except.&lt;/div&gt;&lt;div&gt;...there are instances where lets say two objects intersect with the same leaf nodes... hence via tree traversing, those objects are checked against each other twice.&lt;/div&gt;&lt;div&gt;Besides creating a list of already checked pairs and checking against it, is there anything else I can do to remedy this situation?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I am using the tree for 2d collision detection by the way.&lt;/div&gt;</description></item><item><title>Re: Large objects in QuadTrees</title><link>http://forums.xna.com/forums/thread/195913.aspx</link><pubDate>Fri, 03 Jul 2009 01:01:46 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:195913</guid><dc:creator>jwatte</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/195913.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=45&amp;PostID=195913</wfw:commentRss><description>If you&amp;#39;re talking about &amp;quot;loose&amp;quot; boundaries, then the object is only in one cell. That may be a leaf cell, or it may be a parent cell, but it will always be the cell that contains the center of the object. An object will not be pushed deeper into the tree than the size where a cell size times your looseness alpha is just greater than the radius of the object. Thus, big objects live further up; small objects further down (and you can limit the tree depth if you want).&lt;br /&gt;
&lt;br /&gt;</description></item><item><title>Re: Large objects in QuadTrees</title><link>http://forums.xna.com/forums/thread/195905.aspx</link><pubDate>Fri, 03 Jul 2009 00:28:04 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:195905</guid><dc:creator>Eckish</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/195905.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=45&amp;PostID=195905</wfw:commentRss><description>You should put it in every low level cell that it collides with, if you are going to go that route.  And then no, it won&amp;#39;t be complicated to check against it.  It will exist in more than one cell and may get checked multiple times as a result, but the algorithm doesn&amp;#39;t change with that respect.   &lt;br /&gt;
&lt;br /&gt;
What gets complicated by that method is the return reference.  A good tree design will have a two way reference. The cell nodes will reference the objects, so if a collision exists on the cell, then you know you should check the child objects for collisions too.  The objects themselves should also have a reference to the cell it belongs to.  Thats for allowing you to remove the object from the cell quickly.  Otherwise, you would have to search the tree again in order to find the cell it is located in to remove it.  So, if you go with a design that allows the object to exist in more than one cell, then you also need to design the object to hold multiple cell references.</description></item><item><title>Re: Large objects in QuadTrees</title><link>http://forums.xna.com/forums/thread/195893.aspx</link><pubDate>Thu, 02 Jul 2009 23:41:01 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:195893</guid><dc:creator>Zeta Two</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/195893.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=45&amp;PostID=195893</wfw:commentRss><description>One question:

What if I have a large object (say twice or three times the size of a bottom-level cell). Won&amp;#39;t it be rather complicated check which cells&amp;#39; loose bounds intersects with the current one?</description></item><item><title>Re: Large objects in QuadTrees</title><link>http://forums.xna.com/forums/thread/195878.aspx</link><pubDate>Thu, 02 Jul 2009 22:28:03 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:195878</guid><dc:creator>BenC</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/195878.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=45&amp;PostID=195878</wfw:commentRss><description>Yeah I see what you guys mean... it renders the quad tree somewhat pointless.&lt;div&gt;&lt;br /&gt;&lt;div&gt;For the sake of getting my hands dirty i&amp;#39;ll try my hand at this method you mentioned jwatte:&lt;/div&gt;&lt;div&gt;&lt;span style="font-size:11px;"&gt;&amp;quot;Add overlapping objects to multiple nodes, and descend a single node when querying. This makes each object more complex, because it needs to know all nodes that it&amp;#39;s added to.&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size:11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;I hope it doesn&amp;#39;t get too messy.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size:13px;"&gt;Thanks for the feedback guys.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</description></item><item><title>Re: Large objects in QuadTrees</title><link>http://forums.xna.com/forums/thread/195872.aspx</link><pubDate>Thu, 02 Jul 2009 22:10:24 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:195872</guid><dc:creator>jwatte</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/195872.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=45&amp;PostID=195872</wfw:commentRss><description>The problem with parents is that a lot of things will end up in the root node -- anything that crosses the topmost center &amp;quot;cross&amp;quot; will go there. The problem with that, in turn, is that then everything that tests against the quad tree ends up testing against everything in the root node, and the performance will be more like a linked list, and less like a recursive tree.&lt;br /&gt;
&lt;br /&gt;
That being said -- a lot of games get by with just a linked list, and no recursive structure at all. If you want to save time, just pop &amp;#39;em all into a List&amp;lt;Entity&amp;gt;, and only replace it with a Quadtree&amp;lt;Entity&amp;gt; if and when you really need to.&lt;br /&gt;
&lt;br /&gt;</description></item><item><title>Re: Large objects in QuadTrees</title><link>http://forums.xna.com/forums/thread/195862.aspx</link><pubDate>Thu, 02 Jul 2009 21:59:40 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:195862</guid><dc:creator>Eckish</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/195862.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=45&amp;PostID=195862</wfw:commentRss><description>If they overlap with one line, they could over lap with a line in the parent and continue to move up the tree.  If a bunch of stuff moves up the tree, you lose all the benefits of having a tree in the first place, because you end up checking against most game objects anyways.</description></item><item><title>Re: Large objects in QuadTrees</title><link>http://forums.xna.com/forums/thread/195857.aspx</link><pubDate>Thu, 02 Jul 2009 21:49:57 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:195857</guid><dc:creator>BenC</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/195857.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=45&amp;PostID=195857</wfw:commentRss><description>&lt;div&gt;Thanks for the comment. I expected the method I use to be less efficient than other methods like the ones &lt;a href="http://profile.xna.com/profile.aspx?crn=jwatte" style="text-decoration:none;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;"&gt;jwatte&lt;/a&gt; mentioned...but you used the word &lt;strong&gt;significantly &lt;/strong&gt;which has me worried.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So I take it you guys &lt;strong&gt;highly do not recommend&lt;/strong&gt; placing objects in parents if they overlap and recommend implementing another way of doing it?&lt;/div&gt;</description></item><item><title>Re: Large objects in QuadTrees</title><link>http://forums.xna.com/forums/thread/195654.aspx</link><pubDate>Thu, 02 Jul 2009 08:15:49 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:195654</guid><dc:creator>Craig Martin</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/195654.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=45&amp;PostID=195654</wfw:commentRss><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://forums.xna.com//Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;BenC:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;I went with option one... placing it in the parent quad. So far it seems to be working out fine.&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;br /&gt;
&lt;br /&gt;
That can significantly slow down quad tree lookups.</description></item><item><title>Re: Large objects in QuadTrees</title><link>http://forums.xna.com/forums/thread/195556.aspx</link><pubDate>Thu, 02 Jul 2009 00:45:55 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:195556</guid><dc:creator>BenC</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/195556.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=45&amp;PostID=195556</wfw:commentRss><description>I ran into this issue when I first started to implement a quad tree.&lt;div&gt;I went with option one... placing it in the parent quad. So far it seems to be working out fine.&lt;/div&gt;</description></item><item><title>Re: Large objects in QuadTrees</title><link>http://forums.xna.com/forums/thread/195555.aspx</link><pubDate>Thu, 02 Jul 2009 00:45:29 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:195555</guid><dc:creator>Eckish</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/195555.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=45&amp;PostID=195555</wfw:commentRss><description>Another alternative that might make sense in some situations is to instead break the larger object up into smaller pieces.  Then you can treat each part just like you would normal small objects in the tree.  No complexity is added to the tree structure or search algorithms.  Instead, when a collision is detected on a piece, it will be responsible for notifying the rest of &amp;#39;itself&amp;#39; that a collision occurred.</description></item><item><title>Re: Large objects in QuadTrees</title><link>http://forums.xna.com/forums/thread/195552.aspx</link><pubDate>Thu, 02 Jul 2009 00:37:33 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:195552</guid><dc:creator>jwatte</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/195552.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=45&amp;PostID=195552</wfw:commentRss><description>There are two ways to solve this problem:&lt;br /&gt;
&lt;br /&gt;
1) Add overlapping objects to multiple nodes, and descend a single node when querying. This makes each object more complex, because it needs to know all nodes that it&amp;#39;s added to.&lt;br /&gt;
&lt;br /&gt;
2) Add the object only to the node that contains the center of the object, and recurse multiple nodes when querying. This makes querying somewhat more costly (by a constant factor, it turns out!), but keeps the data structure small and simple.&lt;br /&gt;
&lt;br /&gt;
Basically, the deepest level at which you store an object is determined by the radius of that object. Then you query the tree with an inflation factor for each cell that corresponds to the maximum extent an object may have at that level. If you google for &amp;quot;loose octree&amp;quot; you will find tutorials for how to do this. For octrees, but the same idea works fine for quad trees.&lt;br /&gt;
&lt;br /&gt;</description></item></channel></rss>