public EPropElevationManager(CommonExecutorUTProxy commonExecutor, UnityThreadComputeShaderExecutorObject shaderExecutorObject, EPropElevationConfiguration configuration, EPropConstantPyramidParameters constantPyramidParameters) { _configuration = configuration; _localeBufferManager = new EPropLocaleBufferManager(commonExecutor, shaderExecutorObject, configuration, constantPyramidParameters); _pointersOccupancyContainer = new EPropElevationLocalePointersOccupancyContainer(configuration); }
public EPropLocaleBufferScopeRegistry(EPropElevationConfiguration configuration) { _configuration = configuration; _localeArray = ConstantSizeClaimableContainer <Vector2?> .CreateEmpty(configuration.ScopeLength); _updateOrders = new List <EPropLocaleBufferScopeUpdateOrder>(); }
public EPropLocaleBufferManager(CommonExecutorUTProxy commonExecutor, UnityThreadComputeShaderExecutorObject shaderExecutorObject, EPropElevationConfiguration configuration , EPropConstantPyramidParameters constantPyramidParameters) { _shaderExecutorObject = shaderExecutorObject; _configuration = configuration; _commonExecutor = commonExecutor; _constantPyramidParameters = constantPyramidParameters; _scopes = new EPropLocaleBufferScopeRegistry[configuration.MaxScopesCount]; }
private ConstantSizeClaimableContainer <object> _pointersContainer; //todo possible much less space taking data structure public EPropElevationLocalePointersOccupancyContainer(EPropElevationConfiguration configuration) { _pointersContainer = ConstantSizeClaimableContainer <object> .CreateEmpty(configuration.MaxLocalePointersCount); _pointerIdDict = new DoubleDictionary <EPropElevationId, EPropElevationPointer>(); }
public void Start() { UnityEngine.Random.InitState(412); TaskUtils.SetGlobalMultithreading(false); UnityThreadComputeShaderExecutorObject shaderExecutorObject = new UnityThreadComputeShaderExecutorObject(); ComputeShaderContainerGameObject containerGameObject = GameObject.FindObjectOfType <ComputeShaderContainerGameObject>(); UTTextureRendererProxy textureRendererProxy = new UTTextureRendererProxy(new TextureRendererService( new MultistepTextureRenderer(containerGameObject), new TextureRendererServiceConfiguration() { StepSize = new Vector2(400, 400) })); var meshGeneratorUtProxy = new MeshGeneratorUTProxy(new MeshGeneratorService()); var startConfiguration = ETerrainHeightPyramidFacadeStartConfiguration.DefaultConfiguration; ETerrainHeightBuffersManager buffersManager = new ETerrainHeightBuffersManager(); _eTerrainHeightPyramidFacade = new ETerrainHeightPyramidFacade(buffersManager, meshGeneratorUtProxy, textureRendererProxy, startConfiguration); var perLevelTemplates = _eTerrainHeightPyramidFacade.GenerateLevelTemplates(); var levels = startConfiguration.PerLevelConfigurations.Keys; var ePyramidShaderBuffersGeneratorPerRingInputs = 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 }); buffersManager.InitializeBuffers(ePyramidShaderBuffersGeneratorPerRingInputs, startConfiguration.CommonConfiguration.MaxLevelsCount, startConfiguration.CommonConfiguration.MaxRingsPerLevelCount); _eTerrainHeightPyramidFacade.Start(perLevelTemplates, new Dictionary <EGroundTextureType, OneGroundTypeLevelTextureEntitiesGenerator>() { //{ // EGroundTextureType.HeightMap, new OneGroundTypeLevelTextureEntitiesGenerator() // { // SegmentFillingListenerGeneratorFunc = (level) => // { // var floorTexture = // EGroundTextureGenerator.GenerateEmptyGroundTexture(startConfiguration.CommonConfiguration.FloorTextureSize, // startConfiguration.CommonConfiguration.HeightTextureFormat); // var segmentsPlacer = new ESurfaceSegmentPlacer(textureRendererProxy, floorTexture // , startConfiguration.CommonConfiguration.SlotMapSize, startConfiguration.CommonConfiguration.FloorTextureSize); // var pyramidLevelManager = new GroundLevelTexturesManager(startConfiguration.CommonConfiguration.SlotMapSize); // var segmentModificationManager = new SoleLevelGroundTextureSegmentModificationsManager(segmentsPlacer, pyramidLevelManager); // return new SegmentFillingListenerWithFloorTexture() // { // FloorTexture = floorTexture, // SegmentFillingListener = new LambdaSegmentFillingListener( // (c) => // { // var segmentTexture = ETerrainIntegrationMultipleSegmentsDEO.CreateDummySegmentTexture(c, level); // segmentModificationManager.AddSegmentAsync(segmentTexture, c.SegmentAlignedPosition); // }, // (c) => { }, // (c) => { } // ) // }; // }, // } //} } ); //_eTerrainHeightPyramidFacade.DisableShapes(); _eTerrainHeightPyramidFacade.DisableLevelShapes(HeightPyramidLevel.Bottom); Traveller.transform.position = new Vector3(startConfiguration.InitialTravellerPosition.x, 0, startConfiguration.InitialTravellerPosition.y); var ePropLocationConfiguration = new EPropElevationConfiguration(); EPropConstantPyramidParameters ePropConstantPyramidParameters = new EPropConstantPyramidParameters() { LevelsCount = startConfiguration.HeightPyramidLevels.Count, RingsPerLevelCount = startConfiguration.CommonConfiguration.MaxRingsPerLevelCount, //TODO parametrize HeightScale = startConfiguration.CommonConfiguration.YScale }; _elevationManager = new EPropElevationManager(new CommonExecutorUTProxy(), shaderExecutorObject, ePropLocationConfiguration, ePropConstantPyramidParameters); var heightFloorTextureArray = _eTerrainHeightPyramidFacade.FloorTextureArrays.Where(c => c.TextureType == EGroundTextureType.HeightMap).Select(c => c.Texture).First(); var initializedBuffers = _elevationManager.Initialize(buffersManager.PyramidPerFrameParametersBuffer, buffersManager.EPyramidConfigurationBuffer, heightFloorTextureArray); var ePropLocaleBuffer = initializedBuffers.EPropLocaleBuffer; var ePropIdsBuffer = initializedBuffers.EPropIdsBuffer; _dummyObjectsDisplayer = new EPropDummyObjectsDisplayer(ePropLocationConfiguration.ScopeLength, ePropLocaleBuffer, ePropIdsBuffer, FindObjectOfType <BufferReloaderRootGO>()); _dummyObjectsDisplayer.Start(); _dummyObjectsInstancingDisplayer = new EPropDummyObjectsInstancingDisplayer(DebugMesh, DebugMeshMaterial); _dummyObjectsInstancingDisplayer.Start(); _dummyObjectsInstancingDisplayer.SetLocaleBuffers(ePropLocaleBuffer, ePropIdsBuffer, ePropLocationConfiguration.ScopeLength); _sectorAreasDisplayer = new EPropDebugSectorAreasDisplayer(); _sectorAreasDisplayer.Start(); _mergeRingsDisplayer = new EPropDebugMergeRingsDisplayer(); _mergeRingsDisplayer.Start(); var levelWorldSizes = startConfiguration.PerLevelConfigurations.ToDictionary(c => c.Key, c => c.Value.FloorTextureWorldSize); var ringMergeRanges = perLevelTemplates.ToDictionary(c => c.Key, c => c.Value.PerRingTemplates.ToDictionary(k => k.Key, k => k.Value.HeightMergeRange)); _ePropHotAreaSelector = new EPropHotAreaSelector(levelWorldSizes, ringMergeRanges); _elevationManager.DebugInitializeSectors(new MyRectangle(-200, -200, 400, 400)); }