コード例 #1
0
        public ContourPhase(
            IStageIdentity stageIdentity,
            IStageBounds stageBounds,
            IRasterChunkConfig <Index3D> voxelChunkConfig,
            IAsyncFactory <ChunkKey, IDisposableValue <IReadOnlyVoxelGridChunk> > voxelChunkFactory,
            IDualContourer <TerrainVoxel, TSurfaceData, NormalColorTextureVertex> contourer,
            IChunkStore <ChunkKey, SerializedMeshChunk> meshChunkStore,
            int maxBufferedChunks,
            BatchSerializeGenerationOptions options = null)
        {
            Contracts.Requires.That(stageIdentity != null);
            Contracts.Requires.That(stageBounds != null);
            Contracts.Requires.That(voxelChunkConfig != null);
            Contracts.Requires.That(voxelChunkFactory != null);
            Contracts.Requires.That(contourer != null);
            Contracts.Requires.That(meshChunkStore != null);
            Contracts.Requires.That(maxBufferedChunks > 0);

            var phaseIdentity = new GenerationPhaseIdentity(nameof(ContourPhase <TSurfaceData>));
            var chunkKeys     = new ChunkKeyCollection(stageBounds);

            var poolOptions = new PoolOptions <IMutableDivisibleMesh <NormalColorTextureVertex> >()
            {
                ResetAction = mesh => mesh.Clear(),
            };

            this.pool = Pool.WithFactory.New(
                Factory.From <IMutableDivisibleMesh <NormalColorTextureVertex> >(
                    () => new MutableDivisibleMesh <NormalColorTextureVertex>()),
                poolOptions);

            var chunkFactory = new ContourMeshFactory <TSurfaceData>(
                voxelChunkConfig, voxelChunkFactory, this.pool, contourer);
            var serializer = DivisibleMeshSerializer.NormalColorTextureVertices.WithColorAlpha[
                options?.SerializationEndianness ?? DefaultSerializationEndianness];
            var persistableFactory = new SerializeMeshChunkFactory(chunkFactory, serializer);

            this.Phase = new ChunkedBatchingPhase <ChunkKey, SerializedMeshChunk>(
                stageIdentity,
                phaseIdentity,
                chunkKeys,
                persistableFactory,
                meshChunkStore,
                maxBufferedChunks,
                options);

            this.Completion = this.CompleteAsync();
        }
コード例 #2
0
        public VoxelGridAbsolutePhase(
            IStageIdentity stageIdentity,
            IStageBounds stageBounds,
            IRasterChunkConfig <Index3D> chunkConfig,
            IAsyncChunkPopulator <IVoxelGridChunk> chunkPopulator,
            IChunkStore <ChunkKey, SerializedVoxelGridChunk> chunkStore,
            int maxBufferedChunks,
            BatchSerializeGenerationOptions options = null)
        {
            Contracts.Requires.That(stageIdentity != null);
            Contracts.Requires.That(stageBounds != null);
            Contracts.Requires.That(chunkConfig != null);
            Contracts.Requires.That(chunkPopulator != null);
            Contracts.Requires.That(chunkStore != null);
            Contracts.Requires.That(maxBufferedChunks > 0);

            var phaseIdentity = new GenerationPhaseIdentity(nameof(VoxelGridAbsolutePhase));
            var chunkKeys     = new ChunkKeyCollection(stageBounds);

            var poolOptions = new PoolOptions <VoxelGridChunkResources>()
            {
            };

            this.pool = Pool.WithFactory.New(new VoxelGridChunkResourcesFactory(chunkConfig), poolOptions);

            var chunkFactory = new VoxelGridChunkPoolingFactory(this.pool, chunkPopulator);
            var serializer   = new VoxelGridChunkResourcesSerializer(
                TerrainVoxelSerializer.Get[options?.SerializationEndianness ?? DefaultSerializationEndianness],
                chunkConfig);
            var persister          = new VoxelGridChunkPersister(serializer);
            var persistableFactory = ChunkFactory.Persister.Create(chunkFactory, persister);

            this.Phase = new ChunkedBatchingPhase <ChunkKey, SerializedVoxelGridChunk>(
                stageIdentity,
                phaseIdentity,
                chunkKeys,
                persistableFactory,
                chunkStore,
                maxBufferedChunks,
                options);

            this.Completion = this.CompleteAsync();
        }