private void InitializeTerrainDb(bool useTerrainDetailFileCache = false) { var ultraUpdatableContainer = new UltraUpdatableContainer(new MyUtSchedulerConfiguration(), new GlobalServicesProfileInfo(), new UltraUpdatableContainerConfiguration()); var feConfiguration = new FEConfiguration(new FilePathsConfiguration()); var feGRingConfiguration = new FeGRingConfiguration(); feGRingConfiguration.FeConfiguration = feConfiguration; feConfiguration.TerrainShapeDbConfiguration.UseTextureSavingToDisk = useTerrainDetailFileCache; feConfiguration.TerrainShapeDbConfiguration.UseTextureLoadingFromDisk = useTerrainDetailFileCache; feConfiguration.EngraveRoadsInTerrain = false; TaskUtils.SetGlobalMultithreading(feConfiguration.Multithreading); TaskUtils.SetMultithreadingOverride(true); _gameInitializationFields.SetField(feConfiguration.Repositioner); _gameInitializationFields.SetField(feConfiguration.HeightDenormalizer); var initializingHelper = new FEInitializingHelper(_gameInitializationFields, ultraUpdatableContainer, feConfiguration); initializingHelper.InitializeUTService(new TextureConcieverUTProxy()); initializingHelper.InitializeUTService(new UnityThreadComputeShaderExecutorObject()); initializingHelper.InitializeUTService(new CommonExecutorUTProxy()); initializingHelper.InitializeUTRendererProxy(); var finalTerrainShapeDb = new FETerrainShapeDbInitialization(ultraUpdatableContainer, _gameInitializationFields, feConfiguration, _filePathsConfiguration); finalTerrainShapeDb.Start(); }
public static UltraUpdatableContainer InitializeFinalElements(FEConfiguration configuration, ComputeShaderContainerGameObject containerGameObject, GameInitializationFields gameInitializationFields, Dictionary <int, Ring2RegionsDbGeneratorConfiguration> ring2RegionsDatabasesConfiguration = null , bool initializeLegacyDesignBodySpotUpdater = false) { TaskUtils.SetGlobalMultithreading(configuration.Multithreading); return(TaskUtils.ExecuteFunctionWithOverridenMultithreading(true, () => { var servicesProfileInfo = new GlobalServicesProfileInfo(); gameInitializationFields.SetField(servicesProfileInfo); var ultraUpdatableContainer = new UltraUpdatableContainer( configuration.SchedulerConfiguration, servicesProfileInfo, configuration.UpdatableContainerConfiguration); configuration.TerrainShapeDbConfiguration.UseTextureSavingToDisk = true; gameInitializationFields.SetField(containerGameObject); gameInitializationFields.SetField(configuration.Repositioner); gameInitializationFields.SetField(configuration.HeightDenormalizer); var initializingHelper = new FEInitializingHelper(gameInitializationFields, ultraUpdatableContainer, configuration); initializingHelper.InitializeUTService(new TextureConcieverUTProxy()); initializingHelper.InitializeUTService(new UnityThreadComputeShaderExecutorObject()); initializingHelper.InitializeUTService(new CommonExecutorUTProxy()); initializingHelper.CreatePathProximityTextureDb(); if (initializeLegacyDesignBodySpotUpdater) { initializingHelper.InitializeDesignBodySpotUpdater(); } initializingHelper.InitializeUTRendererProxy(); initializingHelper.InitializeUTService(new MeshGeneratorUTProxy(new MeshGeneratorService())); if (ring2RegionsDatabasesConfiguration != null) { initializingHelper.InitializeComplexRing2RegionsDatabase(ring2RegionsDatabasesConfiguration); } else { initializingHelper.InitializeMonoliticRing2RegionsDatabase(); } //var finalTerrainInitialization = new FinalTerrainInitialization(_ultraUpdatableContainer, _gameInitializationFields, _configuration, FeGRingConfiguration); //finalTerrainInitialization.Start(); initializingHelper.InitializeGlobalInstancingContainer(); //var finalVegetation = new FinalVegetation(_gameInitializationFields, _ultraUpdatableContainer, VegetationConfiguration); //finalVegetation.Start(); return ultraUpdatableContainer; })); }
private FEInitializingHelper InitializeETerrain(ETerrainHeightPyramidFacadeStartConfiguration startConfiguration) { startConfiguration.CommonConfiguration.YScale = _gameInitializationFields.Retrive <HeightDenormalizer>().DenormalizationMultiplier; startConfiguration.HeightPyramidLevels = new List <HeightPyramidLevel>() { HeightPyramidLevel.Top, HeightPyramidLevel.Mid, HeightPyramidLevel.Bottom }; var buffersManager = new ETerrainHeightBuffersManager(); _eTerrainHeightPyramidFacade = new ETerrainHeightPyramidFacade(buffersManager, _gameInitializationFields.Retrive <MeshGeneratorUTProxy>(), _gameInitializationFields.Retrive <UTTextureRendererProxy>(), startConfiguration); var perLevelTemplates = _eTerrainHeightPyramidFacade.GenerateLevelTemplates(); var levels = startConfiguration.PerLevelConfigurations.Keys.Where(c => startConfiguration.HeightPyramidLevels.Contains(c)); buffersManager.InitializeBuffers(levels.ToDictionary(c => c, c => new EPyramidShaderBuffersGeneratorPerRingInput() { FloorTextureResolution = startConfiguration.CommonConfiguration.FloorTextureSize.X, //TODO i use only X, - works only for squares HeightMergeRanges = perLevelTemplates[c].PerRingTemplates.ToDictionary(k => k.Key, k => k.Value.HeightMergeRange), CeilSliceWorldSize = startConfiguration.PerLevelConfigurations[c].FloorTextureWorldSize.x, // TODO works only for square pyramids - i use width RingUvRanges = startConfiguration.CommonConfiguration.RingsUvRange }), startConfiguration.CommonConfiguration.MaxLevelsCount, startConfiguration.CommonConfiguration.MaxRingsPerLevelCount); var dbInitialization = new FETerrainShapeDbInitialization(_ultraUpdatableContainer, _gameInitializationFields, _feConfiguration, new FilePathsConfiguration()); dbInitialization.Start(); var initializingHelper = new FEInitializingHelper(_gameInitializationFields, _ultraUpdatableContainer, _feConfiguration); initializingHelper.InitializeGlobalInstancingContainer(); _eTerrainHeightPyramidFacade.Start(perLevelTemplates, new Dictionary <EGroundTextureType, OneGroundTypeLevelTextureEntitiesGenerator> { [EGroundTextureType.HeightMap] = ETerrainInitializationHelper.CreateHeightTextureEntitiesGenerator( startConfiguration, _gameInitializationFields, _ultraUpdatableContainer, _heightmapListenersContainer), [EGroundTextureType.SurfaceTexture] = ETerrainInitializationHelper.CreateSurfaceTextureEntitiesGenerator( _feConfiguration, startConfiguration, _gameInitializationFields, _ultraUpdatableContainer) } ); return(initializingHelper); }