X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2Fchunk.cpp;h=97ec3e353600d0efa79cb49c67aca250da142786;hb=242b87a5fb412f9006e4b7debc1408cf7ac83000;hp=596bcaf08985765f4a0f96aa928c4cef3d040e94;hpb=fda38181732e58537331c919dd699eaa830ead50;p=blank.git diff --git a/src/world/chunk.cpp b/src/world/chunk.cpp index 596bcaf..97ec3e3 100644 --- a/src/world/chunk.cpp +++ b/src/world/chunk.cpp @@ -415,9 +415,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;