mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-06-22 02:27:01 +08:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user