cleanup a bit

This commit is contained in:
MihailRis 2026-03-04 23:34:04 +03:00
parent 546bbcb4e2
commit 8b48dcbf5a

View file

@ -66,7 +66,10 @@ static void calc_collision(
aabb = aabb + offset; aabb = aabb + offset;
aabb.b.y -= stepHeight + E * 2; 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 newnegx = box->position[nx] - boxhalf[nx] - half[nx];
float newposx = box->position[nx] + boxhalf[nx] + half[nx]; float newposx = box->position[nx] + boxhalf[nx] + half[nx];
float newx; float newx;
@ -82,7 +85,6 @@ static void calc_collision(
pos[nx] = newx; pos[nx] = newx;
} }
} }
}
if (vel[nx] * sign <= 0.0f && hitbox.groundVelocity[nx] * sign <= 0.0f) { if (vel[nx] * sign <= 0.0f && hitbox.groundVelocity[nx] * sign <= 0.0f) {
return; return;
} }
@ -161,7 +163,8 @@ static bool calc_collision_neg_y(
scale.z = 1.0f - E * 4.0f; scale.z = 1.0f - E * 4.0f;
aabb.scale(scale); 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; float newy = std::floor(coord.y) + half.y + obstacle->max().y;
if (newy >= pos.y) { if (newy >= pos.y) {
vel.y = 0.0f; vel.y = 0.0f;