Skip to content

Commit

Permalink
Use Z for up (Part 6)
Browse files Browse the repository at this point in the history
Fix neighbouring chunks list on the server side, which was causing some slices of trees to appear in the air.

Also switch order of loops for generating leaves to Z, Y, X.
  • Loading branch information
Pedro Gimeno committed Feb 21, 2020
1 parent c8b5d94 commit 2a8125a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions server/source/world/ServerWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ void ServerWorld::createChunkNeighbours(ServerChunk *chunk) {
gk::Vector3i surroundingChunks[6] = {
{chunk->x() - 1, chunk->y(), chunk->z()},
{chunk->x() + 1, chunk->y(), chunk->z()},
{chunk->x(), chunk->y(), chunk->z() - 1},
{chunk->x(), chunk->y(), chunk->z() + 1},
{chunk->x(), chunk->y() - 1, chunk->z()},
{chunk->x(), chunk->y() + 1, chunk->z()},
{chunk->x(), chunk->y(), chunk->z() - 1},
{chunk->x(), chunk->y(), chunk->z() + 1},
};

for (u8 i = 0 ; i < 6 ; ++i) {
Expand Down
4 changes: 2 additions & 2 deletions server/source/world/TerrainGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ void TerrainGenerator::fastNoiseGeneration(ServerChunk &chunk) const {
}

// Leaves
for(int ix = -3 ; ix <= 3 ; ix++) {
for(int iz = -3 ; iz <= 3 ; iz++) {
for(int iy = -3 ; iy <= 3 ; iy++) {
for(int iz = -3 ; iz <= 3 ; iz++) {
for(int ix = -3 ; ix <= 3 ; ix++) {
if(ix * ix + iy * iy + iz * iz < 8 + (rand() & 1) && !chunk.getBlock(x + ix, y + iy, z + h + iz)) {
chunk.setBlockRaw(x + ix, y + iy, z + h + iz, m_leavesBlockID);

Expand Down

0 comments on commit 2a8125a

Please sign in to comment.