예제 #1
0
        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();
        }
예제 #2
0
        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();
        }
예제 #3
0
        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);
                    }
                }
            }
        }
예제 #4
0
        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();
                    }
                }
            }
        }
예제 #5
0
        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);
                    }
                }
            }
        }
예제 #6
0
        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);
                    }
                }
            }
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        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();
                        }
                    }
                }
            }
        }