Exemplo n.º 1
0
 public void Initialize(int index, LooseOctree <T> tree)
 {
     orphanObjects   = tree.orphanObjects;
     removals        = tree.removals;
     branchItemCount = 0;
     localItemCount  = 0;
     childHasObjects = 0;
     parent          = null;
     isLeaf          = true;
     childIndex      = index;
     //this.locationCode = locationCode;
     this.tree = tree;
 }
Exemplo n.º 2
0
        // Use this for initialization
        IEnumerator Start()
        {
            {
                for (int x = -99; x <= 99; x += 6)
                {
                    for (int y = -99; y <= 99; y += 6)
                    {
                        for (int z = -99; z <= 99; z += 6)
                        {
                            positions.Add(new Vector3(x, y, z));
                        }
                    }
                }
            }
            tree = new LooseOctree <GameObject>(200F, Vector3.zero, 1.25F, positions.Count);
            numObjectsDisplay.text = "Objects per iteration: " + positions.Count;
            float[] buildResults = new float[20];
            float   buildTotal   = 0;

            float[] destroyResults = new float[20];
            float   destroyTotal   = 0;

            Stopwatch timer = new Stopwatch();

            for (int i = 0; i < buildResults.Length; i++)
            {
                iterationsDisplay.text = "Iterations: " + (i + 1);
                buildResults[i]        = PopulateTree(timer);
                timer.Stop();
                buildTotal             += buildResults[i];
                numNodesDisplay.text    = "Nodes per iteration: " + tree.nodeCount;
                destroyResults[i]       = DestroyTree(timer);
                destroyTotal           += destroyResults[i];
                averageTimeDisplay.text = "Average time: Build(" + Mathf.Round(buildTotal / (i + 1)) + "ms) - Destroy(" + Mathf.Round(destroyTotal / (i + 1)) + "ms)";
                totalTimeDisplay.text   = "Total time: Build(" + buildTotal + "ms) - Destroy(" + destroyTotal + "ms)";
                yield return(new WaitForSeconds(0.1F));
            }
            PopulateTree(timer);
            pointTree = new PointOctree <OctreeObject <GameObject> >(200F, Vector3.zero, 1.25F);
            OctreeObject <GameObject>          obj;
            Queue <OctreeObject <GameObject> > remObj = new Queue <OctreeObject <GameObject> >();

            timer.Reset();
            while (treeObj.Count > 0)
            {
                obj = treeObj.Dequeue();
                timer.Start();
                pointTree.Add(obj, obj.boundsCenter);
                timer.Stop();
                remObj.Enqueue(obj);
            }
            pointTreeAddTimeDisplay.text = timer.ElapsedMilliseconds + "ms";
            timer.Reset();
            while (remObj.Count > 0)
            {
                obj = remObj.Dequeue();
                timer.Start();
                pointTree.Remove(obj);
                timer.Stop();
            }
            pointTreeRemoveTimeDisplay.text = timer.ElapsedMilliseconds + "ms";
            averageTimeDisplay.text         = "Average time: Build(" + buildTotal / buildResults.Length + "ms) - Destroy(" + destroyTotal / destroyResults.Length + "ms)";
            StartCoroutine(PopulateTreeSlow());
        }
Exemplo n.º 3
0
 private int childHasObjects = 0; //Bitmask for child nodes
 public void Initialize(int index, LooseOctree <T> tree, OctreeNode parent)
 {
     Initialize(index, tree);
     this.parent = parent;
     treeDepth   = parent.treeDepth + 1;
 }
Exemplo n.º 4
0
 public void SetNode(LooseOctree <T> .OctreeNode node)
 {
     this.node = node;
 }