cut11b: guard planted contact on terrain clearance and size break time by step radius
This commit is contained in:
parent
7fc5d716e0
commit
49a5df2fb9
1 changed files with 26 additions and 12 deletions
|
|
@ -1328,14 +1328,19 @@ namespace RustToDust.Ymir
|
|||
float maxLandSnap = 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);
|
||||
bool touchesGround = landedSole.Y <= landCheck.SurfaceY + 0.055f * scale;
|
||||
ws.FootSole[i] = landedSole;
|
||||
ws.FootNormal[i] = landedNorm;
|
||||
ws.SwingStartSole[i] = landedSole;
|
||||
ws.SwingStartNormal[i] = landedNorm;
|
||||
ws.SwingTargetSole[i] = landedSole;
|
||||
ws.SwingTargetNormal[i] = landedNorm;
|
||||
ws.Planted[i] = true;
|
||||
plantedOnLanding++;
|
||||
ws.Planted[i] = touchesGround;
|
||||
if (touchesGround)
|
||||
{
|
||||
plantedOnLanding++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1479,7 +1484,8 @@ namespace RustToDust.Ymir
|
|||
|
||||
// Early step-completion break if a planted leg reaches > effectiveBreakFrac * MaxLegReach
|
||||
bool earlyBreak = false;
|
||||
float minBreakTime = Math.Clamp(minDur * (ws.FirstStepFromIdle ? 0.68f : 0.90f), 0.075f, 0.22f);
|
||||
float reachBreakTime = 0.72f * geom.MaxStepRadius * scale / MathF.Max(4f, horizSpeed);
|
||||
float minBreakTime = Math.Clamp(MathF.Min(minDur * (ws.FirstStepFromIdle ? 0.68f : 0.90f), reachBreakTime), 0.060f, 0.22f);
|
||||
if (ws.SwingTime >= minBreakTime && ws.SwingPhase > overlap + 0.15f)
|
||||
{
|
||||
Vector3 curPelvisShift = Vector3.Transform(ws.PelvisOffset, qYaw);
|
||||
|
|
@ -1512,6 +1518,8 @@ namespace RustToDust.Ymir
|
|||
Vector3 curPelvisW = Vector3.Transform(ws.PelvisOffset, qYaw);
|
||||
Span<Vector3> candSole = stackalloc Vector3[4];
|
||||
Span<Vector3> candNorm = stackalloc Vector3[4];
|
||||
Span<bool> candTouchesGround = stackalloc bool[4];
|
||||
candTouchesGround.Fill(true);
|
||||
bool deferEarlyBreak = false;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
|
|
@ -1552,13 +1560,12 @@ namespace RustToDust.Ymir
|
|||
landedNorm = fallbackNorm;
|
||||
}
|
||||
}
|
||||
if (earlyBreak && ws.SwingPhase < 1.0f)
|
||||
var groundCheck = SampleGroundAt(terrain, world, landedSole.X, landedSole.Z, comPos.Y + 0.8f);
|
||||
bool touchesGround = landedSole.Y <= groundCheck.SurfaceY + 0.055f * scale;
|
||||
candTouchesGround[i] = touchesGround;
|
||||
if (earlyBreak && ws.SwingPhase < 1.0f && !touchesGround)
|
||||
{
|
||||
var groundCheck = SampleGroundAt(terrain, world, landedSole.X, landedSole.Z, comPos.Y + 0.8f);
|
||||
if (landedSole.Y > groundCheck.SurfaceY + 0.045f * scale)
|
||||
{
|
||||
deferEarlyBreak = true;
|
||||
}
|
||||
deferEarlyBreak = true;
|
||||
}
|
||||
candSole[i] = landedSole;
|
||||
candNorm[i] = landedNorm;
|
||||
|
|
@ -1578,7 +1585,7 @@ namespace RustToDust.Ymir
|
|||
{
|
||||
ws.FootSole[i] = candSole[i];
|
||||
ws.FootNormal[i] = candNorm[i];
|
||||
ws.Planted[i] = true;
|
||||
ws.Planted[i] = candTouchesGround[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1598,6 +1605,7 @@ namespace RustToDust.Ymir
|
|||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
bool keepOldPlanted = ws.Planted[i] && !earlyBreak;
|
||||
if (stepping && !IsInGroup(n, i, ws.StanceGroup))
|
||||
{
|
||||
ws.SwingStartSole[i] = ws.FootSole[i];
|
||||
|
|
@ -1605,7 +1613,9 @@ namespace RustToDust.Ymir
|
|||
ws.SwingTargetSole[i] = ws.FootSole[i];
|
||||
ws.SwingTargetNormal[i] = ws.FootNormal[i];
|
||||
}
|
||||
ws.Planted[i] = !earlyBreak || IsInGroup(n, i, ws.StanceGroup);
|
||||
ws.Planted[i] = IsInGroup(n, i, ws.StanceGroup)
|
||||
? (ws.Planted[i] || ws.FootSole[i].Y <= SampleGroundAt(terrain, world, ws.FootSole[i].X, ws.FootSole[i].Z, comPos.Y + 0.8f).SurfaceY + 0.055f * scale)
|
||||
: keepOldPlanted;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -1614,7 +1624,11 @@ namespace RustToDust.Ymir
|
|||
{
|
||||
if (IsInGroup(n, i, ws.StanceGroup))
|
||||
{
|
||||
ws.Planted[i] = true;
|
||||
if (!ws.Planted[i])
|
||||
{
|
||||
var gCheck = SampleGroundAt(terrain, world, ws.FootSole[i].X, ws.FootSole[i].Z, comPos.Y + 0.8f);
|
||||
ws.Planted[i] = ws.FootSole[i].Y <= gCheck.SurfaceY + 0.055f * scale;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue