public static TerrainShapeDb CreateTerrainShapeDb(TerrainDetailProvider terrainDetailProvider, CommonExecutorUTProxy commonExecutorUtProxy,
                                                          TerrainDetailAlignmentCalculator terrainDetailAlignmentCalculator, bool mergingEnabled, bool saveTexturesToFile, bool loadTexturesFromFile,
                                                          TerrainDetailFileManager fileManager)
        {
            var cachingConfiguration = new CachingConfiguration()
            {
                SaveAssetsToFile = saveTexturesToFile,
                UseFileCaching   = loadTexturesFromFile
            };

            Func <IAssetsCache <InternalTerrainDetailElementToken, TextureWithSize> > terrainCacheGenerator =
                () => new InMemoryAssetsCache <InternalTerrainDetailElementToken, TextureWithSize>(
                    CreateLevel2AssetsCache <InternalTerrainDetailElementToken, TextureWithSize>(
                        cachingConfiguration,
                        new InMemoryCacheConfiguration(),
                        new TextureWithSizeActionsPerformer(commonExecutorUtProxy),
                        new CachingTerrainDetailFileManager(fileManager)));

            var cachedTerrainDetailProvider = new CachedTerrainDetailProvider(
                terrainDetailProvider,
                terrainCacheGenerator, mergingEnabled);

            cachedTerrainDetailProvider.Initialize().Wait();
            var terrainShapeDb = new TerrainShapeDb(cachedTerrainDetailProvider, terrainDetailAlignmentCalculator);

            return(terrainShapeDb);
        }
        public TerrainShapeDbUnderTest(bool useTextureSavingToDisk  = false, bool useCornerMerging = false,
                                       string terrainDetailFilePath = "C:\\unityCache\\", bool useTextureLoadingFromDisk = false)
        {
            CommonExecutorUTProxy            commonExecutorUtProxy = new CommonExecutorUTProxy();
            ComputeShaderContainerGameObject containerGameObject   = GameObject.FindObjectOfType <ComputeShaderContainerGameObject>();

            var globalHeightTexture = CreateGlobalHeightTexture(commonExecutorUtProxy);

            UTTextureRendererProxy textureRendererProxy = new UTTextureRendererProxy(new TextureRendererService(
                                                                                         new MultistepTextureRenderer(containerGameObject), new TextureRendererServiceConfiguration()
            {
                StepSize = new Vector2(400, 400)
            }));

            UnityThreadComputeShaderExecutorObject computeShaderExecutorObject = new UnityThreadComputeShaderExecutorObject();
            var terrainDetailGenerator = Ring1DebugObjectV2.CreateTerrainDetailGenerator(
                globalHeightTexture, textureRendererProxy, commonExecutorUtProxy, computeShaderExecutorObject,
                containerGameObject);

            TerrainDetailCornerMerger merger = null;
            LateAssignFactory <BaseTerrainDetailProvider> detailProviderFactory = new LateAssignFactory <BaseTerrainDetailProvider>();

            if (useCornerMerging)
            {
                merger = new TerrainDetailCornerMerger(detailProviderFactory, new TerrainDetailAlignmentCalculator(240), textureRendererProxy, new TextureConcieverUTProxy(),
                                                       new CommonExecutorUTProxy(), new TerrainDetailCornerMergerConfiguration());
            }

            var terrainDetailProvider = Ring1DebugObjectV2.CreateTerrainDetailProvider(terrainDetailGenerator, merger);

            _shapeDb = FETerrainShapeDbInitialization.CreateTerrainShapeDb(terrainDetailProvider, commonExecutorUtProxy
                                                                           , new TerrainDetailAlignmentCalculator(240), useCornerMerging, useTextureSavingToDisk, useTextureLoadingFromDisk
                                                                           , new TerrainDetailFileManager(terrainDetailFilePath, commonExecutorUtProxy));

            var baseProvider = new FromTerrainDbBaseTerrainDetailProvider(_shapeDb);

            detailProviderFactory.Assign(baseProvider);
            terrainDetailGenerator.SetBaseTerrainDetailProvider(baseProvider);
        }