From 65a2a3e475988136e8ff57ec1c7807dbc3f5f347 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 9 Jun 2024 17:40:01 +0300 Subject: [PATCH] fix: extended block collision detection --- src/voxels/Chunks.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/voxels/Chunks.cpp b/src/voxels/Chunks.cpp index 65e7bc7f..9c09de7d 100644 --- a/src/voxels/Chunks.cpp +++ b/src/voxels/Chunks.cpp @@ -67,11 +67,16 @@ const AABB* Chunks::isObstacleAt(float x, float y, float z){ } const Block* def = indices->getBlockDef(v->id); if (def->obstacle) { + glm::ivec3 offset {}; + if (v->state.segment) { + glm::ivec3 point(ix, iy, iz); + offset = seekOrigin(point, def, v->state) - point; + } const auto& boxes = def->rotatable ? def->rt.hitboxes[v->state.rotation] : def->hitboxes; for (const auto& hitbox : boxes) { - if (hitbox.contains({x - ix, y - iy, z - iz})) { + if (hitbox.contains({x - ix - offset.x, y - iy - offset.y, z - iz - offset.z})) { return &hitbox; } }