52 lines
1.5 KiB
C
52 lines
1.5 KiB
C
#include "world.h"
|
|
|
|
bool tc_generate_default_terrain_chunk(tc_worldgen_s *gen, tc_chunk_s *chunk)
|
|
{
|
|
tc_block_s block;
|
|
block.type_identifier = 1 | TC_BLOCK_OPAQUE_BIT;
|
|
block.position.x = 0.0f;
|
|
block.position.y = 0.0f;
|
|
block.position.z = 0.0f;
|
|
|
|
tc_block_s grass;
|
|
grass.type_identifier = 2 | TC_BLOCK_OPAQUE_BIT;
|
|
|
|
if(chunk->position.y > 0) return true;
|
|
|
|
uint32_t x_in_chunk = 0;
|
|
uint32_t y_in_chunk = 0;
|
|
uint32_t z_in_chunk = 0;
|
|
while(x_in_chunk < 32)
|
|
{
|
|
y_in_chunk = 0;
|
|
while(y_in_chunk < 32)
|
|
{
|
|
z_in_chunk = 0;
|
|
while(z_in_chunk < 32)
|
|
{
|
|
tc_set_block_in_chunk(chunk, x_in_chunk, y_in_chunk, z_in_chunk, block);
|
|
++z_in_chunk;
|
|
}
|
|
++y_in_chunk;
|
|
}
|
|
++x_in_chunk;
|
|
}
|
|
if(chunk->position.y == 0)
|
|
{
|
|
x_in_chunk = 0;
|
|
while(x_in_chunk < 32)
|
|
{
|
|
z_in_chunk = 0;
|
|
while(z_in_chunk < 32)
|
|
{
|
|
tc_set_block_in_chunk(chunk, x_in_chunk, 31, z_in_chunk, grass);
|
|
++z_in_chunk;
|
|
}
|
|
++x_in_chunk;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|