SweepCallback callback = collider.sweep(position, targetPos, VERTICAL_PENETRATION, -1.0f);
float actualDist = Math.max(0,
(remainingDist + VERTICAL_PENETRATION_LEEWAY) * callback.getClosestHitFraction() - VERTICAL_PENETRATION_LEEWAY);
Vector3f expectedMove = new Vector3f(targetPos);
expectedMove.sub(position);
if (expectedMove.lengthSquared() > physics.getEpsilon()) {
expectedMove.normalize();
expectedMove.scale(actualDist);
position.add(expectedMove);
}
remainingDist -= actualDist;