]> git.localhorst.tv Git - blank.git/commitdiff
fix chunk neighbors
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 23 Mar 2015 18:47:59 +0000 (19:47 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 23 Mar 2015 19:08:41 +0000 (20:08 +0100)
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

src/chunk.cpp

index cc53e912683cb99e576219709fd2151bf867019a..de30ae91a58d5e5bb092f6ed58b5831b0996bad4 100644 (file)
@@ -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;
        }