Esempio n. 1
0
        // ==========================================================================================================================

        public void CalcOctreeSize(Bounds bounds)
        {
            float size;
            int   levels;

            Methods.SnapBoundsAndPreserveArea(ref bounds, cellSize, useCells ? cellOffset : Vector3.zero);

            if (useCells)
            {
                float areaSize = Mathf.Max(Mathw.GetMax(bounds.size), cellSize);
                levels = Mathf.CeilToInt(Mathf.Log(areaSize / cellSize, 2));
                size   = (int)Mathf.Pow(2, levels) * cellSize;
            }
            else
            {
                size   = Mathw.GetMax(bounds.size);
                levels = 0;
            }

            if (levels == 0 && octree is ObjectOctree.Cell)
            {
                octree = new ObjectOctree.MaxCell();
            }
            else if (levels > 0 && octree is ObjectOctree.MaxCell)
            {
                octree = new ObjectOctree.Cell();
            }

            octree.maxLevels = levels;
            octree.bounds    = new Bounds(bounds.center, new Vector3(size, size, size));

            // Debug.Log("size " + size + " levels " + levels);
        }
Esempio n. 2
0
        public void ResetOctree()
        {
            // Debug.Log("ResetOctree");
            octreeContainsObjects = false;

            if (octree == null)
            {
                octree = new ObjectOctree.Cell(); return;
            }

            BaseOctree.Cell[] cells = octree.cells;
            octree.Reset(ref cells);
        }
Esempio n. 3
0
        } // ==========================================================================================================================

        public void ResetOctree()
        {
            // Debug.Log("ResetOctree");
            octreeCreated = false;

            if (octree == null)
            {
                octree = new ObjectOctree.Cell();
                return;
            }

            totalCombined = 0;
            BaseOctree.Cell[] cells = octree.cells;
            octree.Reset(ref cells);
        } // ==========================================================================================================================