diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-14 07:48:47 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-14 07:48:47 +0300 |
| commit | 0ae8c5aa7dc47a72ed8617eaf2e1556266434452 (patch) | |
| tree | 1ff766767be807be9452315b1966b04c9cd7ce88 /crates/fparkan-runtime/src/player_motion.rs | |
| parent | a5e3539789aa3eba2b486b3bdfd7961761bc7df4 (diff) | |
| download | fparkan-0ae8c5aa7dc47a72ed8617eaf2e1556266434452.tar.xz fparkan-0ae8c5aa7dc47a72ed8617eaf2e1556266434452.zip | |
fix(game): count full simulation intervals for player movement
Diffstat (limited to 'crates/fparkan-runtime/src/player_motion.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/player_motion.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/crates/fparkan-runtime/src/player_motion.rs b/crates/fparkan-runtime/src/player_motion.rs index 439429cd..7f88d41a 100644 --- a/crates/fparkan-runtime/src/player_motion.rs +++ b/crates/fparkan-runtime/src/player_motion.rs @@ -86,12 +86,17 @@ fn plan_motion( yaw }; let [right, forward] = input.movement.map(|axis| axis.clamp(-1.0, 1.0)); - let distance = 8.0 * input.delta_seconds.min(0.1) / right.hypot(forward).max(1.0); + let distance = 8.0 * input.delta_seconds / right.hypot(forward).max(1.0); let (sin, cos) = yaw.sin_cos(); let xy = [ from[0] + (cos * right - sin * forward) * distance, from[1] + (sin * right + cos * forward) * distance, ]; + if !xy.iter().all(|axis| axis.is_finite()) { + return Err(EngineError::Movement( + "player step exceeds finite coordinates".into(), + )); + } let mut sweep = None; if xy != [from[0], from[1]] { if let (Some(old_ground), Some(new_ground)) = ( |
