Quantcast
Channel: Questions in topic: "quadtree"
Viewing all articles
Browse latest Browse all 16

Recursive Quadtree causing sudden fail

$
0
0
Got a problem with creating a Quadtree in Unity, on my Start function I create an instance of one Quadtree, the idea is that the quadtree subdivides itself into 4 children per node. The problem is that as soon as I hit play Unity crashes instantly. Not like a freeze it just fails and disappears on Mac OSX. I can't understand because I can't see how it could be a infinite loop as the max_level will stop that. public class Quadtree { public Quadtree[] children = null; public int m_max_level = 4; public int m_level = 0; public Quadtree(int maxLevel, int level){ m_max_level = maxLevel; m_level = level; Divide(); } public void Divide(){ if(m_level < m_max_level){ children = new Quadtree[4]; for(int i = 0; i < children.Length; i++){ children[i] = new Quadtree(m_max_level,m_level++); } } } }

Viewing all articles
Browse latest Browse all 16

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>