From: Daniel Karbach Date: Mon, 23 Mar 2015 18:47:59 +0000 (+0100) Subject: fix chunk neighbors X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=fc73b44e0f90affd42cac2f944f46633a6b8364e;p=blank.git fix chunk neighbors there was something seriously wrong with light propagation now I know why ^^ don't get me wrong, it's still borky, but at least not irrational --- diff --git a/src/chunk.cpp b/src/chunk.cpp index cc53e91..de30ae9 100644 --- a/src/chunk.cpp +++ b/src/chunk.cpp @@ -13,6 +13,7 @@ Chunk::Chunk(const BlockTypeRegistry &types) : types(&types) , neighbor{ 0, 0, 0, 0, 0, 0 } , blocks() +, light() , model() , position(0, 0, 0) , dirty(false) { @@ -22,7 +23,9 @@ Chunk::Chunk(const BlockTypeRegistry &types) Chunk::Chunk(Chunk &&other) : types(other.types) , blocks(std::move(other.blocks)) +, light(std::move(other.light)) , model(std::move(other.model)) +, position(other.position) , dirty(other.dirty) { for (size_t i = 0; i < Block::FACE_COUNT; ++i) { neighbor[i] = other.neighbor[i]; @@ -35,29 +38,31 @@ Chunk &Chunk::operator =(Chunk &&other) { neighbor[i] = other.neighbor[i]; } blocks = std::move(other.blocks); + light = std::move(other.light); model = std::move(other.model); + position = other.position; dirty = other.dirty; return *this; } void Chunk::SetNeighbor(Chunk &other) { - if (other.position == position - Pos(-1, 0, 0)) { + if (other.position == position + Pos(-1, 0, 0)) { neighbor[Block::FACE_LEFT] = &other; other.neighbor[Block::FACE_RIGHT] = this; - } else if (other.position == position - Pos(1, 0, 0)) { + } else if (other.position == position + Pos(1, 0, 0)) { neighbor[Block::FACE_RIGHT] = &other; other.neighbor[Block::FACE_LEFT] = this; - } else if (other.position == position - Pos(0, -1, 0)) { + } else if (other.position == position + Pos(0, -1, 0)) { neighbor[Block::FACE_DOWN] = &other; other.neighbor[Block::FACE_UP] = this; - } else if (other.position == position - Pos(0, 1, 0)) { + } else if (other.position == position + Pos(0, 1, 0)) { neighbor[Block::FACE_UP] = &other; other.neighbor[Block::FACE_DOWN] = this; - } else if (other.position == position - Pos(0, 0, -1)) { + } else if (other.position == position + Pos(0, 0, -1)) { neighbor[Block::FACE_BACK] = &other; other.neighbor[Block::FACE_FRONT] = this; - } else if (other.position == position - Pos(0, 0, 1)) { + } else if (other.position == position + Pos(0, 0, 1)) { neighbor[Block::FACE_FRONT] = &other; other.neighbor[Block::FACE_BACK] = this; }