mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-06-18 00:27:02 +08:00
* feat: add BlockType * refactor: use fBM for heightmap generation * feat: improve mountain realism * refactor: adjust mountain spawn probability * feat: add biome boundary blending * refactor: remove resolve_biome_adjacency_conflict function * feat: add snowy plain * perf: speed up world generation * refactor: lower overall terrain height
41 lines
1.4 KiB
C++
41 lines
1.4 KiB
C++
#include "Cubed/gameplay/builders/biome_builder.hpp"
|
|
|
|
#include "Cubed/gameplay/chunk.hpp"
|
|
#include "Cubed/gameplay/chunk_generator.hpp"
|
|
namespace Cubed {
|
|
void BiomeBuilder::build_bottom() {
|
|
ChunkGenerator& chunk_generator = get_chunk_generator();
|
|
Chunk& chunk = chunk_generator.chunk();
|
|
auto& m_blocks = chunk.blocks();
|
|
for (int x = 0; x < CHUNK_SIZE; x++) {
|
|
for (int y = 0; y < 5; y++) {
|
|
for (int z = 0; z < CHUNK_SIZE; z++) {
|
|
m_blocks[Chunk::index(x, y, z)] = 3;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
void BiomeBuilder::fill_water() {
|
|
ChunkGenerator& chunk_generator = get_chunk_generator();
|
|
Chunk& chunk = chunk_generator.chunk();
|
|
auto& m_blocks = chunk.blocks();
|
|
auto& neighbor = chunk_generator.neighbor_biome();
|
|
auto& heightmap = chunk.heightmap();
|
|
for (int i = 0; i < 8; i++) {
|
|
if (neighbor[i] == BiomeType::RIVER) {
|
|
for (int x = 0; x < SIZE_X; x++) {
|
|
for (int z = 0; z < SIZE_Z; z++) {
|
|
if (heightmap[x][z] >= SEA_LEVEL) {
|
|
continue;
|
|
}
|
|
int height = heightmap[x][z];
|
|
for (int y = height; y < SEA_LEVEL; y++) {
|
|
m_blocks[Chunk::index(x, y, z)] = 7;
|
|
}
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
} // namespace Cubed
|