Merge pull request #337 from 4jcraft/fix/entity-aabb
Some checks are pending
Publish Documentation / build (push) Waiting to run
Build (Linux, x86_64) / build-linux (push) Waiting to run
Build (Linux, x86_64) / build-linux-debug (push) Waiting to run
Clang Format / clang-format (push) Waiting to run

fix: correctly restore entity bounding boxes when computing movement physics
This commit is contained in:
Tropical 2026-03-28 22:35:04 -05:00 committed by GitHub
commit dcc937da5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -462,8 +462,8 @@ void Entity::setPos(double x, double y, double z) {
this->z = z;
float w = bbWidth / 2;
float h = bbHeight;
bb = {x - w, y - heightOffset + ySlideOffset, z - w, x + w,
y - heightOffset + ySlideOffset + h, z + w};
bb = {x - w, y - heightOffset + ySlideOffset, z - w,
x + w, y - heightOffset + ySlideOffset + h, z + w};
}
void Entity::turn(float xo, float yo) {
@ -664,6 +664,8 @@ void Entity::move(double xa, double ya, double za,
double yaOrg = ya;
double zaOrg = za;
AABB bbOrg = bb;
bool isPlayerSneaking =
onGround && isSneaking() && instanceof(eTYPE_PLAYER);
@ -769,6 +771,9 @@ void Entity::move(double xa, double ya, double za,
ya = footSize;
za = zaOrg;
AABB normal = bb;
bb = bbOrg;
// 4J - added extra expand, as if we don't move up by footSize by
// hitting a block above us, then overall we could be trying to move as
// much as footSize downwards, so we'd better include cubes under our
@ -825,6 +830,7 @@ void Entity::move(double xa, double ya, double za,
xa = xaN;
ya = yaN;
za = zaN;
bb = normal;
}
}