mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-01 01:52:26 +00:00
Merge pull request #337 from 4jcraft/fix/entity-aabb
fix: correctly restore entity bounding boxes when computing movement physics
This commit is contained in:
commit
dcc937da5e
|
|
@ -462,8 +462,8 @@ void Entity::setPos(double x, double y, double z) {
|
||||||
this->z = z;
|
this->z = z;
|
||||||
float w = bbWidth / 2;
|
float w = bbWidth / 2;
|
||||||
float h = bbHeight;
|
float h = bbHeight;
|
||||||
bb = {x - w, y - heightOffset + ySlideOffset, z - w, x + w,
|
bb = {x - w, y - heightOffset + ySlideOffset, z - w,
|
||||||
y - heightOffset + ySlideOffset + h, z + w};
|
x + w, y - heightOffset + ySlideOffset + h, z + w};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::turn(float xo, float yo) {
|
void Entity::turn(float xo, float yo) {
|
||||||
|
|
@ -664,6 +664,8 @@ void Entity::move(double xa, double ya, double za,
|
||||||
double yaOrg = ya;
|
double yaOrg = ya;
|
||||||
double zaOrg = za;
|
double zaOrg = za;
|
||||||
|
|
||||||
|
AABB bbOrg = bb;
|
||||||
|
|
||||||
bool isPlayerSneaking =
|
bool isPlayerSneaking =
|
||||||
onGround && isSneaking() && instanceof(eTYPE_PLAYER);
|
onGround && isSneaking() && instanceof(eTYPE_PLAYER);
|
||||||
|
|
||||||
|
|
@ -769,6 +771,9 @@ void Entity::move(double xa, double ya, double za,
|
||||||
ya = footSize;
|
ya = footSize;
|
||||||
za = zaOrg;
|
za = zaOrg;
|
||||||
|
|
||||||
|
AABB normal = bb;
|
||||||
|
bb = bbOrg;
|
||||||
|
|
||||||
// 4J - added extra expand, as if we don't move up by footSize by
|
// 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
|
// 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
|
// 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;
|
xa = xaN;
|
||||||
ya = yaN;
|
ya = yaN;
|
||||||
za = zaN;
|
za = zaN;
|
||||||
|
bb = normal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue