refactor: river (#10)

* fix: correct snowy grass block texture

* refactor: river generation

* fix: water placement error due to interpolation

* perf: improve river naturalness

* feat: add river tab item

* fix: path truncation
This commit is contained in:
zhenyan121
2026-05-23 14:29:41 +08:00
committed by GitHub
parent a54e87dbc6
commit bbf8b4e969
25 changed files with 454 additions and 110 deletions

View File

@@ -15,27 +15,5 @@ void BiomeBuilder::build_bottom() {
}
}
}
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

View File

@@ -29,7 +29,7 @@ void DesertBuilder::build_blocks() {
}
}
void DesertBuilder::build_vegetation() { fill_water(); }
void DesertBuilder::build_vegetation() {}
ChunkGenerator& DesertBuilder::get_chunk_generator() {
return m_chunk_generator;

View File

@@ -52,7 +52,6 @@ void ForestBuilder::build_vegetation() {
}
}
}
fill_water();
}
ChunkGenerator& ForestBuilder::get_chunk_generator() {

View File

@@ -25,7 +25,7 @@ void MountainBuilder::build_blocks() {
}
}
void MountainBuilder::build_vegetation() { fill_water(); }
void MountainBuilder::build_vegetation() {}
ChunkGenerator& MountainBuilder::get_chunk_generator() {
return m_chunk_generator;

View File

@@ -29,7 +29,7 @@ void PlainBuilder::build_blocks() {
}
}
void PlainBuilder::build_vegetation() { fill_water(); }
void PlainBuilder::build_vegetation() {}
ChunkGenerator& PlainBuilder::get_chunk_generator() {
return m_chunk_generator;

View File

@@ -1,6 +1,5 @@
#include "Cubed/gameplay/builders/river_builder.hpp"
#include "Cubed/gameplay/chunk.hpp"
#include "Cubed/gameplay/chunk_generator.hpp"
namespace Cubed {
RiverBuilder::RiverBuilder(ChunkGenerator& chunk_generator)
@@ -12,6 +11,7 @@ void RiverBuilder::build_biome() {
};
void RiverBuilder::build_blocks() {
/*
auto& m_chunk = m_chunk_generator.chunk();
auto& m_blocks = m_chunk.blocks();
auto& m_heightmap = m_chunk.heightmap();
@@ -33,9 +33,11 @@ void RiverBuilder::build_blocks() {
}
}
}
*/
}
void RiverBuilder::build_vegetation() {
/*
auto& m_chunk = m_chunk_generator.chunk();
auto& m_blocks = m_chunk.blocks();
auto& m_heightmap = m_chunk.heightmap();
@@ -50,6 +52,7 @@ void RiverBuilder::build_vegetation() {
}
}
}
*/
}
ChunkGenerator& RiverBuilder::get_chunk_generator() {

View File

@@ -29,7 +29,7 @@ void SnowyPlainBuilder::build_blocks() {
}
}
void SnowyPlainBuilder::build_vegetation() { fill_water(); }
void SnowyPlainBuilder::build_vegetation() {}
ChunkGenerator& SnowyPlainBuilder::get_chunk_generator() {
return m_chunk_generator;