mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
improve it cautiously
This commit is contained in:
parent
6676db3525
commit
7f09c47ffb
1 changed files with 5 additions and 7 deletions
|
|
@ -66,8 +66,8 @@ static void calc_collision_pos(
|
|||
boxAABB.b.y -= stepHeight + E * 2;
|
||||
|
||||
if (box->position[nx] > pos[nx] && box->getAABB().intersects(boxAABB)) {
|
||||
float newnegx = box->position[nx] - boxhalf[nx] - half[nx] - E;
|
||||
float newposx = box->position[nx] + boxhalf[nx] + half[nx] + E;
|
||||
float newnegx = box->position[nx] - boxhalf[nx] - half[nx];
|
||||
float newposx = box->position[nx] + boxhalf[nx] + half[nx];
|
||||
float newx;
|
||||
if (glm::abs(newnegx - pos[nx]) < glm::abs(newposx - pos[nx])) {
|
||||
newx = newnegx;
|
||||
|
|
@ -79,7 +79,6 @@ static void calc_collision_pos(
|
|||
vel[nx] = 0.0f;
|
||||
}
|
||||
pos[nx] = newx;
|
||||
collided[nx] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -138,8 +137,8 @@ static void calc_collision_neg(
|
|||
boxAABB.b.y -= stepHeight + E * 2;
|
||||
|
||||
if (box->position[nx] < pos[nx] && box->getAABB().intersects(boxAABB)) {
|
||||
float newnegx = box->position[nx] - boxhalf[nx] - half[nx] - E;
|
||||
float newposx = box->position[nx] + boxhalf[nx] + half[nx] + E;
|
||||
float newnegx = box->position[nx] - boxhalf[nx] - half[nx];
|
||||
float newposx = box->position[nx] + boxhalf[nx] + half[nx];
|
||||
float newx;
|
||||
if (glm::abs(newnegx - pos[nx]) > glm::abs(newposx - pos[nx])) {
|
||||
newx = newposx;
|
||||
|
|
@ -151,7 +150,6 @@ static void calc_collision_neg(
|
|||
vel[nx] = 0.0f;
|
||||
}
|
||||
pos[nx] = newx;
|
||||
collided[nx] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -448,7 +446,7 @@ void PhysicsSolver::step(
|
|||
calcSubstep(chunks, hitbox, vel, pos, prevGrounded, dt);
|
||||
}
|
||||
|
||||
if (prevGrounded && !hitbox.grounded && vel.y <= 0.0f) {
|
||||
if (prevGrounded && !hitbox.grounded) {
|
||||
vel += hitbox.groundVelocity;
|
||||
hitbox.groundVelocity = {};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue