mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 14:01:49 +00:00
fix: extended block collision detection
This commit is contained in:
parent
4e696520b6
commit
65a2a3e475
1 changed files with 6 additions and 1 deletions
|
|
@ -67,11 +67,16 @@ const AABB* Chunks::isObstacleAt(float x, float y, float z){
|
||||||
}
|
}
|
||||||
const Block* def = indices->getBlockDef(v->id);
|
const Block* def = indices->getBlockDef(v->id);
|
||||||
if (def->obstacle) {
|
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
|
const auto& boxes = def->rotatable
|
||||||
? def->rt.hitboxes[v->state.rotation]
|
? def->rt.hitboxes[v->state.rotation]
|
||||||
: def->hitboxes;
|
: def->hitboxes;
|
||||||
for (const auto& hitbox : boxes) {
|
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;
|
return &hitbox;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue