refactor: world generation (#17)

* refactor: use TBB for concurrent hash maps and parallelize chunk processing

* fix: tbb link fail

* refactor(chunk): remove biome check for caves in rivers and oceans

* refactor(random): replace std distributions with custom implementations

Avoid overhead and platform-dependent behavior of `<random>` distributions by using direct engine operations and integer arithmetic. This ensures deterministic, cross-platform results and improves performance.

* refactor(generation): use chunk seed for cave and river paths

- Use per-chunk seed instead of global path_id for cave and river generation.
- Remove unused m_sum variables and m_path_id members.
- Clamp river yaw within 10 degrees of initial direction.
- Fix river radius interpolation (use t instead of 1-t).
- Lower sea level from 64 to 63.
This commit is contained in:
zhenyan121
2026-06-14 11:36:37 +08:00
committed by GitHub
parent 932463663f
commit f4114c2699
19 changed files with 384 additions and 239 deletions

View File

@@ -6,10 +6,9 @@
#include <algorithm>
namespace Cubed {
CavePath::CavePath(unsigned int world_seed, int path_id,
CavePath::CavePath(unsigned int chunk_seed, unsigned world_seed,
const glm::vec3& start_pos) {
m_path_id = path_id;
m_seed = HASH::combine_32(world_seed, path_id);
m_seed = HASH::combine_32(chunk_seed, world_seed);
m_random.init(m_seed);
m_yaw = m_random.random_float(0.0f, 360.0f);
m_pitch = m_random.random_float(-10.0f, 10.0f);
@@ -75,7 +74,8 @@ void CavePath::precompute_chunk_coverage() {
for (int cx = min_cx; cx <= max_cx; ++cx)
for (int cz = min_cz; cz <= max_cz; ++cz)
m_pending_chunks.insert({cx, cz});
m_pending_chunks.insert(
std::make_pair(ChunkPos{cx, cz}, false));
}
}