mirror of
https://github.com/Kbz-8/42_vox.git
synced 2026-01-11 14:43:34 +00:00
fixing chunk generation
This commit is contained in:
@@ -127,22 +127,20 @@ void World::GenerateWorld()
|
|||||||
}
|
}
|
||||||
std::queue<std::reference_wrapper<Chunk>> mesh_generation_queue;
|
std::queue<std::reference_wrapper<Chunk>> mesh_generation_queue;
|
||||||
|
|
||||||
for(std::int32_t x = m_current_chunk_position.x - RENDER_DISTANCE; x <= m_current_chunk_position.x + RENDER_DISTANCE; x++)
|
Scop::Vec2i x_range{ m_current_chunk_position.x - RENDER_DISTANCE - 1, m_current_chunk_position.x + RENDER_DISTANCE + 1 };
|
||||||
|
Scop::Vec2i z_range{ m_current_chunk_position.y - RENDER_DISTANCE - 1, m_current_chunk_position.y + RENDER_DISTANCE + 1 };
|
||||||
|
|
||||||
|
for(std::int32_t x = x_range.x; x <= x_range.y; x++)
|
||||||
{
|
{
|
||||||
for(std::int32_t z = m_current_chunk_position.y - RENDER_DISTANCE; z <= m_current_chunk_position.y + RENDER_DISTANCE; z++)
|
for(std::int32_t z = z_range.x; z <= z_range.y; z++)
|
||||||
{
|
{
|
||||||
QUIT_CHECK();
|
QUIT_CHECK();
|
||||||
auto res = m_chunks.try_emplace(Scop::Vec2i{ x, z }, *this, Scop::Vec2i{ x, z });
|
auto res = m_chunks.try_emplace(Scop::Vec2i{ x, z }, *this, Scop::Vec2i{ x, z });
|
||||||
if(res.second)
|
|
||||||
{
|
|
||||||
if(!res.first->second.GetActor())
|
|
||||||
{
|
|
||||||
res.first->second.GenerateChunk();
|
res.first->second.GenerateChunk();
|
||||||
|
if(!res.first->second.GetActor() && x > x_range.x && x < x_range.y && z > z_range.x && z < z_range.y)
|
||||||
mesh_generation_queue.push(std::ref(res.first->second));
|
mesh_generation_queue.push(std::ref(res.first->second));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
while(!mesh_generation_queue.empty())
|
while(!mesh_generation_queue.empty())
|
||||||
{
|
{
|
||||||
QUIT_CHECK();
|
QUIT_CHECK();
|
||||||
|
|||||||
Reference in New Issue
Block a user