// Token: 0x06000CBF RID: 3263 RVA: 0x0005DF10 File Offset: 0x0005C310
        public static void drawTiles(Vector3 position, int drawDistance, Camera camera, Plane[] frustumPlanes)
        {
            int          num          = drawDistance * drawDistance;
            FoliageCoord foliageCoord = new FoliageCoord(position);

            for (int i = -drawDistance; i <= drawDistance; i++)
            {
                for (int j = -drawDistance; j <= drawDistance; j++)
                {
                    FoliageCoord foliageCoord2 = new FoliageCoord(foliageCoord.x + i, foliageCoord.y + j);
                    if (!FoliageSystem.activeTiles.ContainsKey(foliageCoord2))
                    {
                        FoliageTile tile = FoliageSystem.getTile(foliageCoord2);
                        if (tile != null)
                        {
                            int num2 = i * i + j * j;
                            if (num2 <= num)
                            {
                                float density = 1f;
                                float num3    = Mathf.Sqrt((float)num2);
                                if (num3 > 2f && drawDistance > 3)
                                {
                                    density = 1f - (num3 - 2f) / (float)(drawDistance - 1);
                                }
                                FoliageSystem.drawTileCullingChecks(tile, num2, density, camera, frustumPlanes);
                                FoliageSystem.activeTiles.Add(foliageCoord2, tile);
                            }
                        }
                    }
                }
            }
        }
        // Token: 0x06000CC5 RID: 3269 RVA: 0x0005E2D4 File Offset: 0x0005C6D4
        public static FoliageTile getTile(FoliageCoord tileCoord)
        {
            FoliageTile result;

            FoliageSystem.tiles.TryGetValue(tileCoord, out result);
            return(result);
        }
Exemple #3
0
 // Token: 0x06000CCE RID: 3278 RVA: 0x0005E6AC File Offset: 0x0005CAAC
 public FoliageTile(FoliageCoord newCoord)
 {
     this.coord          = newCoord;
     this.hasInstances   = false;
     this.canSafelyClear = true;
     this.cuts           = new List <IShapeVolume>();
 }
        // Token: 0x06000CC4 RID: 3268 RVA: 0x0005E2A0 File Offset: 0x0005C6A0
        public static FoliageTile getOrAddTile(FoliageCoord tileCoord)
        {
            FoliageTile foliageTile;

            if (!FoliageSystem.tiles.TryGetValue(tileCoord, out foliageTile))
            {
                foliageTile = new FoliageTile(tileCoord);
                FoliageSystem.tiles.Add(tileCoord, foliageTile);
            }
            return(foliageTile);
        }
        // Token: 0x06000CAF RID: 3247 RVA: 0x0005D8AC File Offset: 0x0005BCAC
        public static void addCut(IShapeVolume cut)
        {
            Bounds        worldBounds   = cut.worldBounds;
            FoliageBounds foliageBounds = new FoliageBounds(worldBounds);

            for (int i = foliageBounds.min.x; i <= foliageBounds.max.x; i++)
            {
                for (int j = foliageBounds.min.y; j <= foliageBounds.max.y; j++)
                {
                    FoliageCoord tileCoord = new FoliageCoord(i, j);
                    FoliageTile  orAddTile = FoliageSystem.getOrAddTile(tileCoord);
                    orAddTile.addCut(cut);
                }
            }
        }
        // Token: 0x06000CB6 RID: 3254 RVA: 0x0005DBA0 File Offset: 0x0005BFA0
        private static void bakeLocalBegin()
        {
            FoliageSystem.bakeLocalPosition = MainCamera.instance.transform.position;
            int          num          = 6;
            int          num2         = num * num;
            FoliageCoord foliageCoord = new FoliageCoord(FoliageSystem.bakeLocalPosition);
            Dictionary <FoliageTile, List <IFoliageSurface> > tileSurfacePairs = FoliageSystem.getTileSurfacePairs();

            for (int i = -num; i <= num; i++)
            {
                for (int j = -num; j <= num; j++)
                {
                    int num3 = i * i + j * j;
                    if (num3 <= num2)
                    {
                        FoliageCoord tileCoord = new FoliageCoord(foliageCoord.x + i, foliageCoord.y + j);
                        FoliageTile  tile      = FoliageSystem.getTile(tileCoord);
                        if (tile != null)
                        {
                            List <IFoliageSurface> value;
                            if (tileSurfacePairs.TryGetValue(tile, out value))
                            {
                                KeyValuePair <FoliageTile, List <IFoliageSurface> > item = new KeyValuePair <FoliageTile, List <IFoliageSurface> >(tile, value);
                                FoliageSystem.bakeQueue.Enqueue(item);
                            }
                        }
                    }
                }
            }
            FoliageSystem.bakeQueueTotal = FoliageSystem.bakeQueue.Count;
            if (FoliageSystem.< > f__mg$cache1 == null)
            {
                FoliageSystem.< > f__mg$cache1 = new FoliageSystemPostBakeHandler(FoliageSystem.bakeLocalEnd);
            }
            FoliageSystem.bakeEnd = FoliageSystem.< > f__mg$cache1;
            FoliageSystem.bakeEnd();
        }
Exemple #7
0
        // Token: 0x06000C4A RID: 3146 RVA: 0x0005CB44 File Offset: 0x0005AF44
        public override int getInstanceCountInVolume(IShapeVolume volume)
        {
            Bounds        worldBounds   = volume.worldBounds;
            FoliageBounds foliageBounds = new FoliageBounds(worldBounds);
            int           num           = 0;

            for (int i = foliageBounds.min.x; i <= foliageBounds.max.x; i++)
            {
                for (int j = foliageBounds.min.y; j <= foliageBounds.max.y; j++)
                {
                    FoliageCoord tileCoord = new FoliageCoord(i, j);
                    FoliageTile  tile      = FoliageSystem.getTile(tileCoord);
                    if (tile != null)
                    {
                        if (!tile.hasInstances)
                        {
                            tile.readInstancesOnThread();
                        }
                        FoliageInstanceList foliageInstanceList;
                        if (tile.instances != null && tile.instances.TryGetValue(base.getReferenceTo <FoliageInstancedMeshInfoAsset>(), out foliageInstanceList))
                        {
                            foreach (List <Matrix4x4> list in foliageInstanceList.matrices)
                            {
                                foreach (Matrix4x4 matrix in list)
                                {
                                    if (volume.containsPoint(matrix.GetPosition()))
                                    {
                                        num++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(num);
        }
        // Token: 0x06000CB0 RID: 3248 RVA: 0x0005D934 File Offset: 0x0005BD34
        private static Dictionary <FoliageTile, List <IFoliageSurface> > getTileSurfacePairs()
        {
            Dictionary <FoliageTile, List <IFoliageSurface> > dictionary = new Dictionary <FoliageTile, List <IFoliageSurface> >();

            foreach (KeyValuePair <FoliageCoord, FoliageTile> keyValuePair in FoliageSystem.tiles)
            {
                FoliageTile value = keyValuePair.Value;
                if (FoliageVolumeUtility.isTileBakeable(value))
                {
                    dictionary.Add(value, new List <IFoliageSurface>());
                }
            }
            foreach (IFoliageSurface foliageSurface in FoliageSystem.surfaces)
            {
                FoliageBounds foliageSurfaceBounds = foliageSurface.getFoliageSurfaceBounds();
                for (int i = foliageSurfaceBounds.min.x; i <= foliageSurfaceBounds.max.x; i++)
                {
                    for (int j = foliageSurfaceBounds.min.y; j <= foliageSurfaceBounds.max.y; j++)
                    {
                        FoliageCoord tileCoord = new FoliageCoord(i, j);
                        FoliageTile  orAddTile = FoliageSystem.getOrAddTile(tileCoord);
                        if (FoliageVolumeUtility.isTileBakeable(orAddTile))
                        {
                            List <IFoliageSurface> list;
                            if (!dictionary.TryGetValue(orAddTile, out list))
                            {
                                list = new List <IFoliageSurface>();
                                dictionary.Add(orAddTile, list);
                            }
                            list.Add(foliageSurface);
                        }
                    }
                }
            }
            return(dictionary);
        }
 // Token: 0x06000BFE RID: 3070 RVA: 0x0005B8D4 File Offset: 0x00059CD4
 public FoliageBounds(FoliageCoord newMin, FoliageCoord newMax)
 {
     this.min = newMin;
     this.max = newMax;
 }
        // Token: 0x06000CC3 RID: 3267 RVA: 0x0005E284 File Offset: 0x0005C684
        public static FoliageTile getTile(Vector3 worldPosition)
        {
            FoliageCoord tileCoord = new FoliageCoord(worldPosition);

            return(FoliageSystem.getTile(tileCoord));
        }