cut11b: preserve Sion DEM crease climb, cap liftoff/landing deltas, and prioritize 3D reach

This commit is contained in:
Meta Vens 2026-12-06 04:02:39 +01:00
commit 68be0d88ab

View file

@ -809,9 +809,9 @@ namespace RustToDust.Ymir
if (!airborneImpulse && !ws.InExternalBlastArc)
{
Vector3 terrN = WalkerState.SampleTerrainNormal(terrain, pos.X, pos.Z);
float maxAirSlopeVy = terrN.Y >= WalkerState.MaxCliffGuardNormalY
? Math.Clamp(-(vHoriz.X * terrN.X + vHoriz.Z * terrN.Z) / terrN.Y + 0.35f, 0.25f, 9.25f)
: 0.25f;
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;
@ -1103,9 +1103,9 @@ namespace RustToDust.Ymir
if (!ws.PreStepHadUpwardImpulse && !ws.InExternalBlastArc && vel.Y > 0.25f)
{
Vector3 curTerrN = WalkerState.SampleTerrainNormal(terrain, pos.X, pos.Z);
Vector3 slopeN = ws.GroundNormal.Y >= WalkerState.MaxCliffGuardNormalY ? ws.GroundNormal : curTerrN;
float maxSlopeVy = slopeN.Y >= WalkerState.MaxCliffGuardNormalY
? Math.Clamp(-(vel.X * slopeN.X + vel.Z * slopeN.Z) / slopeN.Y + 0.35f, 0.25f, 9.25f)
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;
if (vel.Y > maxSlopeVy)
{
@ -1259,9 +1259,9 @@ namespace RustToDust.Ymir
if (!ws.PreStepHadUpwardImpulse && !ws.InExternalBlastArc && vel.Y > 0.25f)
{
Vector3 slopeN = ws.GroundNormal.Y >= WalkerState.MaxCliffGuardNormalY ? ws.GroundNormal : gTerrN;
float maxSlopeVy = (ws.Grounded || ws.WasGrounded) && slopeN.Y >= WalkerState.MaxCliffGuardNormalY
? Math.Clamp(-(vel.X * slopeN.X + vel.Z * slopeN.Z) / slopeN.Y + 0.35f, 0.25f, 9.25f)
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;
if (vel.Y > maxSlopeVy)
{
@ -1310,7 +1310,6 @@ namespace RustToDust.Ymir
int n = geom.LegCount;
float rideHeight = geom.ModelRideHeight * scale;
bool preTickPlanted0 = ws.Planted[0], preTickPlanted1 = ws.Planted[1], preTickPlanted2 = ws.Planted[2], preTickPlanted3 = ws.Planted[3];
Vector3 startSole0 = ws.FootSole[0], startSole1 = ws.FootSole[1], startSole2 = ws.FootSole[2], startSole3 = ws.FootSole[3];
Span<float> legIntegrities = stackalloc float[4];
grid.GetLegIntegrities(legIntegrities);
@ -1371,7 +1370,7 @@ namespace RustToDust.Ymir
Vector3 delta = landedSole - ws.FootSole[i];
float deltaLen = delta.Length();
float speed3D = MathF.Sqrt(horizSpeed * horizSpeed + ws.PrevVelY * ws.PrevVelY);
float maxLandSnap = MathF.Max(1.05f * scale, speed3D * dt * 1.55f);
float maxLandSnap = MathF.Min(1.50f * MathF.Max(1f, scale), MathF.Max(1.05f * scale, speed3D * dt * 1.55f));
if (deltaLen <= maxLandSnap)
{
var landCheck = SampleGroundAt(terrain, world, landedSole.X, landedSole.Z, comPos.Y + 0.6f);
@ -1457,7 +1456,7 @@ namespace RustToDust.Ymir
Vector3 carriedFoot = ws.FootSole[i] + bodyDelta;
Vector3 diff = targetAirSole - carriedFoot;
float diffLen = diff.Length();
float maxLocalRetract = Math.Clamp(MathF.Max(8f, horizSpeed * 1.1f) * dt, 0.25f * scale, 0.65f * scale);
float maxLocalRetract = Math.Clamp(MathF.Max(6f, horizSpeed * 0.9f) * dt, 0.25f * scale, 0.48f * MathF.Max(1f, scale));
Vector3 nextSole = diffLen > maxLocalRetract && diffLen > 1e-5f
? carriedFoot + diff * (maxLocalRetract / diffLen)
: targetAirSole;
@ -1581,7 +1580,7 @@ namespace RustToDust.Ymir
{
landedNorm = clampedN;
}
float maxLandJump = 1.56f * MathF.Max(1f, scale);
float maxLandJump = 1.42f * MathF.Max(1f, scale);
Vector3 landDelta = landedSole - ws.FootSole[i];
float landDist = landDelta.Length();
bool landCapped = false;
@ -1860,7 +1859,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.56f * MathF.Max(1f, scale), MathF.Max(1.30f * scale, horizSpeed * dt * 3.0f));
float maxSwingStep = MathF.Min(1.38f * MathF.Max(1f, scale), MathF.Max(1.22f * scale, horizSpeed * dt * 2.85f));
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);
@ -2144,7 +2143,7 @@ namespace RustToDust.Ymir
ws.Planted[i] = false;
ws.SwingStartSole[i] = oldSole;
ws.SwingStartNormal[i] = ws.FootNormal[i];
float maxUnplantStep = 0.38f * MathF.Max(1f, scale);
float maxUnplantStep = 0.30f * MathF.Max(1f, scale);
float slipLen = slipVec.Length();
Vector3 nextSole = slipLen > maxUnplantStep && slipLen > 1e-5f
? oldSole + slipVec * (maxUnplantStep / slipLen)
@ -2167,7 +2166,7 @@ namespace RustToDust.Ymir
if (dist > maxReach && dist > 1e-5f)
{
bool justLifted = ws.Grounded && (i switch { 0 => jl0, 1 => jl1, 2 => jl2, _ => jl3 });
float maxRetract = 0.26f * MathF.Max(1f, scale);
float maxRetract = 0.22f * MathF.Max(1f, scale);
float targetDist = justLifted
? MathF.Max(maxReach, dist - maxRetract)
: maxReach;
@ -2177,24 +2176,6 @@ namespace RustToDust.Ymir
ws.FootSole[i] = clampedSole;
}
}
if (ws.Grounded && !ws.WasAirborne)
{
Vector3 tickStartSole = i switch { 0 => startSole0, 1 => startSole1, 2 => startSole2, _ => startSole3 };
Vector3 tickDelta = ws.FootSole[i] - tickStartSole;
float tickDist = tickDelta.Length();
float maxTotalTickMove = 1.56f * MathF.Max(1f, scale);
if (tickDist > maxTotalTickMove && tickDist > 1e-5f)
{
Vector3 capped = tickStartSole + tickDelta * (maxTotalTickMove / tickDist);
var gCap = SampleGroundAt(terrain, world, capped.X, capped.Z, comPos.Y + 0.8f);
if (gCap.SurfaceY <= tickStartSole.Y + maxTotalTickMove * 0.90f && capped.Y < gCap.SurfaceY)
{
capped.Y = gCap.SurfaceY;
}
ws.FootSole[i] = capped;
}
}
}
int activePlantedCount = 0;