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

@@ -5,7 +5,7 @@
namespace Cubed {
CaveCarver::CaveCarver() {}
std::unordered_map<int, CavePath>& CaveCarver::paths() { return m_paths; }
std::unordered_map<unsigned, CavePath>& CaveCarver::paths() { return m_paths; }
void CaveCarver::init(unsigned world_seed) {
m_seed = world_seed;
@@ -19,13 +19,17 @@ void CaveCarver::reload(unsigned world_seed) {
init(world_seed);
}
void CaveCarver::add_path(const glm::vec3& pos) {
m_paths.emplace(m_sum, CavePath{m_seed, m_sum, pos});
void CaveCarver::add_path(const glm::vec3& pos, unsigned chunk_seed) {
m_paths.emplace(chunk_seed, CavePath{m_seed, m_sum, pos});
m_sum++;
}
void CaveCarver::try_to_add_path(const ChunkPos& chunk_pos,
unsigned chunk_seed) {
auto it = m_paths.find(chunk_seed);
if (it != m_paths.end()) {
return;
}
Random random{chunk_seed};
if (random.random_bool(static_cast<double>(m_cave_probability))) {
const int CHUNK_MIN_X = chunk_pos.x * CHUNK_SIZE;
@@ -38,7 +42,7 @@ void CaveCarver::try_to_add_path(const ChunkPos& chunk_pos,
int x = random.random_int(CHUNK_MIN_X, CHUNK_MAX_X);
int y = random.random_int(CHUNK_MIN_Y + 1, max_y);
int z = random.random_int(CHUNK_MIN_Z, CHUNK_MAX_Z);
add_path(glm::vec3{x, y, z});
add_path(glm::vec3{x, y, z}, chunk_seed);
}
}