X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2Fchunk.cpp;h=2216617ec52aac4dc59b317329d2103da84d872a;hb=c04ea5a6f67d446ea29aa2e88dc4c666956d7732;hp=c114526ba46cdace3204acb226189cb0af671d27;hpb=bc1cefd505bf1f34639b8839cb337b08310ceb8e;p=blank.git diff --git a/src/world/chunk.cpp b/src/world/chunk.cpp index c114526..2216617 100644 --- a/src/world/chunk.cpp +++ b/src/world/chunk.cpp @@ -481,6 +481,30 @@ bool Chunk::Intersection( } } +bool Chunk::Intersection( + const AABB &box, + const glm::mat4 &Mbox, + const glm::mat4 &Mchunk +) const noexcept { + if (!blank::Intersection(box, Mbox, Bounds(), Mchunk)) { + return false; + } + for (int idx = 0, z = 0; z < depth; ++z) { + for (int y = 0; y < height; ++y) { + for (int x = 0; x < width; ++x, ++idx) { + const BlockType &type = Type(idx); + if (!type.visible) { + continue; + } + if (type.shape->Intersects(Mchunk * ToTransform(Pos(x, y, z), idx), box, Mbox)) { + return true; + } + } + } + } + return false; +} + namespace {