X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2Fchunk.cpp;h=7f7b185dc91eaff3d9c71c0126ddcd414b3d02d2;hb=d2f4c8720ae2326fac4203fa4984d835e875b355;hp=596bcaf08985765f4a0f96aa928c4cef3d040e94;hpb=ef2427f841a434f93805321f8bbac44be2dd4555;p=blank.git diff --git a/src/world/chunk.cpp b/src/world/chunk.cpp index 596bcaf..7f7b185 100644 --- a/src/world/chunk.cpp +++ b/src/world/chunk.cpp @@ -33,7 +33,6 @@ Chunk::Chunk(const BlockTypeRegistry &types) noexcept : types(&types) , neighbor{0} , gravity() -, blocks{} , light{0} , generated(false) , lighted(false) @@ -415,9 +414,17 @@ bool Chunk::Intersection( if (!type.collision || !type.shape) { continue; } + RoughLocation::Fine pos(x, y, z); + + // center of the blok relative to the ray + glm::vec3 relative_center(glm::vec3((position - reference) * ExactLocation::Extent() + pos) + 0.5f); + if (ray.DistanceSquared(relative_center) > 3.0f) { + continue; + } + float cur_dist; glm::vec3 cur_norm; - if (type.shape->Intersects(ray, ToTransform(reference, RoughLocation::Fine(x, y, z), idx), cur_dist, cur_norm)) { + if (type.shape->Intersects(ray, ToTransform(reference, pos, idx), cur_dist, cur_norm)) { if (cur_dist < coll.depth) { coll.block = idx; coll.depth = cur_dist;