Esempio n. 1
0
        private bool CustumComputeVolumeCells()
        {
            volumelList.Clear();

            Scene curScene = SceneManager.GetSceneByName(Name);

            GameObject[] roots = curScene.GetRootGameObjects();

            for (int i = 0; i < curScene.rootCount; i++)
            {
                var root = roots[i];
                if (root.activeInHierarchy == false)
                {
                    continue;
                }
                var volumes = root.GetComponentsInChildren <OCVolume>();
                foreach (var volume in volumes)
                {
                    if (volume.enabled)
                    {
                        //if (volume.SimpleGenerateCell)
                        {
                            var visVolume = new VisVolume(this);
                            visVolume.CellSize = volume.CellSize;
                            //visVolume.CellSize = Config.CellSize;
                            visVolume.aabb = volume.Box.bounds;
                            visVolume.GenerateCells();
                            volumelList.Add(visVolume);
                        }

                        /*else
                         * {
                         *  var raster = new VolumeCellRaster(new RasterSettings(volume.CellSize, Config.MinPlayAreaHeight, Config.MaxPlayAreaHeight));
                         *  raster.AddVolume(volume.Box.bounds.min, volume.Box.bounds.max);
                         *  var cells = raster.ComputeVolumeCells(colliderList, Util.Progress);
                         *
                         *  if (cells != null && cells.Count > 0)
                         *  {
                         *      cells = ProprocessCells(cells, volume.CellSize);
                         *      var visVolume = new VisVolume(this);
                         *      visVolume.CellSize = volume.CellSize;
                         *      visVolume.aabb = volume.Box.bounds;
                         *      volumelList.Add(visVolume);
                         *
                         *      foreach (var cell in cells)
                         *      {
                         *          var c = new Cell(visVolume);
                         *          c.aabb = new Bounds(cell.Center, cell.Size);
                         *          visVolume.AddCell(c);
                         *      }
                         *  }
                         * }*/
                    }
                }
            }

            EditorUtility.ClearProgressBar();

            return(volumelList.Count > 0);
        }
Esempio n. 2
0
        private bool AutoComputeVolumeCells(string Name)
        {
            Scene curScene = SceneManager.GetSceneByName(Name);

            GameObject[] objs = curScene.GetRootGameObjects();

            var bounds       = new Bounds();
            var colliderList = new List <Collider>();

            for (int i = 0; i < curScene.rootCount; i++)
            {
                GameObject obj = objs[i];

                var colliders = obj.GetComponentsInChildren <Collider>();
                foreach (var collider in colliders)
                {
                    if (IsStandableCollider(collider))
                    {
                        colliderList.Add(collider);

                        bounds.Encapsulate(collider.bounds);
                    }
                }
            }
            bounds.Expand(new Vector3(5.0f, 5.0f, 5.0f));


            Debug.LogFormat("Total Raster Collider Count {0}", colliderList.Count);

            var success = true;

            {
                var raster = new VolumeCellRaster(new RasterSettings(Config.CellSize, Config.MinPlayAreaHeight, Config.MaxPlayAreaHeight));
                raster.AddVolume(bounds.min, bounds.max);
                var cells = raster.ComputeVolumeCells(colliderList, Util.Progress);

                if (cells != null && cells.Count > 0)
                {
                    cells = ProprocessCells(cells, Config.CellSize);
                    var visVolume = new VisVolume(this);
                    visVolume.CellSize = Config.CellSize;
                    visVolume.aabb     = bounds;
                    volumelList.Add(visVolume);

                    foreach (var cell in cells)
                    {
                        var c = new Cell(visVolume);
                        c.aabb = new Bounds(cell.Center, cell.Size);
                        visVolume.AddCell(c);
                    }
                }

                success = cells != null;
            }
            return(success);
        }
Esempio n. 3
0
        private void LoadBlock(OCDataReader ocReader, int blockIndex)
        {
            if (ocReader.TrySetBlock(blockIndex))
            {
                LoadNeighborMaxGameObjId(ocReader);
                _maxGameObjectIDCount = ocReader.ReadInt();

                int len = ocReader.ReadInt();

                for (int i = 0; i < len; i++)
                {
                    VisVolume volume = new VisVolume(this);
                    volume.Load(ocReader);
                    volumelList.Add(volume);
                }
            }
        }
Esempio n. 4
0
 public void AddVolume(VisVolume v)
 {
     volumelList.Add(v);
 }
Esempio n. 5
0
 public Cell(VisVolume owner)
 {
     this.owner = owner;
 }