X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FChunk.hpp;h=045f58df7d6ac29f1140fea27849cc212aea5e30;hb=1a8d4d31ef0a094ef6488127c5f873040151cb57;hp=7eceb980cb62d6c66918ae9b3eb7fa587416c2c3;hpb=ed3bdc028edc0ecb5835d1c0bf18dbc59b342daf;p=blank.git diff --git a/src/world/Chunk.hpp b/src/world/Chunk.hpp index 7eceb98..045f58d 100644 --- a/src/world/Chunk.hpp +++ b/src/world/Chunk.hpp @@ -35,6 +35,14 @@ public: static glm::vec3 Center() noexcept { return glm::vec3(8.0f); } static float Radius() noexcept { return 27.71281292110203669632f; /* 16 * √3 */ } + /// get bounding box relative to given reference chunk + AABB RelativeBounds(const ExactLocation::Coarse &ref) const noexcept { + AABB bounds; + bounds.min = (position - ref) * ExactLocation::Extent(); + bounds.max = bounds.min + ExactLocation::FExtent(); + return bounds; + } + static constexpr bool InBounds(const ExactLocation::Fine &pos) noexcept { return pos.x >= 0.0f && pos.x < fside && @@ -141,7 +149,7 @@ public: const ExactLocation::Coarse &reference, float &dist ) const noexcept { - return blank::Intersection(ray, Bounds(), Transform(reference), &dist); + return blank::Intersection(ray, RelativeBounds(reference), dist); } /// check if given ray intersects any block of this chunk