X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2Fchunk.cpp;h=2c5e7ec4ebad297570c5ef71fd2799822e5e30cc;hb=32909aa3224ec0ed5656721178eb6ad31cd047df;hp=2216617ec52aac4dc59b317329d2103da84d872a;hpb=c04ea5a6f67d446ea29aa2e88dc4c666956d7732;p=blank.git diff --git a/src/world/chunk.cpp b/src/world/chunk.cpp index 2216617..2c5e7ec 100644 --- a/src/world/chunk.cpp +++ b/src/world/chunk.cpp @@ -3,8 +3,10 @@ #include "ChunkLoader.hpp" #include "Generator.hpp" +#include "WorldCollision.hpp" #include +#include #include #include @@ -484,9 +486,14 @@ bool Chunk::Intersection( bool Chunk::Intersection( const AABB &box, const glm::mat4 &Mbox, - const glm::mat4 &Mchunk + const glm::mat4 &Mchunk, + std::vector &col ) const noexcept { - if (!blank::Intersection(box, Mbox, Bounds(), Mchunk)) { + bool any = false; + float penetration; + glm::vec3 normal; + + if (!blank::Intersection(box, Mbox, Bounds(), Mchunk, penetration, normal)) { return false; } for (int idx = 0, z = 0; z < depth; ++z) { @@ -496,13 +503,14 @@ bool Chunk::Intersection( if (!type.visible) { continue; } - if (type.shape->Intersects(Mchunk * ToTransform(Pos(x, y, z), idx), box, Mbox)) { - return true; + if (type.shape->Intersects(Mchunk * ToTransform(Pos(x, y, z), idx), box, Mbox, penetration, normal)) { + col.emplace_back(this, idx, penetration, normal); + any = true; } } } } - return false; + return any; }