Пример #1
0
        private void SetExportData(IExportContainer container)
        {
            // if < 3.0.0 this asset doesn't exist

            // 3.0.0 to 5.5.0 this asset is created by culling settings so it has set data already
            if (OcclusionCullingSettings.IsReadPVSData(container.Version))
            {
                return;
            }

            // if >= 5.5.0 and !Release this asset containts renderer data
            if (IsReadStaticRenderers(container.Flags))
            {
                return;
            }

            // if >= 5.5.0 and Release this asset doesn't containt renderers data so we need to create it
            List <OcclusionCullingSettings> cullingSettings = new List <OcclusionCullingSettings>();

            foreach (Object asset in File.Collection.FetchAssets())
            {
                if (asset.ClassID == ClassIDType.OcclusionCullingSettings)
                {
                    OcclusionCullingSettings cullingSetting = (OcclusionCullingSettings)asset;
                    if (cullingSetting.OcclusionCullingData.IsAsset(cullingSetting.File, this))
                    {
                        cullingSettings.Add(cullingSetting);
                    }
                }
            }

            int maxRenderer = Scenes.Max(j => j.IndexRenderers + j.SizeRenderers);

            m_staticRenderers = new SceneObjectIdentifier[maxRenderer];
            int maxPortal = Scenes.Max(j => j.IndexPortals + j.SizePortals);

            m_portals = new SceneObjectIdentifier[maxPortal];

            foreach (OcclusionCullingSettings cullingSetting in cullingSettings)
            {
                int sceneIndex = Scenes.IndexOf(t => t.Scene == cullingSetting.SceneGUID);
                if (sceneIndex == -1)
                {
                    Logger.Log(LogType.Error, LogCategory.Export, $"Unable to find scene data with GUID {cullingSetting.SceneGUID} in {ValidName}");
                    continue;
                }

                OcclusionScene scene = Scenes[sceneIndex];
                if (scene.SizeRenderers != cullingSetting.StaticRenderers.Count)
                {
                    throw new Exception($"Scene renderer count {scene.SizeRenderers} doesn't match with given {cullingSetting.StaticRenderers.Count}");
                }
                if (scene.SizePortals != cullingSetting.Portals.Count)
                {
                    throw new Exception($"Scene portal count {scene.SizePortals} doesn't match with given {cullingSetting.Portals.Count}");
                }
                SetIDs(container, cullingSetting, scene);
            }
        }
Пример #2
0
        private void SetExportData(IExportContainer container)
        {
            // if < 3.0.0 this asset doesn't exist

            // 3.0.0 to 5.5.0 this asset is created by culling settings so it has set data already
            if (OcclusionCullingSettings.IsReadPVSData(container.Version))
            {
                return;
            }

            // if >= 5.5.0 and !Release this asset containts renderer data
            if (IsReadStaticRenderers(container.Flags))
            {
                return;
            }

            // if >= 5.5.0 and Release this asset doesn't containt renderers data so we need to create it
            List <OcclusionCullingSettings> cullingSettings = new List <OcclusionCullingSettings>();

            foreach (Object asset in File.Collection.FetchAssets())
            {
                if (asset.ClassID == ClassIDType.OcclusionCullingSettings)
                {
                    OcclusionCullingSettings cullingSetting = (OcclusionCullingSettings)asset;
                    if (cullingSetting.OcclusionCullingData.IsAsset(cullingSetting.File, this))
                    {
                        cullingSettings.Add(cullingSetting);
                    }
                }
            }

            int            maxRenderer = Scenes.Max(j => j.IndexRenderers);
            OcclusionScene rscene      = Scenes.First(t => t.IndexRenderers == maxRenderer);

            m_staticRenderers = new SceneObjectIdentifier[rscene.IndexRenderers + rscene.SizeRenderers];

            int            maxPortal = Scenes.Max(j => j.IndexPortals);
            OcclusionScene pscene    = Scenes.First(t => t.IndexPortals == maxPortal);

            m_portals = new SceneObjectIdentifier[pscene.IndexPortals + pscene.SizePortals];

            foreach (OcclusionCullingSettings cullingSetting in cullingSettings)
            {
                OcclusionScene scene = Scenes.First(t => t.Scene == cullingSetting.SceneGUID);
                if (scene.SizeRenderers != cullingSetting.StaticRenderers.Count)
                {
                    throw new Exception($"Scene renderer count {scene.SizeRenderers} doesn't match with given {cullingSetting.StaticRenderers.Count}");
                }
                if (scene.SizePortals != cullingSetting.Portals.Count)
                {
                    throw new Exception($"Scene portal count {scene.SizePortals} doesn't match with given {cullingSetting.Portals.Count}");
                }
                SetIDs(container, cullingSetting, scene);
            }
        }
Пример #3
0
        public void Initialize(IExportContainer container, OcclusionCullingSettings cullingSetting)
        {
            m_PVSData = (byte[])cullingSetting.PVSData;
            int            renderCount = cullingSetting.StaticRenderers.Count;
            int            portalCount = cullingSetting.Portals.Count;
            OcclusionScene scene       = new OcclusionScene(cullingSetting.SceneGUID, renderCount, portalCount);

            m_scenes = new OcclusionScene[] { scene };

            m_staticRenderers = new SceneObjectIdentifier[scene.SizeRenderers];
            m_portals         = new SceneObjectIdentifier[scene.SizePortals];
            SetIDs(container, cullingSetting, scene);
        }
Пример #4
0
        private void SetIDs(IExportContainer container, OcclusionCullingSettings cullingSetting, OcclusionScene scene)
        {
            for (int i = 0; i < cullingSetting.StaticRenderers.Count; i++)
            {
                PPtr <Renderer> prenderer = cullingSetting.StaticRenderers[i];
                Renderer        renderer  = prenderer.FindAsset(cullingSetting.File);
                m_staticRenderers[scene.IndexRenderers + i] = CreateObjectID(container, renderer);
            }

            for (int i = 0; i < cullingSetting.Portals.Count; i++)
            {
                PPtr <OcclusionPortal> pportal = cullingSetting.Portals[i];
                OcclusionPortal        portal  = pportal.FindAsset(cullingSetting.File);
                m_portals[scene.IndexPortals + i] = CreateObjectID(container, portal);
            }
        }
Пример #5
0
 public static OcclusionCullingData CreateVirtualInstance(VirtualSerializedFile virtualFile, OcclusionCullingSettings cullingSetting)
 {
     return(virtualFile.CreateAsset((assetInfo) => new OcclusionCullingData(assetInfo, cullingSetting)));
 }
Пример #6
0
 private OcclusionCullingData(AssetInfo assetInfo, OcclusionCullingSettings cullingSetting) :
     base(assetInfo, true)
 {
     Name = nameof(OcclusionCullingData);
 }