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 (ISerializedFile file in File.Collection.Files) { foreach (Object asset in file.FetchAssets()) { if (asset.ClassID == ClassIDType.OcclusionCullingSettings) { OcclusionCullingSettings cullingSetting = (OcclusionCullingSettings)asset; if (Scenes.Any(t => t.Scene == cullingSetting.SceneGUID)) { 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); } }
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); }
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); } }