mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-06-22 02:27:01 +08:00
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:
@@ -103,8 +103,7 @@ int Chunk::index(const glm::vec3& pos) {
|
||||
return Chunk::index(pos.x, pos.y, pos.z);
|
||||
}
|
||||
|
||||
void Chunk::gen_vertex_data(
|
||||
const std::array<const std::vector<BlockType>*, 4>& neighbor_block) {
|
||||
void Chunk::gen_vertex_data(const OptionalBlockVectorArray& neighbor_block) {
|
||||
if (m_is_on_gen_vertex_data) {
|
||||
return;
|
||||
}
|
||||
@@ -265,8 +264,7 @@ unsigned Chunk::seed() const {
|
||||
|
||||
BiomeConditions& Chunk::conditions() { return m_conditions; }
|
||||
|
||||
void Chunk::gen_vertices(
|
||||
const std::array<const std::vector<BlockType>*, 4>& neighbor_block) {
|
||||
void Chunk::gen_vertices(const OptionalBlockVectorArray& neighbor_block) {
|
||||
static const glm::ivec3 DIR[6] = {{0, 0, 1}, {1, 0, 0}, {0, 0, -1},
|
||||
{-1, 0, 0}, {0, 1, 0}, {0, -1, 0}};
|
||||
|
||||
@@ -299,8 +297,9 @@ void Chunk::gen_vertices(
|
||||
World::chunk_pos(world_nx, world_nz);
|
||||
|
||||
auto is_culled =
|
||||
[&](const std::vector<BlockType>* chunk_blocks) {
|
||||
if (chunk_blocks == nullptr) {
|
||||
[&](const std::optional<std::vector<BlockType>>&
|
||||
chunk_blocks) {
|
||||
if (chunk_blocks == std::nullopt) {
|
||||
return true;
|
||||
}
|
||||
int x, y, z;
|
||||
|
||||
Reference in New Issue
Block a user