mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-06-22 02:27:01 +08:00
refactor(gameplay): move chunk generation phases into gen_chunk method
Consolidate multiple phase generation calls into a single gen_chunk() method on Chunk, which handles neighbor generation and ensures thread safety. Simplify World::gen_chunks_internal by using gen_chunk() instead of manual phase orchestration.
This commit is contained in:
@@ -455,6 +455,38 @@ void Chunk::gen_cross_plane_vertices(int world_x, int world_y, int world_z,
|
||||
}
|
||||
}
|
||||
|
||||
void Chunk::gen_chunk() {
|
||||
if (m_blocks.size() != 0) {
|
||||
Logger::warn(
|
||||
"Request Generator Chunk {} {} ,but the Blocks size is Not 0",
|
||||
m_chunk_pos.x, m_chunk_pos.z);
|
||||
}
|
||||
std::vector<Chunk> neighbor;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
neighbor.emplace_back(m_world, m_chunk_pos + CHUNK_DIR[i]);
|
||||
}
|
||||
for (auto& chunk : neighbor) {
|
||||
chunk.gen_phase_one();
|
||||
chunk.gen_phase_three();
|
||||
chunk.gen_phase_five();
|
||||
chunk.gen_phase_seven();
|
||||
}
|
||||
gen_phase_one();
|
||||
gen_phase_three();
|
||||
gen_phase_five();
|
||||
|
||||
OptionalBlockVectorArray neightbor_blocks;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
neightbor_blocks[i] = neighbor[i].get_chunk_blocks();
|
||||
}
|
||||
gen_phase_six(neightbor_blocks);
|
||||
gen_phase_seven();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
neightbor_blocks[i] = neighbor[i].get_chunk_blocks();
|
||||
}
|
||||
gen_vertex_data(neightbor_blocks);
|
||||
}
|
||||
|
||||
// Logger::info("Cross Sum {}", m_cross_vertices_sum.load());
|
||||
|
||||
} // namespace Cubed
|
||||
|
||||
Reference in New Issue
Block a user