fix(ymir): fix ClampSoleToReach Phase 2 direction, breaker cadence, and pelvis rate
This commit is contained in:
parent
8921afe9ca
commit
3b5f6ee257
1 changed files with 32 additions and 30 deletions
|
|
@ -1434,8 +1434,8 @@ namespace RustToDust.Ymir
|
|||
{
|
||||
float hScale = MathF.Max(0.30f, rideHeight / 3.20f);
|
||||
float baseDur = Math.Clamp(0.48f * MathF.Sqrt(hScale), 0.24f, 0.58f);
|
||||
float speedDurRatio = Math.Clamp(32f / MathF.Max(8f, grid.Spec.MaxSpeed), 0.65f, 1.0f);
|
||||
float minDur = Math.Clamp(0.24f * hScale * speedDurRatio, 0.085f, 0.32f);
|
||||
float speedDurRatio = Math.Clamp(30f / MathF.Max(8f, grid.Spec.MaxSpeed), 0.65f, 1.0f);
|
||||
float minDur = Math.Clamp(0.24f * MathF.Pow(hScale, 0.65f) * speedDurRatio, 0.085f, 0.32f);
|
||||
float effectiveDur = baseDur * (1f - 0.28f * speedFrac);
|
||||
float crouchFrac = n == 2 ? Math.Clamp(horizSpeed / MathF.Max(6f, grid.Spec.MaxSpeed * 0.42f), 0f, 1f) : speedFrac;
|
||||
float crouchCoeff = 0.055f + 0.072f * straightness;
|
||||
|
|
@ -1463,12 +1463,12 @@ namespace RustToDust.Ymir
|
|||
|
||||
// Early step-completion break if a planted leg reaches > breakFrac * MaxLegReach
|
||||
bool earlyBreak = false;
|
||||
float minBreakTime = Math.Clamp(minDur * (n == 4 && ws.FirstStepFromIdle ? 0.65f : 0.85f), 0.075f, 0.22f);
|
||||
float minBreakTime = Math.Clamp(minDur * (n == 4 && ws.FirstStepFromIdle ? 0.65f : 0.92f), 0.075f, 0.22f);
|
||||
if (ws.SwingTime >= minBreakTime && ws.SwingPhase > overlap + 0.15f)
|
||||
{
|
||||
Vector3 curPelvisShift = Vector3.Transform(ws.PelvisOffset, qYaw);
|
||||
Quaternion curQTotal = Quaternion.Normalize(qYaw * Quaternion.CreateFromYawPitchRoll(0f, ws.LeanPitch, ws.LeanRoll));
|
||||
float breakFrac = n == 4 ? 0.945f : 0.975f;
|
||||
float breakFrac = n == 4 ? 0.945f : 0.960f;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
if (!ws.Planted[i]) continue;
|
||||
|
|
@ -1850,7 +1850,7 @@ namespace RustToDust.Ymir
|
|||
minAllowedPelvisY = maxAllowedPelvisY;
|
||||
}
|
||||
float clampedPelvisY = Math.Clamp(ws.PelvisOffset.Y, minAllowedPelvisY, maxAllowedPelvisY);
|
||||
float maxPelvisRate = 2.4f * scale * dt;
|
||||
float maxPelvisRate = 4.2f * scale * dt;
|
||||
if (clampedPelvisY < ws.PelvisOffset.Y)
|
||||
{
|
||||
ws.PelvisOffset.Y = MathF.Max(-0.85f * scale, MathF.Max(clampedPelvisY, ws.PelvisOffset.Y - maxPelvisRate));
|
||||
|
|
@ -2004,28 +2004,29 @@ namespace RustToDust.Ymir
|
|||
float fx = sole.X;
|
||||
float fz = sole.Z;
|
||||
WalkableSurfaceHit finalHit = g0;
|
||||
float dy0 = (g0.SurfaceY + ankleH) - hipWorld.Y;
|
||||
float dy0 = (g0.SurfaceY + g0.Normal.Y * ankleH) - hipWorld.Y;
|
||||
if (MathF.Abs(dy0) < maxReach * 0.995f)
|
||||
{
|
||||
for (int iter = 0; iter < 3; iter++)
|
||||
for (int iter = 0; iter < 4; iter++)
|
||||
{
|
||||
finalHit = SampleGroundAt(terrain, world, fx, fz, referenceMaxY);
|
||||
float dy = (finalHit.SurfaceY + ankleH) - hipWorld.Y;
|
||||
Vector3 ankOff = finalHit.Normal * ankleH;
|
||||
float dy = (finalHit.SurfaceY + ankOff.Y) - hipWorld.Y;
|
||||
if (MathF.Abs(dy) >= maxReach * 0.995f)
|
||||
{
|
||||
break;
|
||||
}
|
||||
float maxHoriz = MathF.Sqrt(MathF.Max(0.0004f, maxReach * maxReach - dy * dy));
|
||||
float dx = fx - hipWorld.X;
|
||||
float dz = fz - hipWorld.Z;
|
||||
float dx = (fx + ankOff.X) - hipWorld.X;
|
||||
float dz = (fz + ankOff.Z) - hipWorld.Z;
|
||||
float hDist = MathF.Sqrt(dx * dx + dz * dz);
|
||||
if (hDist <= maxHoriz || hDist < 1e-4f)
|
||||
{
|
||||
break;
|
||||
}
|
||||
float k = maxHoriz / hDist;
|
||||
fx = hipWorld.X + dx * k;
|
||||
fz = hipWorld.Z + dz * k;
|
||||
float k = (maxHoriz * 0.995f) / hDist;
|
||||
fx = hipWorld.X + dx * k - ankOff.X;
|
||||
fz = hipWorld.Z + dz * k - ankOff.Z;
|
||||
}
|
||||
|
||||
finalHit = SampleGroundAt(terrain, world, fx, fz, referenceMaxY);
|
||||
|
|
@ -2037,26 +2038,27 @@ namespace RustToDust.Ymir
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Pull inward/uphill toward chassisCenterWorld where ground may be reachable within maxReach
|
||||
Vector2 toCenter = new(chassisCenterWorld.X - hipWorld.X, chassisCenterWorld.Z - hipWorld.Z);
|
||||
float toCenterLen = toCenter.Length();
|
||||
if (toCenterLen > 1e-3f)
|
||||
else
|
||||
{
|
||||
Vector2 dir = toCenter / toCenterLen;
|
||||
float maxStep = MathF.Min(toCenterLen, maxReach * 0.96f);
|
||||
for (int s = 1; s <= 4; s++)
|
||||
// Ground at (fx, fz) is beyond maxReach vertically (steep sidehill / cliff / airborne):
|
||||
// pull progressively from (fx, fz) toward chassisCenterWorld where ground may be reachable.
|
||||
Vector2 fromSoleToCenter = new(chassisCenterWorld.X - fx, chassisCenterWorld.Z - fz);
|
||||
float spanLen = fromSoleToCenter.Length();
|
||||
if (spanLen > 1e-3f)
|
||||
{
|
||||
float t = (s / 4f) * maxStep;
|
||||
float sx = hipWorld.X + dir.X * t;
|
||||
float sz = hipWorld.Z + dir.Y * t;
|
||||
var sh = SampleGroundAt(terrain, world, sx, sz, referenceMaxY);
|
||||
Vector3 sAnkle = new Vector3(sx, sh.SurfaceY, sz) + sh.Normal * ankleH;
|
||||
if ((sAnkle - hipWorld).Length() <= maxReach)
|
||||
for (int s = 1; s <= 4; s++)
|
||||
{
|
||||
sole = new Vector3(sx, sh.SurfaceY, sz);
|
||||
normal = sh.Normal;
|
||||
return true;
|
||||
float t = s / 4f;
|
||||
float sx = fx + fromSoleToCenter.X * t;
|
||||
float sz = fz + fromSoleToCenter.Y * t;
|
||||
var sh = SampleGroundAt(terrain, world, sx, sz, referenceMaxY);
|
||||
Vector3 sAnkle = new Vector3(sx, sh.SurfaceY, sz) + sh.Normal * ankleH;
|
||||
if ((sAnkle - hipWorld).Length() <= maxReach)
|
||||
{
|
||||
sole = new Vector3(sx, sh.SurfaceY, sz);
|
||||
normal = sh.Normal;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue