Ejemplo n.º 1
0
        public PipelineProvider(Device device)
        {
            _terrainGenerator  = new TerrainGenerator(new DaniNoise(WorldSettings.HighMapNoiseOptions));
            _neighborAssigner  = new NeighborAssigner();
            _artifactGenerator = new ArtifactGenerator();
            _mapReadyPool      = new MapReadyPool();

            _localSunlightInitializer = new LocalSunlightInitializer();
            _fullScanner = new FullScanner();
            _localLightPropagationService = new LocalLightPropagationService();
            _chunkPool = new ChunkPool();

            _globalVisibilityFinalizer = new GlobalVisibilityFinalizer();
            _globalLightFinalizer      = new GlobalLightFinalizer();
            _buildPool = new BuildPool();

            _chunkDispatcher = new ChunkDispatcher(device);
        }
Ejemplo n.º 2
0
        public TransformBlock <Int2, Chunk> CreatePipeline(int maxDegreeOfParallelism, Action <Chunk> successCallback, out NeighborAssigner assigner)
        {
            var multiThreaded = new ExecutionDataflowBlockOptions
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            };

            var singleThreaded = new ExecutionDataflowBlockOptions
            {
                MaxDegreeOfParallelism = 1
            };

            var pipeline          = new TransformBlock <Int2, Chunk>(_terrainGenerator.Execute, multiThreaded);
            var neighborAssigner  = new TransformManyBlock <Chunk, Chunk>(_neighborAssigner.Execute, singleThreaded);
            var artifactGenerator = new TransformBlock <Chunk, Chunk>(_artifactGenerator.Execute, multiThreaded);
            var mapReadyPool      = new TransformManyBlock <Chunk, Chunk>(_mapReadyPool.Execute, singleThreaded);

            var sunlightInitializer   = new TransformBlock <Chunk, Chunk>(_localSunlightInitializer.Execute, multiThreaded);
            var fullScan              = new TransformBlock <Chunk, Chunk>(_fullScanner.Execute, multiThreaded);
            var localLightPropagation = new TransformBlock <Chunk, Chunk>(_localLightPropagationService.Execute, multiThreaded);
            var chunkPool             = new TransformManyBlock <Chunk, Chunk>(_chunkPool.Execute, singleThreaded);

            var globalVisibility = new TransformBlock <Chunk, Chunk>(_globalVisibilityFinalizer.Execute, singleThreaded);
            var lightFinalizer   = new TransformBlock <Chunk, Chunk>(_globalLightFinalizer.Execute, singleThreaded);
            var buildPool        = new TransformManyBlock <Chunk, Chunk>(_buildPool.Execute, singleThreaded);

            var dispatcher = new TransformBlock <Chunk, Chunk>(_chunkDispatcher.Execute, singleThreaded);

            var finalizer = new ActionBlock <Chunk>(successCallback, multiThreaded);

            pipeline.LinkTo(neighborAssigner);
            neighborAssigner.LinkTo(artifactGenerator);
            artifactGenerator.LinkTo(mapReadyPool);
            mapReadyPool.LinkTo(sunlightInitializer);
            sunlightInitializer.LinkTo(fullScan);
            fullScan.LinkTo(localLightPropagation);
            localLightPropagation.LinkTo(chunkPool);
            chunkPool.LinkTo(globalVisibility);
            globalVisibility.LinkTo(lightFinalizer);
            lightFinalizer.LinkTo(buildPool);
            buildPool.LinkTo(dispatcher);
            dispatcher.LinkTo(finalizer);
            assigner = _neighborAssigner;
            return(pipeline);
        }