public void DisposeRuntimePrefabSystem() { 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?.Dispose(); } } packageRuntimePrefabInfo.RuntimePrefabManagerList.Clear(); } PackageRuntimePrefabInfoList.Clear(); VisibleVegetationCellSelector?.Dispose(); VisibleVegetationCellSelector = null; DestroyRuntimePrefabParent(); }
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 void SetRuntimePrefabVisibility(bool value) { 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?.SetRuntimePrefabVisibility(value); } } } }
public void UpdateCullingDistance() { 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?.UpdateRuntimePrefabDistance(); } } } }
private void OnClearCacheVegetationCell(VegetationSystemPro vegetationSystemPro, VegetationCell vegetationCell) { 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.RefreshVegetationCell(vegetationCell); } } } }
void UpdateFloatingOrigin(Vector3 deltaFloatingOriginOffset) { 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?.RuntimePrefabStorage.UpdateFloatingOrigin(deltaFloatingOriginOffset); } } } }
public void SetupRuntimePrefabSystem() { if (!VegetationSystemPro) { return; } DisposeRuntimePrefabSystem(); CreateRuntimePrefabParent(); VisibleVegetationCellSelector = new VisibleVegetationCellSelector(); for (int i = 0; i <= VegetationSystemPro.VegetationPackageProList.Count - 1; i++) { VegetationPackagePro vegetationPackagePro = VegetationSystemPro.VegetationPackageProList[i]; VegetationPackageRuntimePrefabInfo vegetationPackageRuntimePrefabInfo = new VegetationPackageRuntimePrefabInfo(); for (int j = 0; j <= vegetationPackagePro.VegetationInfoList.Count - 1; j++) { VegetationItemInfoPro vegetationItemInfoPro = vegetationPackagePro.VegetationInfoList[j]; VegetationItemRuntimePrefabInfo vegetationItemRuntimePrefabInfo = new VegetationItemRuntimePrefabInfo(); for (int k = 0; k <= vegetationItemInfoPro.RuntimePrefabRuleList.Count - 1; k++) { RuntimePrefabRule runtimePrefabRule = vegetationItemInfoPro.RuntimePrefabRuleList[k]; RuntimePrefabManager runtimePrefabManager = new RuntimePrefabManager(VisibleVegetationCellSelector, VegetationSystemPro, vegetationItemInfoPro, runtimePrefabRule, _runtimePrefabParent, ShowRuntimePrefabs); vegetationItemRuntimePrefabInfo.RuntimePrefabManagerList.Add(runtimePrefabManager); } vegetationPackageRuntimePrefabInfo.RuntimePrefabManagerList.Add(vegetationItemRuntimePrefabInfo); } PackageRuntimePrefabInfoList.Add(vegetationPackageRuntimePrefabInfo); } VisibleVegetationCellSelector.Init(VegetationSystemPro); }
public int GetVisibleColliders() { int instanceCount = 0; 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]; instanceCount += runtimePrefabManager.RuntimePrefabStorage.RuntimePrefabInfoList.Count; } } } return(instanceCount); }
public int GetLoadedInstanceCount() { int instanceCount = 0; 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]; instanceCount += runtimePrefabManager.VegetationItemSelector.InstanceList.Length; } } } return(instanceCount); }
private void OnClearCacheVegetationItem(VegetationSystemPro vegetationSystemPro, int vegetationPackageIndex, int vegetationItemIndex) { for (int i = 0; i <= PackageRuntimePrefabInfoList.Count - 1; i++) { VegetationPackageRuntimePrefabInfo packageRuntimePrefabInfo = PackageRuntimePrefabInfoList[i]; for (int j = 0; j <= packageRuntimePrefabInfo.RuntimePrefabManagerList.Count - 1; j++) { if (i == vegetationPackageIndex && j == vegetationItemIndex) { VegetationItemRuntimePrefabInfo vegetationItemRuntimePrefabInfo = packageRuntimePrefabInfo.RuntimePrefabManagerList[j]; for (int k = 0; k <= vegetationItemRuntimePrefabInfo.RuntimePrefabManagerList.Count - 1; k++) { RuntimePrefabManager runtimePrefabManager = vegetationItemRuntimePrefabInfo.RuntimePrefabManagerList[k]; runtimePrefabManager?.VegetationItemSelector.RefreshAllVegetationCells(); } } } } }