Improve water surface height calculation in player locomotion

This commit is contained in:
2026-04-11 22:15:51 +02:00
parent dfc8cdd296
commit 71610b318d

View File

@@ -487,13 +487,16 @@ export function stepPlayerLocomotion(
verticalVelocity = 0;
jumpHoldRemainingMs = 0;
} else if (currentSwimmableWater) {
const waterSurfaceHeight =
currentVolumeState.waterSurfaceHeight ??
options.feetPosition.y + activeShape.eyeHeight;
const targetFeetY =
currentVolumeState.waterSurfaceHeight +
waterSurfaceHeight +
SWIM_HEAD_CLEARANCE -
activeShape.eyeHeight;
const currentHeadSubmerged =
options.feetPosition.y + activeShape.eyeHeight <
currentVolumeState.waterSurfaceHeight;
waterSurfaceHeight;
if (waterVerticalInput !== 0) {
verticalVelocity = waterVerticalInput * swimVerticalSpeed;
@@ -577,10 +580,13 @@ export function stepPlayerLocomotion(
nextVolumeState.inWater &&
nextVolumeState.waterSurfaceHeight !== null &&
!nextShallowWater;
const nextWaterSurfaceHeight =
nextVolumeState.waterSurfaceHeight ??
resolvedMotion.feetPosition.y + activeShape.eyeHeight;
const headSubmerged =
nextSwimmableWater &&
resolvedMotion.feetPosition.y + activeShape.eyeHeight <
nextVolumeState.waterSurfaceHeight;
nextWaterSurfaceHeight;
const headBump =
verticalDisplacement > 0 &&
resolvedMotion.collidedAxes.y &&