cut11b: preserve steep DEM crease climbs, bound landing tick once, and restore stride bounds

This commit is contained in:
Meta Vens 2026-12-06 04:06:37 +01:00
commit 70c484a6d4

View file

@ -806,16 +806,9 @@ namespace RustToDust.Ymir
}
else
{
if (!airborneImpulse && !ws.InExternalBlastArc)
if (!airborneImpulse && !ws.InExternalBlastArc && targetVy > 9.45f)
{
Vector3 terrN = WalkerState.SampleTerrainNormal(terrain, pos.X, pos.Z);
float maxAirSlopeVy = terrN.Y >= 0.55f
? Math.Clamp(-(vHoriz.X * terrN.X + vHoriz.Z * terrN.Z) / terrN.Y + 0.50f, 1.50f, 9.40f)
: 0.50f;
if (targetVy > maxAirSlopeVy)
{
targetVy = maxAirSlopeVy;
}
targetVy = 9.45f;
}
view.ForceX[lane] = 0f;
view.ForceY[lane] = 0f;
@ -1100,13 +1093,14 @@ namespace RustToDust.Ymir
}
// 1b. Suppress spurious Box3D curb/corner solver launch when not on an explicit external blast
if (!ws.PreStepHadUpwardImpulse && !ws.InExternalBlastArc && vel.Y > 0.25f)
if (!ws.PreStepHadUpwardImpulse && !ws.InExternalBlastArc && vel.Y > 0.35f)
{
Vector3 curTerrN = WalkerState.SampleTerrainNormal(terrain, pos.X, pos.Z);
Vector3 slopeN = ws.GroundNormal.Y >= 0.55f ? ws.GroundNormal : curTerrN;
float maxSlopeVy = (ws.WasGrounded || ws.Grounded) && slopeN.Y >= 0.55f
? Math.Clamp(-(vel.X * slopeN.X + vel.Z * slopeN.Z) / slopeN.Y + 0.45f, 0.25f, 9.40f)
: 0.25f;
Vector3 slopeN = ws.GroundNormal.Y >= 0.45f ? ws.GroundNormal : curTerrN;
float rawSlopeVy = slopeN.Y >= 0.45f ? -(vel.X * slopeN.X + vel.Z * slopeN.Z) / slopeN.Y : 0f;
float maxSlopeVy = (ws.WasGrounded || ws.Grounded)
? Math.Clamp(rawSlopeVy + 0.45f, 0.35f, 9.45f)
: 0.35f;
if (vel.Y > maxSlopeVy)
{
vel.Y = maxSlopeVy;
@ -1257,12 +1251,13 @@ namespace RustToDust.Ymir
ws.InExternalBlastArc = false;
}
if (!ws.PreStepHadUpwardImpulse && !ws.InExternalBlastArc && vel.Y > 0.25f)
if (!ws.PreStepHadUpwardImpulse && !ws.InExternalBlastArc && vel.Y > 0.35f)
{
Vector3 slopeN = ws.GroundNormal.Y >= 0.55f ? ws.GroundNormal : gTerrN;
float maxSlopeVy = (ws.Grounded || ws.WasGrounded) && slopeN.Y >= 0.55f
? Math.Clamp(-(vel.X * slopeN.X + vel.Z * slopeN.Z) / slopeN.Y + 0.45f, 0.25f, 9.40f)
: 0.25f;
Vector3 slopeN = ws.GroundNormal.Y >= 0.45f ? ws.GroundNormal : gTerrN;
float rawSlopeVy = slopeN.Y >= 0.45f ? -(vel.X * slopeN.X + vel.Z * slopeN.Z) / slopeN.Y : 0f;
float maxSlopeVy = (ws.Grounded || ws.WasGrounded)
? Math.Clamp(rawSlopeVy + 0.45f, 0.35f, 9.45f)
: 0.35f;
if (vel.Y > maxSlopeVy)
{
vel.Y = maxSlopeVy;
@ -1473,6 +1468,10 @@ namespace RustToDust.Ymir
ws.SwingPhase = 0f;
ws.FirstStepFromIdle = true;
}
else if (ws.WasAirborne && !ws.IsAirborne)
{
// Landing block above already snapped/bounded foot placement for this tick; skip redundant same-tick swing advance
}
else if (!stepping && !anySwinging)
{
for (int i = 0; i < n; i++)
@ -1580,7 +1579,7 @@ namespace RustToDust.Ymir
{
landedNorm = clampedN;
}
float maxLandJump = 1.42f * MathF.Max(1f, scale);
float maxLandJump = 1.56f * MathF.Max(1f, scale);
Vector3 landDelta = landedSole - ws.FootSole[i];
float landDist = landDelta.Length();
bool landCapped = false;
@ -1859,7 +1858,7 @@ namespace RustToDust.Ymir
float arcScale = Math.Clamp(1.05f - 0.33f * (geom.MeanHipSpan / MathF.Max(0.5f, geom.ModelRideHeight)), 0.65f, 0.85f);
float arcLift = (geom.SwingArcHeight * scale * arcScale + 0.12f * stepDiff) * MathF.Pow(legEnv, 1.40f);
var underHit = SampleGroundAt(terrain, world, sx, sz, comPos.Y + 0.8f);
float maxSwingStep = MathF.Min(1.38f * MathF.Max(1f, scale), MathF.Max(1.22f * scale, horizSpeed * dt * 2.85f));
float maxSwingStep = MathF.Min(1.56f * MathF.Max(1f, scale), MathF.Max(1.50f * scale, horizSpeed * dt * 4.5f));
float clampedUnderY = MathF.Min(underHit.SurfaceY, ws.FootSole[i].Y + maxSwingStep * 0.90f);
float minGround = clampedUnderY + 0.10f * scale * legEnv;
Vector3 desiredSole = new(sx, MathF.Max(syBase + arcLift, minGround), sz);
@ -2168,7 +2167,7 @@ namespace RustToDust.Ymir
bool justLifted = ws.Grounded && (i switch { 0 => jl0, 1 => jl1, 2 => jl2, _ => jl3 });
float maxRetract = 0.22f * MathF.Max(1f, scale);
float targetDist = justLifted
? MathF.Max(maxReach, dist - maxRetract)
? MathF.Min(maxReach * 1.06f, MathF.Max(maxReach, dist - maxRetract))
: maxReach;
Vector3 clampedAnkle = hipTotalW + delta * (targetDist / dist);
Vector3 clampedSole = clampedAnkle - ws.FootNormal[i] * ankleH;