public SkyIslandMapImagesPhase( IStageIdentity stageIdentity, IStageBounds stageBounds, IAsyncFactory <ChunkOverheadKey, IDisposableValue <IReadOnlySkyIslandMapChunk> > chunkFactory, IKeyValueStore statsStore, SkyIslandMapImagesOptions imageOptions = null, GenerationOptions generationOptions = null) { Contracts.Requires.That(stageIdentity != null); Contracts.Requires.That(stageBounds != null); Contracts.Requires.That(chunkFactory != null); Contracts.Requires.That(statsStore != null); var phaseIdentity = new GenerationPhaseIdentity(nameof(SkyIslandMapImagesPhase)); var chunkKeys = new ChunkOverheadKeyCollection(stageBounds); var chunkProcessor = new SkyIslandMapChunkImagesProcessor(stageBounds, statsStore, imageOptions); this.Phase = new ChunkedPhase <ChunkOverheadKey, IReadOnlySkyIslandMapChunk>( stageIdentity, phaseIdentity, chunkKeys, chunkFactory, chunkProcessor, generationOptions); }
private static OscillationOrder3D GetOscillationOrder(IStageBounds bounds) { Contracts.Requires.That(bounds != null); var dimensions = bounds.InChunks.Dimensions; return(dimensions.X <= dimensions.Z ? OscillationOrder3D.YXZ : OscillationOrder3D.YZX); }
private static OscillationOrder2D GetOscillationOrder(IStageBounds bounds) { Contracts.Requires.That(bounds != null); var dimensions = bounds.InOverheadChunks.Dimensions; return(dimensions.X <= dimensions.Y ? OscillationOrder2D.XY : OscillationOrder2D.YX); }
public void SetFiniteBounds( IStageBounds stageBounds, SkyIslandMaps outOfBoundsValue, bool modifyingThrowsException = true) { Contracts.Requires.That(stageBounds != null); this.stageBounds = stageBounds; this.outOfBoundsValue = outOfBoundsValue; this.modifyingThrowsException = modifyingThrowsException; }
public SkyIslandMapChunkImagesProcessor( IStageBounds stageBounds, IKeyValueStore statsStore, SkyIslandMapImagesOptions imagesOptions = null) { Contracts.Requires.That(stageBounds != null); Contracts.Requires.That(statsStore != null); this.stageBounds = stageBounds; this.statsStore = statsStore; this.imagesOptions = imagesOptions; }
public ChunkKeyCollection( IStageBounds bounds, Func <Index3D, Index3D, IEnumerable <Index3D> > enumerationOrder) { Contracts.Requires.That(bounds != null); Contracts.Requires.That(enumerationOrder != null); var chunkKeys = enumerationOrder(bounds.InChunks.LowerBounds, bounds.InChunks.Dimensions) .Select(index => new ChunkKey(index)); this.keys = new ReadOnlyLargeCollection <ChunkKey>( chunkKeys, bounds.InChunks.LongLength); }
public StageBoundaryChunkOverheadFactory( IStageBounds bounds, IAsyncFactory <ChunkOverheadKey, TChunk> interiorFactory, IFactory <ChunkOverheadKey, TChunk> exteriorFactory) { Contracts.Requires.That(bounds != null); Contracts.Requires.That(interiorFactory != null); Contracts.Requires.That(exteriorFactory != null); this.minKey = bounds.InOverheadChunks.LowerBounds; this.maxKey = bounds.InOverheadChunks.UpperBounds; this.interiorFactory = interiorFactory; this.exteriorFactory = exteriorFactory; }
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(); }
public SkyIslandMapAbsolutePhase( IStageIdentity stageIdentity, IStageBounds stageBounds, IRasterChunkConfig <Index2D> chunkConfig, IAsyncChunkPopulator <ISkyIslandMapChunk> chunkPopulator, IChunkStore <ChunkOverheadKey, SerializedSkyIslandMapChunk> 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(SkyIslandMapAbsolutePhase)); var chunkKeys = new ChunkOverheadKeyCollection(stageBounds); var poolOptions = new PoolOptions <SkyIslandMapChunkResources>() { }; this.pool = Pool.WithFactory.New(new SkyIslandMapChunkResourcesFactory(chunkConfig), poolOptions); var chunkFactory = new SkyIslandMapChunkPoolingFactory(this.pool, chunkPopulator); var serializer = new SkyIslandMapChunkResourcesSerializer( SkyIslandMapsSerializer.Get[options?.SerializationEndianness ?? DefaultSerializationEndianness], chunkConfig); var persister = new SkyIslandMapChunkPersister(serializer); var persistableFactory = ChunkFactory.Persister.Create(chunkFactory, persister); this.Phase = new ChunkedBatchingPhase <ChunkOverheadKey, SerializedSkyIslandMapChunk>( stageIdentity, phaseIdentity, chunkKeys, persistableFactory, chunkStore, maxBufferedChunks, options); this.Completion = this.CompleteAsync(); }
public static SkyIslandMapPopulatorConfig.Builder CreatePreconfigured( IStageBounds stageBounds, IRasterChunkConfig chunkConfig) { Contracts.Requires.That(stageBounds != null); Contracts.Requires.That(chunkConfig != null); double baselineHeightVariation = 50; double halfStageHeight = stageBounds.InChunks.Dimensions.Y * chunkConfig.SideLength / 2.0; double baselineMin = halfStageHeight - baselineHeightVariation; double baselineMax = halfStageHeight + baselineHeightVariation; double scale = 10000; return(new SkyIslandMapPopulatorConfig.Builder() { SelectionGradientStartDistancePercent = .6, ShapeDistorter = NoiseDistorter.Combine( NoiseDistorter.New().Frequency(20 / scale, 20 / scale).ConvertRange(-1, 1), NoiseDistorter.New().Frequency(40 / scale, 40 / scale).ConvertRange(-.5, .5), NoiseDistorter.New().Frequency(80 / scale, 80 / scale).ConvertRange(-.3, .3)), BaselineHeightDistorter = NoiseDistorter.New().Frequency(10 / scale, 10 / scale).ConvertRange(baselineMin, baselineMax), MountainDistorter = NoiseDistorter.New().Frequency(10 / scale, 10 / scale).ConvertRange(-6, 5).Clamp(1, 4), TopHeightDistorter = NoiseDistorter.Combine( NoiseDistorter.New().Frequency(20 / scale, 20 / scale).ConvertRange(0, 10), NoiseDistorter.New().Frequency(40 / scale, 40 / scale).ConvertRange(0, 40), NoiseDistorter.New().Frequency(80 / scale, 80 / scale).ConvertRange(0, 20), NoiseDistorter.New().Frequency(160 / scale, 160 / scale).ConvertRange(0, 10)), TopHeightNearEdgeDistorter = NoiseDistorter.Combine( NoiseDistorter.New().Frequency(20 / scale, 20 / scale).ConvertRange(0, 7.5), NoiseDistorter.New().Frequency(40 / scale, 40 / scale).ConvertRange(0, 30), NoiseDistorter.New().Frequency(80 / scale, 80 / scale).ConvertRange(0, 15), NoiseDistorter.New().Frequency(160 / scale, 160 / scale).ConvertRange(0, 7.5)), BottomHeightDistorter = NoiseDistorter.New().Frequency(200 / scale, 200 / scale).ConvertRange(-200, -100), BottomHeightNearEdgeDistorter = NoiseDistorter.New().Frequency(800 / scale, 800 / scale).ConvertRange(-100, -50), }); }
public SkyIslandMapChunkPopulator( SkyIslandMapPopulatorConfig mapsConfig, IStageBounds stageBounds, IFactory <int, INoise2D> multiNoise) { Contracts.Requires.That(mapsConfig != null); Contracts.Requires.That(stageBounds != null); Contracts.Requires.That(multiNoise != null); this.mapsConfig = mapsConfig; // using the lesser of the 2 dimensions ensures the radial gradient doesn't clip early out of bounds var stageOverheadDimensions = stageBounds.InOverheadChunks.Dimensions; this.halfStageLength = Math.Min(stageOverheadDimensions.X, stageOverheadDimensions.Y) / 2.0; this.radiusStart = this.halfStageLength * this.mapsConfig.SelectionGradientStartDistancePercent; this.shapeNoise = multiNoise.Create(SkyIslandNoiseSubSeed.ShapeMap); this.baselineNoise = multiNoise.Create(SkyIslandNoiseSubSeed.BaselineMap); this.mountainNoise = multiNoise.Create(SkyIslandNoiseSubSeed.MountainMap); this.topNoise = multiNoise.Create(SkyIslandNoiseSubSeed.TopMap); this.bottomNoise = multiNoise.Create(SkyIslandNoiseSubSeed.BottomMap); }
public static bool Contains(this IStageBounds bounds, ChunkOverheadKey key) { Contracts.Requires.That(bounds != null); return(key.Index.IsIn(bounds.InOverheadChunks.LowerBounds, bounds.InOverheadChunks.UpperBounds)); }
public ChunkKeyCollection(IStageBounds bounds, OscillationOrder3D order) : this(bounds, (start, dimensions) => Index.OscillateRange(start, dimensions, order)) { }
public ChunkKeyCollection(IStageBounds bounds) : this(bounds, GetOscillationOrder(bounds)) { }
public static IAsyncFactory <ChunkKey, TChunk> Create <TChunk>( IStageBounds bounds, IAsyncFactory <ChunkKey, TChunk> interiorFactory, IFactory <ChunkKey, TChunk> exteriorFactory) => new StageBoundaryChunkFactory <TChunk>(bounds, interiorFactory, exteriorFactory);