void AddVegetationItemsToScene(VegetationCell vegetationCell, GameObject parent, VegetationItemInfoPro vegetationItemInfoPro) { if (!vegetationItemInfoPro.VegetationPrefab) { return; } VegetationSystemPro vegetationSystemPro = _sceneVegetationBaker.VegetationSystemPro; vegetationSystemPro.SpawnVegetationCell(vegetationCell, vegetationItemInfoPro.VegetationItemID); NativeList <MatrixInstance> vegetationInstanceList = vegetationSystemPro.GetVegetationItemInstances(vegetationCell, vegetationItemInfoPro.VegetationItemID); for (int j = 0; j <= vegetationInstanceList.Length - 1; j++) { Matrix4x4 vegetationItemMatrix = vegetationInstanceList[j].Matrix; Vector3 position = MatrixTools.ExtractTranslationFromMatrix(vegetationItemMatrix); Vector3 scale = MatrixTools.ExtractScaleFromMatrix(vegetationItemMatrix); Quaternion rotation = MatrixTools.ExtractRotationFromMatrix(vegetationItemMatrix); GameObject vegetationItem = Instantiate(vegetationItemInfoPro.VegetationPrefab, parent.transform); vegetationItem.transform.position = position; vegetationItem.transform.localScale = scale; vegetationItem.transform.rotation = rotation; vegetationItem.isStatic = _sceneVegetationBaker.ExportStatic; } vegetationCell.ClearCache(); }
public ColliderPool(VegetationItemInfoPro vegetationItemInfoPro, VegetationItemModelInfo vegetationItemModelInfo, VegetationSystemPro vegetationSystemPro, Transform colliderParent, bool showColliders) { _vegetationItemInfoPro = vegetationItemInfoPro; _vegetationItemModelInfo = vegetationItemModelInfo; _vegetationSystemPro = vegetationSystemPro; _colliderParent = colliderParent; _showColliders = showColliders; _colliderLayer = vegetationSystemPro.VegetationSettings.GetLayer(vegetationItemInfoPro.VegetationType); _colliderTag = vegetationItemInfoPro.ColliderTag; if (_colliderTag == "") { _colliderTag = "Untagged"; } if (_vegetationItemInfoPro.ColliderType == ColliderType.FromPrefab) { GameObject tmpColliderObject = Object.Instantiate(vegetationItemInfoPro.VegetationPrefab); if (_vegetationItemInfoPro.ColliderTag != "") { tmpColliderObject.tag = vegetationItemInfoPro.ColliderTag; } tmpColliderObject.hideFlags = HideFlags.DontSave; tmpColliderObject.name = "ColliderSource_" + _vegetationItemInfoPro.VegetationItemID; tmpColliderObject.transform.SetParent(_colliderParent); _sourceColliderObject = CreateColliderObject(tmpColliderObject); DestroyObject(tmpColliderObject); } }
public static VegetationSystemPro GetTopVegetationSystem() /// Finds main system to be used as source for clones { GameObject[] rootObjects = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects(); foreach (GameObject rootObject in rootObjects) { if (rootObject.GetComponent <VegetationStudioManager>()) { int childCount = rootObject.transform.childCount; for (int c = 0; c < childCount; c++) { Transform child = rootObject.transform.GetChild(c); VegetationSystemPro sys = child.GetComponent <VegetationSystemPro>(); if (sys != null) { return(sys); } } } } return(null); }
public static void SetObjects(List <Transition>[] allTransitions, string[] allIds) { VegetationSystemPro system = GameObject.FindObjectOfType <VegetationSystemPro>(); PersistentVegetationStorage storage = system.PersistentVegetationStorage; for (int i = 0; i < allTransitions.Length; i++) { if (allTransitions[i] == null) { continue; } foreach (Transition obj in allTransitions[i]) { storage.AddVegetationItemInstance( allIds[i], obj.pos, obj.scale, obj.rotation, applyMeshRotation: true, vegetationSourceID: VS_MM_id, distanceFalloff: 1, clearCellCache: true); } } //for (int i=0; i<system.VegetationCellList.Count; i++) // system.VegetationCellList[i].ClearCache(); system.RefreshBillboards(); #if UNITY_EDITOR UnityEditor.EditorUtility.SetDirty(storage.PersistentVegetationStoragePackage); UnityEditor.EditorUtility.SetDirty(system); #endif }
/// <summary> /// Returns a unique list of all VegetationPackages used in the scene. /// </summary> /// <returns></returns> public static List <VegetationPackagePro> GetVegetationPackageList(BiomeType biomeType) { List <VegetationPackagePro> vegetationPackageList = new List <VegetationPackagePro>(); if (!Instance) { FindInstance(); } if (!Instance) { return(vegetationPackageList); } for (int i = 0; i <= Instance.VegetationSystemList.Count - 1; i++) { VegetationSystemPro vegetationSystemPro = Instance.VegetationSystemList[i]; if (vegetationSystemPro) { VegetationPackagePro vegetationPackagePro = vegetationSystemPro.GetVegetationPackageFromBiome(biomeType); if (vegetationPackagePro) { vegetationPackageList.Add(vegetationPackagePro); } } } return(vegetationPackageList); }
public static void SetTextures(VegetationSystemPro system, VegetationPackagePro package, Texture2D[] textures, int[] maskGroupNums, Rect terrainRect) { for (int i = 0; i < textures.Length; i++) { Texture2D tex = textures[i]; if (tex == null) { continue; } TextureMaskGroup maskGroup = package.TextureMaskGroupList[maskGroupNums[i]]; //creating new mask only if the mask with the same rect doesn't exist TextureMask mask = maskGroup.TextureMaskList.Find(m => m.TextureRect == terrainRect); if (mask == null) { mask = new TextureMask { TextureRect = terrainRect }; maskGroup.TextureMaskList.Add(mask); } mask.MaskTexture = tex; } //VegetationSystemPro system = GameObject.FindObjectOfType<VegetationSystemPro>(); //if (system != null) // system.ClearCache(); //clearing cache causes flickering system.RefreshTerrainHeightmap(); }
/// <summary> /// Returns a unique list of all VegetationPackages used in the scene. /// </summary> /// <returns></returns> public static List <VegetationPackagePro> GetAllVegetationPackageList() { List <VegetationPackagePro> vegetationPackageList = new List <VegetationPackagePro>(); if (!Instance) { FindInstance(); } if (!Instance) { return(vegetationPackageList); } for (int i = 0; i <= Instance.VegetationSystemList.Count - 1; i++) { VegetationSystemPro vegetationSystemPro = Instance.VegetationSystemList[i]; if (vegetationSystemPro) { vegetationPackageList.AddRange(vegetationSystemPro.VegetationPackageProList); } } return(vegetationPackageList); }
private void FindVegetationSystemPro() { if (!VegetationSystemPro) { VegetationSystemPro = GetComponent <VegetationSystemPro>(); } }
public ColliderManager(VisibleVegetationCellSelector visibleVegetationCellSelector, VegetationSystemPro vegetationSystemPro, VegetationItemInfoPro vegetationItemInfoPro, Transform colliderParent, bool showColliders) { _showColliders = showColliders; _vegetationSystemPro = vegetationSystemPro; _vegetationItemInfoPro = vegetationItemInfoPro; float cullingDistance = vegetationSystemPro.VegetationSettings.GetVegetationDistance() * vegetationItemInfoPro.ColliderDistanceFactor; VegetationItemSelector = new VegetationItemSelector(visibleVegetationCellSelector, vegetationSystemPro, vegetationItemInfoPro, false, 1, 0) { CullingDistance = cullingDistance }; VegetationItemSelector.OnVegetationItemVisibleDelegate += OnVegetationItemVisible; VegetationItemSelector.OnVegetationItemInvisibleDelegate += OnVegetationItemInvisible; VegetationItemSelector.OnVegetationCellInvisibleDelegate += OnVegetationCellInvisible; VegetationItemModelInfo vegetationItemModelInfo = vegetationSystemPro.GetVegetationItemModelInfo(vegetationItemInfoPro.VegetationItemID); ColliderPool = new ColliderPool(vegetationItemInfoPro, vegetationItemModelInfo, vegetationSystemPro, colliderParent, _showColliders); RuntimePrefabStorage = new RuntimePrefabStorage(ColliderPool); }
private static void AddBiomeMaskToVegetationSystem(VegetationSystemPro vegetationSystem, PolygonBiomeMask maskArea) { int biomeSortOrder = vegetationSystem.GetBiomeSortOrder(maskArea.BiomeType); maskArea.BiomeSortOrder = biomeSortOrder; Rect maskRect = RectExtension.CreateRectFromBounds(maskArea.MaskBounds); if (vegetationSystem.VegetationCellQuadTree != null && vegetationSystem.BillboardCellQuadTree != null) { List <VegetationCell> selectedCellList = new List <VegetationCell>(); vegetationSystem.VegetationCellQuadTree.Query(maskRect, selectedCellList); for (int i = 0; i <= selectedCellList.Count - 1; i++) { selectedCellList[i].AddBiomeMask(maskArea); } List <BillboardCell> selectedBillboardCellList = new List <BillboardCell>(); vegetationSystem.BillboardCellQuadTree.Query(maskRect, selectedBillboardCellList); for (int i = 0; i <= selectedBillboardCellList.Count - 1; i++) { selectedBillboardCellList[i].ClearCache(); } } }
private static void AddVegetationMaskToVegetationSystem(VegetationSystemPro vegetationSystem, BaseMaskArea maskArea) { vegetationSystem.CompleteCellLoading(); VegetationItemIndexes vegetationItemIndexes = new VegetationItemIndexes(); if (maskArea.VegetationItemID != "") { vegetationItemIndexes = vegetationSystem.GetVegetationItemIndexes(maskArea.VegetationItemID); } else { vegetationItemIndexes.VegetationPackageIndex = -1; vegetationItemIndexes.VegetationItemIndex = -1; } Rect maskRect = RectExtension.CreateRectFromBounds(maskArea.MaskBounds); if (vegetationSystem.VegetationCellQuadTree == null || vegetationSystem.BillboardCellQuadTree == null) { return; } List <VegetationCell> selectedCellList = new List <VegetationCell>(); vegetationSystem.VegetationCellQuadTree.Query(maskRect, selectedCellList); if (vegetationItemIndexes.VegetationPackageIndex > -1) { for (int i = 0; i <= selectedCellList.Count - 1; i++) { selectedCellList[i] .AddVegetationMask( maskArea, vegetationItemIndexes.VegetationPackageIndex, vegetationItemIndexes.VegetationItemIndex); } List <BillboardCell> selectedBillboardCellList = new List <BillboardCell>(); vegetationSystem.BillboardCellQuadTree.Query(maskRect, selectedBillboardCellList); for (int i = 0; i <= selectedBillboardCellList.Count - 1; i++) { selectedBillboardCellList[i].ClearCache(vegetationItemIndexes.VegetationPackageIndex, vegetationItemIndexes.VegetationItemIndex); } } else { for (int i = 0; i <= selectedCellList.Count - 1; i++) { selectedCellList[i].AddVegetationMask(maskArea); } List <BillboardCell> selectedBillboardCellList = new List <BillboardCell>(); vegetationSystem.BillboardCellQuadTree.Query(maskRect, selectedBillboardCellList); for (int i = 0; i <= selectedBillboardCellList.Count - 1; i++) { selectedBillboardCellList[i].ClearCache(); } } }
void RenderVegetationNow(VegetationSystemPro vegetationSystemPro, ShadowMaskCreator shadowMaskCreator) { Shader overrideShader = Shader.Find("AwesomeTechnologies/Shadows/ShadowHeight"); List <VegetationCell> processCellList = new List <VegetationCell>(); vegetationSystemPro.VegetationCellQuadTree.Query(shadowMaskCreator.AreaRect, processCellList); for (int i = 0; i <= vegetationSystemPro.VegetationPackageProList.Count - 1; i++) { for (int j = 0; j <= vegetationSystemPro.VegetationPackageProList[i].VegetationInfoList.Count - 1; j++) { VegetationItemInfoPro vegetationItemInfoPro = vegetationSystemPro.VegetationPackageProList[i].VegetationInfoList[j]; if (!RenderVegetationType(vegetationItemInfoPro.VegetationType, shadowMaskCreator)) { continue; } for (int k = 0; k <= processCellList.Count - 1; k++) { if (j % 10 == 0) { EditorUtility.DisplayProgressBar("Render vegetation item: " + vegetationItemInfoPro.Name, "Render cell " + k + "/" + (processCellList.Count - 1), k / ((float)processCellList.Count - 1)); } VegetationCell vegetationCell = processCellList[k]; string vegetationItemID = vegetationItemInfoPro.VegetationItemID; vegetationSystemPro.SpawnVegetationCell(vegetationCell, vegetationItemID); NativeList <MatrixInstance> vegetationInstanceList = vegetationSystemPro.GetVegetationItemInstances(vegetationCell, vegetationItemID); VegetationItemModelInfo vegetationItemModelInfo = vegetationSystemPro.GetVegetationItemModelInfo(vegetationItemID); for (int l = 0; l <= vegetationItemModelInfo.VegetationMeshLod0.subMeshCount - 1; l++) { vegetationItemModelInfo.VegetationMaterialsLOD0[l].SetFloat(CullFarStart, 50000); vegetationItemModelInfo.VegetationMaterialsLOD0[l].SetFloat(CullFarDistance, 20); } for (int l = 0; l <= vegetationItemModelInfo.VegetationMeshLod0.subMeshCount - 1; l++) { Material tempMaterial = new Material(vegetationItemModelInfo.VegetationMaterialsLOD0[l]); tempMaterial.shader = overrideShader; tempMaterial.SetPass(0); for (int m = 0; m <= vegetationInstanceList.Length - 1; m++) { Graphics.DrawMeshNow(vegetationItemModelInfo.VegetationMeshLod0, vegetationInstanceList[m].Matrix); } DestroyImmediate(tempMaterial); } } EditorUtility.ClearProgressBar(); } } }
// ReSharper disable once UnusedMember.Local void Reset() { VegetationSystemPro = GetComponent <VegetationSystemPro>(); if (VegetationSystemPro) { VegetationSystemPro.DetectPersistentVegetationStorage(); } }
public static void SetSceneDirty(VegetationSystemPro vegetationSystemPro) { if (!Application.isPlaying) { EditorSceneManager.MarkSceneDirty(vegetationSystemPro.gameObject.scene); EditorUtility.SetDirty(vegetationSystemPro); } }
public static void FlushObjects(Rect terrainRect, bool clearCache = true) { VegetationSystemPro system = GameObject.FindObjectOfType <VegetationSystemPro>(); if (system == null) { return; } PersistentVegetationStorage storage = system.PersistentVegetationStorage; PersistentVegetationStoragePackage storagePackage = system.PersistentVegetationStorage.PersistentVegetationStoragePackage; if (storagePackage == null) { return; } List <VegetationCell> overlapCellList = new List <VegetationCell>(); system.VegetationCellQuadTree.Query(terrainRect, overlapCellList); for (int i = 0; i < overlapCellList.Count; i++) { int cellIndex = overlapCellList[i].Index; //storagePackage.PersistentVegetationCellList[cellIndex].ClearCell(); var infoList = storagePackage.PersistentVegetationCellList[cellIndex].PersistentVegetationInfoList; for (int j = 0; j < infoList.Count; j++) { var itemList = infoList[j].VegetationItemList; for (int k = itemList.Count - 1; k >= 0; k--) { Vector3 pos = itemList[k].Position + system.VegetationSystemPosition; Vector2 pos2 = pos.V2(); if (terrainRect.Contains(pos2)) { itemList.RemoveAt(k); //storage.RemoveVegetationItemInstance(infoList[j].VegetationItemID, pos, 1, clearCellCache:false); } } } //VegetationItemIndexes indexes = VegetationSystemPro.GetVegetationItemIndexes(vegetationItemID); //system.ClearCache(overlapCellList[i],indexes.VegetationPackageIndex,indexes.VegetationItemIndex); } //if (clearCache) //{ // for (int i=0; i<system.VegetationCellList.Count; i++) // system.VegetationCellList[i].ClearCache(); //} system.RefreshBillboards(); }
public static void SetObjects(List <ObjectPool.Transition>[] allTransitions, string[] allIds) { if (system == null) { system = GameObject.FindObjectOfType <VegetationSystemPro>(); } if (system == null) { throw new System.Exception("MapMagic could not find Vegetation System in scene./n Add Window -> AwesomeTechnologies -> Vegetation System to scene"); } PersistentVegetationStorage storage = system.PersistentVegetationStorage; PersistentVegetationStoragePackage storagePackage = system.PersistentVegetationStorage.PersistentVegetationStoragePackage; if (storagePackage == null) { throw new System.Exception("Vegetation System has no storage package assigned to be used with MapMagic./nAssign a Persistent Vegetation Storage Package to Persistent Vegetation Storage component and initialize it."); } for (int i = 0; i < allTransitions.Length; i++) { if (allTransitions[i] == null) { continue; } var itemInfo = system.GetVegetationItemInfo(allIds[i]); if (itemInfo == null) { throw new System.Exception("Item applied by MapMagic is not present in Vegetation System storage"); } foreach (ObjectPool.Transition obj in allTransitions[i]) { storage.AddVegetationItemInstance( allIds[i], obj.pos, obj.scale, obj.rotation, applyMeshRotation: true, vegetationSourceID: VS_MM_id, distanceFalloff: 1, clearCellCache: true); } } //for (int i=0; i<system.VegetationCellList.Count; i++) // system.VegetationCellList[i].ClearCache(); //system.ClearCache(); system.RefreshBillboards(); #if UNITY_EDITOR UnityEditor.EditorUtility.SetDirty(storagePackage); UnityEditor.EditorUtility.SetDirty(system); #endif }
private void OnRenderComplete(VegetationSystemPro vegetationSystemPro) { if (PackageRuntimePrefabInfoList.Count == 0) { return; } TestFloatingOrigin(); UnityEngine.Profiling.Profiler.BeginSample("Runtime prefab system processing"); JobHandle cullingJobHandle = default(JobHandle); for (int i = 0; i <= PackageRuntimePrefabInfoList.Count - 1; i++) { VegetationPackageRuntimePrefabInfo packageRuntimePrefabInfo = PackageRuntimePrefabInfoList[i]; for (int j = 0; j <= packageRuntimePrefabInfo.RuntimePrefabManagerList.Count - 1; j++) { VegetationItemRuntimePrefabInfo vegetationItemRuntimePrefabInfo = packageRuntimePrefabInfo.RuntimePrefabManagerList[j]; for (int k = 0; k <= vegetationItemRuntimePrefabInfo.RuntimePrefabManagerList.Count - 1; k++) { RuntimePrefabManager runtimePrefabManager = vegetationItemRuntimePrefabInfo.RuntimePrefabManagerList[k]; if (runtimePrefabManager == null) { continue; } cullingJobHandle = runtimePrefabManager.VegetationItemSelector.ProcessInvisibleCells(cullingJobHandle); cullingJobHandle = runtimePrefabManager.VegetationItemSelector.ProcessVisibleCells(cullingJobHandle); cullingJobHandle = runtimePrefabManager.VegetationItemSelector.ProcessCulling(cullingJobHandle); } } } cullingJobHandle.Complete(); for (int i = 0; i <= PackageRuntimePrefabInfoList.Count - 1; i++) { VegetationPackageRuntimePrefabInfo packageRuntimePrefabInfo = PackageRuntimePrefabInfoList[i]; for (int j = 0; j <= packageRuntimePrefabInfo.RuntimePrefabManagerList.Count - 1; j++) { VegetationItemRuntimePrefabInfo vegetationItemRuntimePrefabInfo = packageRuntimePrefabInfo.RuntimePrefabManagerList[j]; for (int k = 0; k <= vegetationItemRuntimePrefabInfo.RuntimePrefabManagerList.Count - 1; k++) { RuntimePrefabManager runtimePrefabManager = vegetationItemRuntimePrefabInfo.RuntimePrefabManagerList[k]; runtimePrefabManager?.VegetationItemSelector.ProcessEvents(); } } } UnityEngine.Profiling.Profiler.EndSample(); }
// public VisibleVegetationCellSelector() // { // // } public void Init(VegetationSystemPro vegetationSystemPro) { _vegetationSystemPro = vegetationSystemPro; _vegetationSystemPro.OnAddCameraDelegate += OnAddCamera; _vegetationSystemPro.OnAddCameraDelegate += OnRemoveCamera; AddVisibleVegetationCells(); }
public RuntimePrefabPool(RuntimePrefabRule runtimePrefabRule, VegetationItemInfoPro vegetationItemInfoPro, Transform prefabParent, bool showPrefabsInHierarchy, VegetationSystemPro vegetationSystemPro) { _vegetationSystemPro = vegetationSystemPro; _vegetationItemInfoPro = vegetationItemInfoPro; _prefabParent = prefabParent; _showPrefabsInHierarchy = showPrefabsInHierarchy; _runtimePrefabRule = runtimePrefabRule; }
void Reset() { VegetationSystemPro vegetationSystemPro = this.GetComponent <VegetationSystemPro>(); if (vegetationSystemPro) { AreaRect = RectExtension.CreateRectFromBounds(vegetationSystemPro.VegetationSystemBounds); } }
public void OnGUI(Layout layout, bool selected, int num, object parent) { #if VEGETATION_STUDIO_PRO VSProObjectsOutput vsOut = (VSProObjectsOutput)parent; VegetationPackagePro package = vsOut.package; //(VegetationPackagePro)vsOut.serializedPackage; VegetationSystemPro system = GameObject.FindObjectOfType <VegetationSystemPro>(); Layer layer = vsOut.baseLayers[num]; layout.margin = 20; layout.rightMargin = 5; layout.Par(20); input.DrawIcon(layout); if (package != null) { int itemInfoIndex = package.VegetationInfoList.FindIndex(i => i.VegetationItemID == layer.id); VegetationItemInfoPro itemInfo = itemInfoIndex >= 0 ? package.VegetationInfoList[itemInfoIndex] : null; Texture2D icon = null; if (itemInfo != null) { #if UNITY_EDITOR if (itemInfo.PrefabType == VegetationPrefabType.Mesh) { icon = AssetPreviewCache.GetAssetPreview(itemInfo.VegetationPrefab); } else { icon = AssetPreviewCache.GetAssetPreview(itemInfo.VegetationTexture); } #endif } layout.Icon(icon, rect: layout.Inset(20), frame: true, alphaBlend: false); layout.Inset(10); itemInfoIndex = layout.Popup(itemInfoIndex, objectNames, rect: layout.Inset(layout.field.width - 20 - 45)); if (itemInfoIndex >= 0) { layer.id = package.VegetationInfoList[itemInfoIndex].VegetationItemID; } } if (selected) { layout.Toggle(ref relativeHeight, "Relative Height"); layout.Toggle(ref rotate, "Rotate"); layout.Toggle(ref takeTerrainNormal, "Incline by Terrain"); layout.Par(); layout.Toggle(ref scale, "Scale", rect: layout.Inset(60)); layout.disabled = !scale; layout.Toggle(ref scaleY, rect: layout.Inset(18)); layout.Label("Y only", rect: layout.Inset(45)); //if (layout.lastChange) scaleU = false; layout.disabled = false; } #endif }
public void RemoveUnityTerrain() { if (system == null) { system = GameObject.FindObjectOfType <VegetationSystemPro>(); } if (system != null) { system.RemoveTerrain(gameObject); } }
public static void OnVegetationCellRefresh(VegetationSystemPro vegetationSystem) { if (!Instance) { FindInstance(); } if (Instance) { Instance.Internal_OnVegetationCellRefresh(vegetationSystem); } }
private void OnClearCacheVegetationCell(VegetationSystemPro vegetationSystemPro, VegetationCell vegetationCell) { for (int i = 0; i <= PackageColliderInfoList.Count - 1; i++) { VegetationPackageColliderInfo vegetationPackageColliderInfo = PackageColliderInfoList[i]; for (int j = 0; j <= vegetationPackageColliderInfo.ColliderManagerList.Count - 1; j++) { ColliderManager colliderManager = vegetationPackageColliderInfo.ColliderManagerList[j]; colliderManager?.VegetationItemSelector.RefreshVegetationCell(vegetationCell); } } }
/// <summary> /// Internal function used by VegetationSystem components to unregister with the manager /// </summary> /// <param name="vegetationSystem"></param> public static void UnregisterVegetationSystem(VegetationSystemPro vegetationSystem) { if (!Instance) { FindInstance(); } if (Instance) { Instance.Instance_UnregisterVegetationSystem(vegetationSystem); } }
/// <summary> /// Internal function used by VegetationSystem components to register with the manager /// </summary> /// <param name="vegetationSystem"></param> protected void Instance_RegisterVegetationSystem(VegetationSystemPro vegetationSystem) { if (!VegetationSystemList.Contains(vegetationSystem)) { VegetationSystemList.Add(vegetationSystem); OnAddVegetationSystem(vegetationSystem); if (OnAddVegetationSystemDelegate != null) { OnAddVegetationSystemDelegate(vegetationSystem); } } }
public void Internal_OnVegetationCellRefresh(VegetationSystemPro vegetationSystem) { for (int i = 0; i <= _biomeMaskList.Count - 1; i++) { AddBiomeMaskToVegetationSystem(vegetationSystem, _biomeMaskList[i]); } for (int i = 0; i <= _vegetationMaskList.Count - 1; i++) { AddVegetationMaskToVegetationSystem(vegetationSystem, _vegetationMaskList[i]); } }
private void OnRenderComplete(VegetationSystemPro vegetationSystemPro) { if (PackageColliderInfoList.Count == 0) { return; } TestFloatingOrigin(); Profiler.BeginSample("Collider system processing"); JobHandleList.Clear(); JobHandle cullingJobHandle = default(JobHandle); for (int i = 0; i <= PackageColliderInfoList.Count - 1; i++) { VegetationPackageColliderInfo vegetationPackageColliderInfo = PackageColliderInfoList[i]; for (int j = 0; j <= vegetationPackageColliderInfo.ColliderManagerList.Count - 1; j++) { ColliderManager colliderManager = vegetationPackageColliderInfo.ColliderManagerList[j]; if (colliderManager == null) { continue; } JobHandle itemCullingHandle = cullingJobHandle; itemCullingHandle = colliderManager.VegetationItemSelector.ProcessInvisibleCells(itemCullingHandle); itemCullingHandle = colliderManager.VegetationItemSelector.ProcessVisibleCells(itemCullingHandle); itemCullingHandle = colliderManager.VegetationItemSelector.ProcessCulling(itemCullingHandle); JobHandleList.Add(itemCullingHandle); } } JobHandle mergedHandle = JobHandle.CombineDependencies(JobHandleList); mergedHandle.Complete(); for (int i = 0; i <= PackageColliderInfoList.Count - 1; i++) { VegetationPackageColliderInfo vegetationPackageColliderInfo = PackageColliderInfoList[i]; for (int j = 0; j <= vegetationPackageColliderInfo.ColliderManagerList.Count - 1; j++) { ColliderManager colliderManager = vegetationPackageColliderInfo.ColliderManagerList[j]; colliderManager?.VegetationItemSelector.ProcessEvents(); } } Profiler.EndSample(); }
private void OnClearCacheVegetationItem(VegetationSystemPro vegetationSystemPro, int vegetationPackageIndex, int vegetationItemIndex) { for (int i = 0; i <= PackageColliderInfoList.Count - 1; i++) { VegetationPackageColliderInfo vegetationPackageColliderInfo = PackageColliderInfoList[i]; for (int j = 0; j <= vegetationPackageColliderInfo.ColliderManagerList.Count - 1; j++) { if (i == vegetationPackageIndex && j == vegetationItemIndex) { ColliderManager colliderManager = vegetationPackageColliderInfo.ColliderManagerList[j]; colliderManager?.VegetationItemSelector.RefreshAllVegetationCells(); } } } }
public static void RefreshVegetation() { VegetationStudioManager VegetationStudioInstance = FindVegetationStudioInstance(); List <VegetationSystemPro> VegetationSystemList = VegetationStudioInstance.VegetationSystemList; for (int i = 0; i <= VegetationSystemList.Count - 1; i++) { VegetationSystemPro vegetationSystemPro = VegetationSystemList[i]; vegetationSystemPro.ClearCache(); vegetationSystemPro.RefreshTerrainHeightmap(); SceneView.RepaintAll(); SetSceneDirty(vegetationSystemPro); } }