X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2Fchunk.cpp;h=a65f5c31d9b1d0081ab3204903b87cbe10bd562d;hb=955fbb45dedb570520fc45d2ce69f420bed2ad08;hp=7591266be5433ecb6b7a0e6c200e1eb3026a68e7;hpb=419e33e565bffbaf0416ed4a5f80e9c81f62a479;p=blank.git diff --git a/src/world/chunk.cpp b/src/world/chunk.cpp index 7591266..a65f5c3 100644 --- a/src/world/chunk.cpp +++ b/src/world/chunk.cpp @@ -3,6 +3,7 @@ #include "ChunkLoader.hpp" #include "Generator.hpp" +#include "WorldCollision.hpp" #include #include @@ -485,8 +486,10 @@ 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 { + bool any = false; float penetration; glm::vec3 normal; @@ -497,16 +500,17 @@ bool Chunk::Intersection( for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x, ++idx) { const BlockType &type = Type(idx); - if (!type.visible) { + if (!type.collision) { 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; }