Ejemplo n.º 1
0
        public void UpdateCulling(GaiaSettings gaiaSettings)
        {
            if (!GaiaUtils.CheckIfSceneProfileExists())
            {
                return;
            }
            if (GaiaGlobal.Instance.m_mainCamera == null)
            {
                GaiaGlobal.Instance.m_mainCamera = GaiaUtils.GetCamera();
            }

            float farClipPlane = 2000f;

            if (GaiaGlobal.Instance.m_mainCamera != null)
            {
                farClipPlane = GaiaGlobal.Instance.m_mainCamera.farClipPlane;
            }

            if (GaiaGlobal.Instance.SceneProfile.m_sunLight == null)
            {
                GaiaGlobal.Instance.SceneProfile.m_sunLight = GaiaUtils.GetMainDirectionalLight();
            }

            Terrain terrain = TerrainHelper.GetActiveTerrain();

            //Objects
            m_layerDistances = new float[32];
            for (int i = 0; i < m_layerDistances.Length; i++)
            {
                string layerName = LayerMask.LayerToName(i);
                switch (layerName)
                {
                case "Default":
                case "Water":
                case "PW_VFX":
                    m_layerDistances[i] = 0f;
                    break;

                case "PW_Object_Small":
                    m_layerDistances[i] = GaiaUtils.CalculateCameraCullingLayerValue(terrain, gaiaSettings.m_currentEnvironment, 5f);
                    break;

                case "PW_Object_Medium":
                    m_layerDistances[i] = GaiaUtils.CalculateCameraCullingLayerValue(terrain, gaiaSettings.m_currentEnvironment, 3f);
                    break;

                case "PW_Object_Large":
                    m_layerDistances[i] = GaiaUtils.CalculateCameraCullingLayerValue(terrain, gaiaSettings.m_currentEnvironment);
                    break;

                default:
                    m_layerDistances[i] = 0f;
                    break;
                }
            }
        }