+bool Chunk::Obstructed(int idx) const {
+ if (IsBorder(idx)) return false;
+
+ // not checking neighbor visibility here, so all
+ // invisible blocks must have their fill set to 6x false
+ // (the default, so should be okay)
+
+ const BlockType &right = Type(blocks[idx + 1]);
+ if (!right.fill.left) return false;
+
+ const BlockType &left = Type(blocks[idx - 1]);
+ if (!left.fill.right) return false;
+
+ const BlockType &up = Type(blocks[idx + Width()]);
+ if (!up.fill.down) return false;
+
+ const BlockType &down = Type(blocks[idx - Width()]);
+ if (!down.fill.up) return false;
+
+ const BlockType &front = Type(blocks[idx + Width() * Height()]);
+ if (!front.fill.back) return false;
+
+ const BlockType &back = Type(blocks[idx - Width() * Height()]);
+ if (!back.fill.front) return false;
+
+ return true;
+}
+
+glm::mat4 Chunk::ToTransform(int idx) const {
+ return glm::translate(glm::mat4(1.0f), ToCoords(idx)) * blocks[idx].Transform();
+}
+