Esempio n. 1
0
        public void DisposeColliderSystem()
        {
            if (JobHandleList.IsCreated)
            {
                JobHandleList.Dispose();
            }

            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)
                    {
                        colliderManager.OnCreateColliderDelegate        -= OnCreateCollider;
                        colliderManager.OnBeforeDestroyColliderDelegate -= OnBeforeDestroyCollider;
                    }
                    colliderManager?.Dispose();
                }

                vegetationPackageColliderInfo.ColliderManagerList.Clear();
            }
            PackageColliderInfoList.Clear();
            VisibleVegetationCellSelector?.Dispose();
            VisibleVegetationCellSelector = null;
            DestroyColliderParent();
        }
Esempio n. 2
0
 void UpdateFloatingOrigin(Vector3 deltaFloatingOriginOffset)
 {
     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?.RuntimePrefabStorage.UpdateFloatingOrigin(deltaFloatingOriginOffset);
         }
     }
 }
Esempio n. 3
0
 public void UpdateCullingDistance()
 {
     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?.UpdateColliderDistance();
         }
     }
 }
Esempio n. 4
0
 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);
         }
     }
 }
Esempio n. 5
0
 public void SetColliderVisibility(bool value)
 {
     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?.SetColliderVisibility(value);
         }
     }
 }
Esempio n. 6
0
        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();
        }
Esempio n. 7
0
 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();
             }
         }
     }
 }
Esempio n. 8
0
        public int GetVisibleColliders()
        {
            int instanceCount = 0;

            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)
                    {
                        instanceCount += colliderManager.RuntimePrefabStorage.RuntimePrefabInfoList.Count;
                    }
                }
            }
            return(instanceCount);
        }
Esempio n. 9
0
        public int GetLoadedInstanceCount()
        {
            int instanceCount = 0;

            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)
                    {
                        instanceCount += colliderManager.VegetationItemSelector.InstanceList.Length;
                    }
                }
            }
            return(instanceCount);
        }
Esempio n. 10
0
        public void SetupColliderSystem()
        {
            if (!VegetationSystemPro)
            {
                return;
            }

            DisposeColliderSystem();

            JobHandleList = new NativeList <JobHandle>(64, Allocator.Persistent);

            CreateColliderParent();

            VisibleVegetationCellSelector = new VisibleVegetationCellSelector();

            for (int i = 0; i <= VegetationSystemPro.VegetationPackageProList.Count - 1; i++)
            {
                VegetationPackagePro          vegetationPackagePro          = VegetationSystemPro.VegetationPackageProList[i];
                VegetationPackageColliderInfo vegetationPackageColliderInfo = new VegetationPackageColliderInfo();

                for (int j = 0; j <= vegetationPackagePro.VegetationInfoList.Count - 1; j++)
                {
                    VegetationItemInfoPro vegetationItemInfoPro = vegetationPackagePro.VegetationInfoList[j];
                    if (vegetationItemInfoPro.ColliderType != ColliderType.Disabled)
                    {
                        ColliderManager tmpColliderManager = new ColliderManager(VisibleVegetationCellSelector, VegetationSystemPro, vegetationItemInfoPro, _colliderParent, ShowColliders);
                        tmpColliderManager.OnCreateColliderDelegate        += OnCreateCollider;
                        tmpColliderManager.OnBeforeDestroyColliderDelegate += OnBeforeDestroyCollider;

                        vegetationPackageColliderInfo.ColliderManagerList.Add(tmpColliderManager);
                    }
                    else
                    {
                        vegetationPackageColliderInfo.ColliderManagerList.Add(null);
                    }
                }

                PackageColliderInfoList.Add(vegetationPackageColliderInfo);
            }
            VisibleVegetationCellSelector.Init(VegetationSystemPro);
        }
Esempio n. 11
0
        public void BakeCollidersToScene()
        {
            for (int i = 0; i <= PackageColliderInfoList.Count - 1; i++)
            {
                VegetationPackageColliderInfo vegetationPackageColliderInfo = PackageColliderInfoList[i];
                VegetationPackagePro          vegetationPackagePro          = VegetationSystemPro.VegetationPackageProList[i];
                for (int j = 0; j <= vegetationPackageColliderInfo.ColliderManagerList.Count - 1; j++)
                {
                    VegetationItemInfoPro vegetationItemInfoPro = vegetationPackagePro.VegetationInfoList[j];
                    if (!vegetationItemInfoPro.ColliderUseForBake)
                    {
                        continue;
                    }

                    ColliderManager colliderManager = vegetationPackageColliderInfo.ColliderManagerList[j];
                    if (colliderManager != null)
                    {
                        BakeVegetationItemColliders(colliderManager, vegetationItemInfoPro);
                    }
                }
            }
        }