returning range from noise

This commit is contained in:
Kbz-8
2025-05-21 14:48:01 +02:00
parent 4329e7624e
commit c1df84bad7
5 changed files with 28 additions and 30 deletions

View File

@@ -1,6 +1,13 @@
#include <Noise.h>
[[nodiscard]] std::uint32_t Noise::GetHeight(Scop::Vec2i pos)
[[nodiscard]] std::array<std::uint32_t, CHUNK_SIZE.y> Noise::GetHeight(Scop::Vec2i pos)
{
return std::abs(std::sin((float)pos.x / 20.0f) * std::cos((float)pos.y / 20.0f) * 60.0f) + 1;
std::array<std::uint32_t, CHUNK_SIZE.y> data;
std::memset(data.data(), 0, data.size() * sizeof(std::uint32_t));
std::uint32_t height = std::abs(std::sin((float)pos.x / 20.0f) * std::cos((float)pos.y / 20.0f) * 60.0f) + 1;
for(std::uint32_t y = 0; y < std::min(height, CHUNK_SIZE.y); y++)
data[y] = 1;
return data;
}