// Token: 0x06000CBD RID: 3261 RVA: 0x0005DE68 File Offset: 0x0005C268 public static void addInstance(AssetReference <FoliageInstancedMeshInfoAsset> assetReference, Vector3 position, Quaternion rotation, Vector3 scale, bool clearWhenBaked) { FoliageTile orAddTile = FoliageSystem.getOrAddTile(position); Matrix4x4 newMatrix = Matrix4x4.TRS(position, rotation, scale); orAddTile.addInstance(new FoliageInstanceGroup(assetReference, newMatrix, clearWhenBaked)); }
// 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: 0x06000CB4 RID: 3252 RVA: 0x0005DB70 File Offset: 0x0005BF70 private static void bakeGlobalEnd() { if (FoliageSystem.globalBake != null) { FoliageSystem.globalBake(); } FoliageSystem.bakePost(); }
// Token: 0x06000CB1 RID: 3249 RVA: 0x0005DAA0 File Offset: 0x0005BEA0 private static void bakePre() { if (FoliageSystem.preBake != null) { FoliageSystem.preBake(); } FoliageSystem.bakeQueue.Clear(); }
// Token: 0x06000CB7 RID: 3255 RVA: 0x0005DCB2 File Offset: 0x0005C0B2 private static void bakeLocalEnd() { if (FoliageSystem.localBake != null) { FoliageSystem.localBake(FoliageSystem.bakeLocalPosition); } FoliageSystem.bakePost(); }
// Token: 0x06000C7A RID: 3194 RVA: 0x0005D504 File Offset: 0x0005B904 protected void OnEnable() { if (this.isRegistered) { return; } this.isRegistered = true; FoliageSystem.addSurface(this); }
// Token: 0x06000C7B RID: 3195 RVA: 0x0005D51F File Offset: 0x0005B91F protected void OnDestroy() { if (!this.isRegistered) { return; } this.isRegistered = false; FoliageSystem.removeSurface(this); }
// Token: 0x06000CB8 RID: 3256 RVA: 0x0005DCD2 File Offset: 0x0005C0D2 public static void bakeCancel() { if (FoliageSystem.bakeQueue.Count == 0) { return; } FoliageSystem.bakeQueue.Clear(); FoliageSystem.bakeEnd(); }
// Token: 0x06000CCD RID: 3277 RVA: 0x0005E671 File Offset: 0x0005CA71 protected void OnDestroy() { if (FoliageSystem.instance == this) { FoliageSystem.instance = null; FoliageSystem.prevTiles.Clear(); FoliageSystem.activeTiles.Clear(); FoliageSystem.bakeQueue.Clear(); FoliageSystem.clearTiles(); } }
// Token: 0x06000CBC RID: 3260 RVA: 0x0005DE3C File Offset: 0x0005C23C private static void bakePost() { if (LevelHierarchy.instance != null) { LevelHierarchy.instance.isDirty = true; } if (FoliageSystem.postBake != null) { FoliageSystem.postBake(); } }
// Token: 0x06000CC0 RID: 3264 RVA: 0x0005E006 File Offset: 0x0005C406 public static void drawTileCullingChecks(FoliageTile tile, int sqrDistance, float density, Camera camera, Plane[] frustumPlanes) { if (tile == null) { return; } if (!GeometryUtility.TestPlanesAABB(frustumPlanes, tile.worldBounds)) { return; } FoliageSystem.drawTile(tile, sqrDistance, density, camera); }
// Token: 0x06000CC9 RID: 3273 RVA: 0x0005E3D4 File Offset: 0x0005C7D4 protected void Update() { if (MainCamera.instance == null) { return; } FoliageSystem.activeTiles.Clear(); if (FoliageSettings.enabled && FoliageSystem.foliageVisibilityGroup.isVisible) { FoliageSystem.mainCameraFrustumPlanes = GeometryUtility.CalculateFrustumPlanes(MainCamera.instance); FoliageSystem.drawTiles(MainCamera.instance.transform.position, FoliageSettings.drawDistance, null, FoliageSystem.mainCameraFrustumPlanes); if (FoliageSettings.drawFocus && FoliageSystem.isFocused && FoliageSystem.focusCamera != null) { if (MainCamera.instance == FoliageSystem.focusCamera) { FoliageSystem.focusCameraFrustumPlanes = FoliageSystem.mainCameraFrustumPlanes; } else { FoliageSystem.focusCameraFrustumPlanes = GeometryUtility.CalculateFrustumPlanes(FoliageSystem.focusCamera); } FoliageSystem.drawTiles(FoliageSystem.focusPosition, FoliageSettings.drawFocusDistance, FoliageSystem.focusCamera, FoliageSystem.focusCameraFrustumPlanes); } } foreach (KeyValuePair <FoliageCoord, FoliageTile> keyValuePair in FoliageSystem.prevTiles) { if (!FoliageSystem.activeTiles.ContainsKey(keyValuePair.Key)) { if (keyValuePair.Value != null && keyValuePair.Value.hasInstances) { if (keyValuePair.Value.canSafelyClear) { keyValuePair.Value.clearInstances(); } } } } FoliageSystem.prevTiles.Clear(); foreach (KeyValuePair <FoliageCoord, FoliageTile> keyValuePair2 in FoliageSystem.activeTiles) { FoliageSystem.prevTiles.Add(keyValuePair2.Key, keyValuePair2.Value); } if (FoliageSystem.bakeQueue.Count > 0) { KeyValuePair <FoliageTile, List <IFoliageSurface> > keyValuePair3 = FoliageSystem.bakeQueue.Dequeue(); FoliageSystem.bake(keyValuePair3.Key, keyValuePair3.Value); if (FoliageSystem.bakeQueue.Count == 0) { FoliageSystem.bakeEnd(); } } }
// Token: 0x06000CCC RID: 3276 RVA: 0x0005E610 File Offset: 0x0005CA10 protected void Awake() { base.name = "Foliage_System"; base.gameObject.layer = LayerMasks.GROUND; if (FoliageSystem.instance == null) { FoliageSystem.instance = this; FoliageSystem.prevTiles.Clear(); FoliageSystem.activeTiles.Clear(); FoliageSystem.bakeQueue.Clear(); FoliageSystem.clearTiles(); } }
// 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: 0x06000CB3 RID: 3251 RVA: 0x0005DAD4 File Offset: 0x0005BED4 private static void bakeGlobalBegin() { Dictionary <FoliageTile, List <IFoliageSurface> > tileSurfacePairs = FoliageSystem.getTileSurfacePairs(); foreach (KeyValuePair <FoliageTile, List <IFoliageSurface> > item in tileSurfacePairs) { FoliageSystem.bakeQueue.Enqueue(item); } FoliageSystem.bakeQueueTotal = FoliageSystem.bakeQueue.Count; if (FoliageSystem.< > f__mg$cache0 == null) { FoliageSystem.< > f__mg$cache0 = new FoliageSystemPostBakeHandler(FoliageSystem.bakeGlobalEnd); } FoliageSystem.bakeEnd = FoliageSystem.< > f__mg$cache0; FoliageSystem.bakeEnd(); }
// Token: 0x06000CBB RID: 3259 RVA: 0x0005DD84 File Offset: 0x0005C184 private static void bake(FoliageTile tile, List <IFoliageSurface> list) { FoliageSystem.bakePreTile(FoliageSystem.bakeSettings, tile); if (FoliageSystem.preBakeTile != null) { FoliageSystem.preBakeTile(FoliageSystem.bakeSettings, tile); } if (!FoliageSystem.bakeSettings.bakeApplyScale) { foreach (IFoliageSurface foliageSurface in list) { foliageSurface.bakeFoliageSurface(FoliageSystem.bakeSettings, tile); } } FoliageSystem.bakePostTile(FoliageSystem.bakeSettings, tile); if (FoliageSystem.postBakeTile != null) { FoliageSystem.postBakeTile(FoliageSystem.bakeSettings, tile); } }
// 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: 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(); }
// 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: 0x06000CC3 RID: 3267 RVA: 0x0005E284 File Offset: 0x0005C684 public static FoliageTile getTile(Vector3 worldPosition) { FoliageCoord tileCoord = new FoliageCoord(worldPosition); return(FoliageSystem.getTile(tileCoord)); }
// Token: 0x06000C4B RID: 3147 RVA: 0x0005CCAC File Offset: 0x0005B0AC protected override void addFoliage(Vector3 position, Quaternion rotation, Vector3 scale, bool clearWhenBaked) { FoliageSystem.addInstance(base.getReferenceTo <FoliageInstancedMeshInfoAsset>(), position, rotation, scale, clearWhenBaked); }
// Token: 0x06000CB5 RID: 3253 RVA: 0x0005DB8B File Offset: 0x0005BF8B public static void bakeLocal(FoliageBakeSettings bakeSettings) { FoliageSystem.bakeSettings = bakeSettings; FoliageSystem.bakePre(); FoliageSystem.bakeLocalBegin(); }