physics substeps calculation fix

This commit is contained in:
MihailRis
2023-12-10 21:50:53 +03:00
parent 2ba9125804
commit 00db63723a
+4 -2
View File
@@ -69,12 +69,14 @@ void Player::update(
hitbox->velocity.z += dir.z * speed * delta * 9; hitbox->velocity.z += dir.z * speed * delta * 9;
} }
int substeps = (int)(delta * 1000); float vel = std::max(glm::length(hitbox->velocity * 0.25f), 1.0f);
substeps = std::min(100, std::max(0, substeps)); int substeps = int(delta * vel * 1000);
substeps = std::min(100, std::max(1, substeps));
level->physics->step(level->chunks, hitbox, level->physics->step(level->chunks, hitbox,
delta, substeps, delta, substeps,
crouch, flight ? 0.0f : 1.0f, crouch, flight ? 0.0f : 1.0f,
!noclip); !noclip);
if (flight && hitbox->grounded) { if (flight && hitbox->grounded) {
flight = false; flight = false;
} }