public Guid Generate(OpenSimplexRequestDto requestDto) { int seed = requestDto.Seed.HasValue ? requestDto.Seed.Value : new Random().Next(); var heightmapDto = openSimplexGenerator.Generate( requestDto.Width, requestDto.Height, requestDto.OverlappedSize, seed, requestDto.Scale, requestDto.Octaves, requestDto.Persistance, requestDto.Lacunarity ); var id = CreateHeightmap(heightmapDto); if (requestDto.Infinite) { repository.AddBaseHeightmapChunk(new BaseHeightmapChunkDto { Id = id, Width = requestDto.Width, Height = requestDto.Height, OverlappedSize = requestDto.OverlappedSize, Seed = seed, Scale = requestDto.Scale, Octaves = requestDto.Octaves, Persistance = requestDto.Persistance, Lacunarity = requestDto.Lacunarity, Heightmap = heightmapDto }); repository.SaveChanges(); } return(id); }
public IActionResult CreateSimplexHeightmap([FromBody] OpenSimplexRequestDto requestDto) { var result = terrainService.Generate(requestDto); return(Ok(result)); }