fix(ymir): fix FirstStepFromIdle break time, biped slope crouch, and post-lean airborne reach clamp
This commit is contained in:
parent
706d9ae26f
commit
b41435408d
1 changed files with 28 additions and 17 deletions
|
|
@ -185,6 +185,13 @@ namespace RustToDust.Ymir
|
|||
LoadG[i] = Grounded ? (n == 2 ? 1.0f : 0.65f) : 0f;
|
||||
}
|
||||
|
||||
if (Grounded && centerHit.Normal.Y < 0.96f)
|
||||
{
|
||||
float meanSoleY = 0f;
|
||||
for (int i = 0; i < n; i++) meanSoleY += FootSole[i].Y;
|
||||
meanSoleY /= n;
|
||||
PelvisOffset = new Vector3(0f, Math.Clamp(meanSoleY - centerHit.SurfaceY, -0.40f * GeomScale, 0.15f * GeomScale), 0f);
|
||||
}
|
||||
if (n == 4 && Grounded)
|
||||
{
|
||||
// Pre-align dorsal quadruped visual pitch/roll & pelvis height to 4-foot support plane at t=0
|
||||
|
|
@ -1463,7 +1470,7 @@ 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.90f), 0.075f, 0.22f);
|
||||
float minBreakTime = Math.Clamp(minDur * (ws.FirstStepFromIdle ? 0.68f : 0.90f), 0.075f, 0.22f);
|
||||
if (ws.SwingTime >= minBreakTime && ws.SwingPhase > overlap + 0.15f)
|
||||
{
|
||||
Vector3 curPelvisShift = Vector3.Transform(ws.PelvisOffset, qYaw);
|
||||
|
|
@ -1705,12 +1712,16 @@ namespace RustToDust.Ymir
|
|||
float limpShiftX = (legIntegrities[1] - legIntegrities[0]) * 0.14f * scale;
|
||||
float targetPelvisX = plantedSignX * lateralAmp * swingSin * speedWeight + limpShiftX;
|
||||
|
||||
float meanSoleY = 0.5f * (ws.FootSole[0].Y + ws.FootSole[1].Y);
|
||||
var centerG = SampleGroundAt(terrain, world, comPos.X, comPos.Z, comPos.Y + 0.6f);
|
||||
float slopeAdjY = Math.Clamp(meanSoleY - centerG.SurfaceY, -0.35f * scale, 0.08f * scale);
|
||||
|
||||
float sprintCrouchFrac = Math.Clamp(horizSpeed / MathF.Max(5f, grid.Spec.MaxSpeed * 0.35f), 0f, 1f);
|
||||
float sprintCrouchCoeff = 0.055f + 0.072f * straightness;
|
||||
float sprintCrouchY = -sprintCrouchCoeff * geom.ModelHalfHeight * scale * sprintCrouchFrac;
|
||||
float vaultAmp = Math.Clamp((0.036f + 0.013f * straightness) * rideHeight, 0.10f * scale, 0.22f * scale) * (0.35f + 0.65f * speedFrac);
|
||||
float vaultAmp = Math.Clamp((0.042f + 0.015f * straightness) * rideHeight, 0.12f * scale, 0.25f * scale) * (0.40f + 0.60f * speedFrac);
|
||||
float vaultY = (swingSin - 0.15f * straightness) * vaultAmp;
|
||||
targetPelvis = new Vector3(targetPelvisX, sprintCrouchY + vaultY + ws.CompressionY, 0f);
|
||||
targetPelvis = new Vector3(targetPelvisX, MathF.Min(0f, slopeAdjY) + sprintCrouchY + vaultY + ws.CompressionY, 0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1867,23 +1878,23 @@ namespace RustToDust.Ymir
|
|||
|
||||
Vector3 pelvisWorldShift = Vector3.Transform(ws.PelvisOffset, qYaw);
|
||||
|
||||
// Keep planted soles locked in world space inside 0.995 * MaxLegReach of visual hip
|
||||
if (ws.Grounded)
|
||||
// Keep all soles locked inside 0.995 * MaxLegReach of visual hip (post-pelvis & post-lean)
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
for (int i = 0; i < n; i++)
|
||||
if (ws.Grounded && !ws.Planted[i])
|
||||
{
|
||||
if (!ws.Planted[i])
|
||||
continue;
|
||||
}
|
||||
Vector3 hipTotalW = comPos + pelvisWorldShift + Vector3.Transform(geom.Legs[i].HipInCom * scale, qTotal);
|
||||
float maxReach = geom.Legs[i].MaxLegReach * scale * 0.995f;
|
||||
Vector3 oldSole = ws.FootSole[i];
|
||||
Vector3 clampedSole = oldSole;
|
||||
if (ClampSoleToReach(hipTotalW, geom.Legs[i].AnkleH * scale, maxReach, comPos, terrain, world, comPos.Y + 0.8f, ref clampedSole, out Vector3 clampedN))
|
||||
{
|
||||
ws.FootSole[i] = clampedSole;
|
||||
ws.FootNormal[i] = clampedN;
|
||||
if (ws.Grounded && ws.Planted[i])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Vector3 hipTotalW = comPos + pelvisWorldShift + Vector3.Transform(geom.Legs[i].HipInCom * scale, qTotal);
|
||||
float maxReach = geom.Legs[i].MaxLegReach * scale * 0.995f;
|
||||
Vector3 oldSole = ws.FootSole[i];
|
||||
Vector3 clampedSole = oldSole;
|
||||
if (ClampSoleToReach(hipTotalW, geom.Legs[i].AnkleH * scale, maxReach, comPos, terrain, world, comPos.Y + 0.8f, ref clampedSole, out Vector3 clampedN))
|
||||
{
|
||||
ws.FootSole[i] = clampedSole;
|
||||
ws.FootNormal[i] = clampedN;
|
||||
float drag = MathF.Sqrt((clampedSole.X - oldSole.X) * (clampedSole.X - oldSole.X) +
|
||||
(clampedSole.Z - oldSole.Z) * (clampedSole.Z - oldSole.Z));
|
||||
if (drag > ws.MaxFootSlipM)
|
||||
|
|
|
|||
Loading…
Reference in a new issue