public void DrawVisibleBillboardCellGizmos() { if (BillboardJobCullingGroup == null) { return; } Gizmos.color = Color.green; for (int i = 0; i <= BillboardJobCullingGroup.VisibleCellIndexList.Length - 1; i++) { int index = BillboardJobCullingGroup.VisibleCellIndexList[i]; BillboardCell billboardCell = VegetationSystemPro.BillboardCellList[index]; Gizmos.DrawWireCube(billboardCell.BilllboardCellBounds.center, billboardCell.BilllboardCellBounds.size); } }
private void CreateBillboardCells() { DisposeBillboardCells(); var expandedBounds = new Bounds(VegetationSystemBounds.center, VegetationSystemBounds.size); var currentBillboardCellSize = BillboardCellSize; if (!Application.isPlaying) { currentBillboardCellSize = 400; } expandedBounds.Expand(new Vector3(currentBillboardCellSize * 2f, 0, currentBillboardCellSize * 2f)); BillboardCellQuadTree = new QuadTree <BillboardCell>(RectExtension.CreateRectFromBounds(expandedBounds)); var cellXCount = Mathf.CeilToInt(VegetationSystemBounds.size.x / currentBillboardCellSize); var cellZCount = Mathf.CeilToInt(VegetationSystemBounds.size.z / currentBillboardCellSize); var corner = new Vector2(VegetationSystemBounds.center.x - VegetationSystemBounds.size.x / 2f, VegetationSystemBounds.center.z - VegetationSystemBounds.size.z / 2f); for (var x = 0; x <= cellXCount - 1; x++) { for (var z = 0; z <= cellZCount - 1; z++) { var billboardCell = new BillboardCell( new Rect( new Vector2(currentBillboardCellSize * x + corner.x, currentBillboardCellSize * z + corner.y), new Vector2(currentBillboardCellSize, currentBillboardCellSize)), VegetationSystemBounds.center.y, VegetationSystemBounds.size.y); BillboardCellList.Add(billboardCell); billboardCell.Index = BillboardCellList.Count - 1; BillboardCellQuadTree.Insert(billboardCell); } } PrepareAllBillboardCells(); }