cut11b: cap cliff-drop swing and hover discontinuities
This commit is contained in:
parent
9c283a1962
commit
1b1c9c614f
1 changed files with 36 additions and 4 deletions
|
|
@ -1582,9 +1582,24 @@ namespace RustToDust.Ymir
|
|||
{
|
||||
if (!IsInGroup(n, i, ws.StanceGroup))
|
||||
{
|
||||
ws.FootSole[i] = candSole[i];
|
||||
ws.FootNormal[i] = candNorm[i];
|
||||
ws.Planted[i] = candTouchesGround[i];
|
||||
if (candTouchesGround[i])
|
||||
{
|
||||
ws.FootSole[i] = candSole[i];
|
||||
ws.FootNormal[i] = candNorm[i];
|
||||
ws.Planted[i] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Foot hovers over a cliff drop-off: keep sole continuous instead of snapping 6m down the cliff
|
||||
Vector3 stepD = candSole[i] - ws.FootSole[i];
|
||||
float stepLen = stepD.Length();
|
||||
float maxHoverStep = MathF.Max(1.15f * scale, horizSpeed * dt * 2.5f);
|
||||
ws.FootSole[i] = stepLen > maxHoverStep && stepLen > 1e-5f
|
||||
? ws.FootSole[i] + stepD * (maxHoverStep / stepLen)
|
||||
: candSole[i];
|
||||
ws.FootNormal[i] = candNorm[i];
|
||||
ws.Planted[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1749,7 +1764,24 @@ namespace RustToDust.Ymir
|
|||
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 minGround = underHit.SurfaceY + 0.10f * scale * legEnv;
|
||||
ws.FootSole[i] = new Vector3(sx, MathF.Max(syBase + arcLift, minGround), sz);
|
||||
Vector3 desiredSole = new(sx, MathF.Max(syBase + arcLift, minGround), sz);
|
||||
Vector3 swingStep = desiredSole - ws.FootSole[i];
|
||||
float swingStepLen = swingStep.Length();
|
||||
float maxSwingStep = MathF.Max(1.65f * scale, horizSpeed * dt * 4.5f);
|
||||
if (swingStepLen > maxSwingStep && swingStepLen > 1e-5f)
|
||||
{
|
||||
Vector3 cappedSole = ws.FootSole[i] + swingStep * (maxSwingStep / swingStepLen);
|
||||
var capHit = SampleGroundAt(terrain, world, cappedSole.X, cappedSole.Z, comPos.Y + 0.8f);
|
||||
if (cappedSole.Y < capHit.SurfaceY)
|
||||
{
|
||||
cappedSole.Y = capHit.SurfaceY;
|
||||
}
|
||||
ws.FootSole[i] = cappedSole;
|
||||
}
|
||||
else
|
||||
{
|
||||
ws.FootSole[i] = desiredSole;
|
||||
}
|
||||
|
||||
Vector3 nBlend = Vector3.Lerp(ws.SwingStartNormal[i], ws.SwingTargetNormal[i], legS);
|
||||
ws.FootNormal[i] = nBlend.LengthSquared() > 1e-6f ? Vector3.Normalize(nBlend) : Vector3.UnitY;
|
||||
|
|
|
|||
Loading…
Reference in a new issue