public void RefreshTerrainArea(Bounds bounds)
        {
            if (VegetationCellQuadTree == null)
            {
                return;
            }

            List <VegetationCell> overlapVegetationCellList = new List <VegetationCell>();
            Rect updateRect = RectExtension.CreateRectFromBounds(bounds);

            VegetationCellQuadTree.Query(updateRect, overlapVegetationCellList);

            Bounds updateBounds = bounds;

            NativeArray <Bounds> vegetationCellBounds =
                new NativeArray <Bounds>(overlapVegetationCellList.Count, Allocator.Persistent);

            for (int i = 0; i <= overlapVegetationCellList.Count - 1; i++)
            {
                Bounds cellBounds = RectExtension.CreateBoundsFromRect(overlapVegetationCellList[i].Rectangle, -100000);
                vegetationCellBounds[i] = cellBounds;
                updateBounds.Encapsulate(cellBounds);
            }

            updateRect = RectExtension.CreateRectFromBounds(updateBounds);

            float minBoundsHeight    = VegetationSystemBounds.center.y - VegetationSystemBounds.extents.y;
            float worldspaceSealevel = minBoundsHeight + SeaLevel;

            if (!ExcludeSeaLevelCells)
            {
                worldspaceSealevel = minBoundsHeight;
            }

            JobHandle jobHandle = default(JobHandle);

            for (int i = 0; i <= VegetationStudioTerrainList.Count - 1; i++)
            {
                jobHandle = VegetationStudioTerrainList[i]
                            .SampleCellHeight(vegetationCellBounds, worldspaceSealevel, updateRect, jobHandle);
            }

            jobHandle.Complete();

            for (int i = 0; i <= overlapVegetationCellList.Count - 1; i++)
            {
                overlapVegetationCellList[i].VegetationCellBounds = vegetationCellBounds[i];
            }

            vegetationCellBounds.Dispose();

            ForceCullingRefresh();
            ClearCache(bounds);
        }
Пример #2
0
 public MeshSampleCell(Rect rectangle)
 {
     CellBounds = RectExtension.CreateBoundsFromRect(rectangle, -100000);
 }
Пример #3
0
 public BillboardCell(Rect rectangle, float centerY, float sizeY)
 {
     BilllboardCellBounds = RectExtension.CreateBoundsFromRect(rectangle, centerY, sizeY);
 }
Пример #4
0
 public VegetationCell(Rect rectangle)
 {
     VegetationCellBounds = RectExtension.CreateBoundsFromRect(rectangle, -100000);
 }