mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-15 16:01:51 +00:00
cleanup a bit
This commit is contained in:
parent
546bbcb4e2
commit
8b48dcbf5a
1 changed files with 27 additions and 24 deletions
|
|
@ -66,7 +66,10 @@ static void calc_collision(
|
|||
aabb = aabb + offset;
|
||||
aabb.b.y -= stepHeight + E * 2;
|
||||
|
||||
if ((box->position[nx] - pos[nx]) * sign > 0.0f && box->getAABB().intersects(aabb)) {
|
||||
if ((box->position[nx] - pos[nx]) * sign <= 0.0f || !box->getAABB().intersects(aabb)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
float newnegx = box->position[nx] - boxhalf[nx] - half[nx];
|
||||
float newposx = box->position[nx] + boxhalf[nx] + half[nx];
|
||||
float newx;
|
||||
|
|
@ -82,7 +85,6 @@ static void calc_collision(
|
|||
pos[nx] = newx;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (vel[nx] * sign <= 0.0f && hitbox.groundVelocity[nx] * sign <= 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -161,7 +163,8 @@ static bool calc_collision_neg_y(
|
|||
scale.z = 1.0f - E * 4.0f;
|
||||
aabb.scale(scale);
|
||||
|
||||
if (const auto obstacle = chunks.isObstacleAt(coord.x, coord.y, coord.z, aabb)) {
|
||||
if (const auto obstacle =
|
||||
chunks.isObstacleAt(coord.x, coord.y, coord.z, aabb)) {
|
||||
float newy = std::floor(coord.y) + half.y + obstacle->max().y;
|
||||
if (newy >= pos.y) {
|
||||
vel.y = 0.0f;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue