wip(ymir): cut11b cliff guard 36deg, Smoke walker fixes, breaker crouch checkpoint
This commit is contained in:
parent
3d90162bc4
commit
0e8985e0ac
1 changed files with 94 additions and 32 deletions
|
|
@ -750,7 +750,7 @@ namespace RustToDust.Ymir
|
||||||
Vector3 sustainedN = nAvg.LengthSquared() > 1e-5f ? Vector3.Normalize(nAvg) : ws.GroundNormal;
|
Vector3 sustainedN = nAvg.LengthSquared() > 1e-5f ? Vector3.Normalize(nAvg) : ws.GroundNormal;
|
||||||
float sustainedCliffNy = terrain.IsHeightmapMode
|
float sustainedCliffNy = terrain.IsHeightmapMode
|
||||||
? WalkerState.MaxCliffGuardNormalY
|
? WalkerState.MaxCliffGuardNormalY
|
||||||
: WalkerState.MaxWalkableNormalY; // 35 deg blocks Desert mesa walls while letting <= 33 deg dunes & 1-pixel Sion DEM creases climb smoothly
|
: 0.809017f; // cos(36 deg): blocks Desert mesa walls while letting <= 35 deg dune crests climb smoothly
|
||||||
Vector3 cliffCheckN = !terrain.IsHeightmapMode && ws.GroundNormal.Y < sustainedN.Y
|
Vector3 cliffCheckN = !terrain.IsHeightmapMode && ws.GroundNormal.Y < sustainedN.Y
|
||||||
? ws.GroundNormal
|
? ws.GroundNormal
|
||||||
: sustainedN;
|
: sustainedN;
|
||||||
|
|
@ -1465,7 +1465,8 @@ namespace RustToDust.Ymir
|
||||||
float minDur = scale < 0.70f ? 0.085f : Math.Clamp(0.24f * MathF.Sqrt(hScale), 0.23f, 0.34f);
|
float minDur = scale < 0.70f ? 0.085f : Math.Clamp(0.24f * MathF.Sqrt(hScale), 0.23f, 0.34f);
|
||||||
float effectiveDur = baseDur * (1f - 0.28f * speedFrac);
|
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 crouchFrac = n == 2 ? Math.Clamp(horizSpeed / MathF.Max(6f, grid.Spec.MaxSpeed * 0.42f), 0f, 1f) : speedFrac;
|
||||||
float crouchBias = n == 2 ? 0.135f * geom.ModelHalfHeight * scale * crouchFrac : 0f;
|
float crouchCoeff = geom.ModelHalfHeight < 3.20f ? 0.115f : 0.055f;
|
||||||
|
float crouchBias = n == 2 ? crouchCoeff * geom.ModelHalfHeight * scale * crouchFrac : 0f;
|
||||||
|
|
||||||
// Bound step duration so stance travel stays inside physical horizontal reach at sprint speed
|
// Bound step duration so stance travel stays inside physical horizontal reach at sprint speed
|
||||||
if (horizSpeed > 1.0f)
|
if (horizSpeed > 1.0f)
|
||||||
|
|
@ -1520,30 +1521,62 @@ namespace RustToDust.Ymir
|
||||||
if (!IsInGroup(n, i, ws.StanceGroup))
|
if (!IsInGroup(n, i, ws.StanceGroup))
|
||||||
{
|
{
|
||||||
Vector3 plantSource = ws.SwingTargetSole[i];
|
Vector3 plantSource = ws.SwingTargetSole[i];
|
||||||
if (earlyBreak && ws.SwingPhase < 0.96f)
|
float maxPlantStep = MathF.Max(1.15f * scale, horizSpeed * dt * 2.2f);
|
||||||
|
bool earlyQuadClamp = earlyBreak && !(n == 2 && scale >= 0.70f);
|
||||||
|
if (earlyBreak)
|
||||||
{
|
{
|
||||||
if (n == 2 && scale >= 0.70f)
|
if (n == 2 && scale >= 0.70f)
|
||||||
{
|
{
|
||||||
plantSource = ws.FootSole[i];
|
if (ws.SwingPhase < 0.96f)
|
||||||
|
{
|
||||||
|
plantSource = ws.FootSole[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (ws.SwingPhase < 0.96f)
|
||||||
{
|
{
|
||||||
Vector3 stepVec = ws.SwingTargetSole[i] - ws.FootSole[i];
|
Vector3 stepVec = ws.SwingTargetSole[i] - ws.FootSole[i];
|
||||||
float stepDist = stepVec.Length();
|
float stepDist = stepVec.Length();
|
||||||
float maxPlantStep = MathF.Max(1.15f * scale, horizSpeed * dt * 2.2f);
|
|
||||||
plantSource = stepDist > maxPlantStep && stepDist > 1e-5f
|
plantSource = stepDist > maxPlantStep && stepDist > 1e-5f
|
||||||
? ws.FootSole[i] + stepVec * (maxPlantStep / stepDist)
|
? ws.FootSole[i] + stepVec * (maxPlantStep / stepDist)
|
||||||
: ws.SwingTargetSole[i];
|
: ws.SwingTargetSole[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vector3 plantHip = comPos + curPelvisW + Vector3.Transform(geom.Legs[i].HipInCom * scale, qYaw);
|
Vector3 plantHip = comPos + curPelvisW + Vector3.Transform(geom.Legs[i].HipInCom * scale, qYaw);
|
||||||
|
float plantAnkleH = geom.Legs[i].AnkleH * scale;
|
||||||
|
float plantMaxReach = geom.Legs[i].MaxLegReach * scale * 0.955f;
|
||||||
var gHit = SampleGroundAt(terrain, world, plantSource.X, plantSource.Z, comPos.Y + 0.8f);
|
var gHit = SampleGroundAt(terrain, world, plantSource.X, plantSource.Z, comPos.Y + 0.8f);
|
||||||
Vector3 landedSole = new(plantSource.X, gHit.SurfaceY, plantSource.Z);
|
Vector3 landedSole = new(plantSource.X, gHit.SurfaceY, plantSource.Z);
|
||||||
Vector3 landedNorm = gHit.Normal;
|
Vector3 landedNorm = gHit.Normal;
|
||||||
if (ClampSoleToReach(plantHip, geom.Legs[i].AnkleH * scale, geom.Legs[i].MaxLegReach * scale * 0.955f, terrain, world, comPos.Y + 0.8f, ref landedSole, out Vector3 clampedN))
|
Vector3 preClampSole = landedSole;
|
||||||
|
bool plantClamped = ClampSoleToReach(plantHip, plantAnkleH, plantMaxReach, terrain, world, comPos.Y + 0.8f, ref landedSole, out Vector3 clampedN);
|
||||||
|
if (plantClamped)
|
||||||
{
|
{
|
||||||
landedNorm = clampedN;
|
landedNorm = clampedN;
|
||||||
}
|
}
|
||||||
|
if (earlyQuadClamp && plantClamped && (landedSole - ws.FootSole[i]).Length() > maxPlantStep)
|
||||||
|
{
|
||||||
|
if (MathF.Abs((preClampSole.Y + plantAnkleH) - plantHip.Y) > plantMaxReach &&
|
||||||
|
(preClampSole - ws.FootSole[i]).Length() < (landedSole - ws.FootSole[i]).Length())
|
||||||
|
{
|
||||||
|
landedSole = preClampSole;
|
||||||
|
landedNorm = gHit.Normal;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var curGround = SampleGroundAt(terrain, world, ws.FootSole[i].X, ws.FootSole[i].Z, comPos.Y + 0.8f);
|
||||||
|
Vector3 fallbackSole = new(ws.FootSole[i].X, curGround.SurfaceY, ws.FootSole[i].Z);
|
||||||
|
Vector3 fallbackNorm = curGround.Normal;
|
||||||
|
if (ClampSoleToReach(plantHip, plantAnkleH, plantMaxReach, terrain, world, comPos.Y + 0.8f, ref fallbackSole, out Vector3 fbClampedN))
|
||||||
|
{
|
||||||
|
fallbackNorm = fbClampedN;
|
||||||
|
}
|
||||||
|
if ((fallbackSole - ws.FootSole[i]).Length() < (landedSole - ws.FootSole[i]).Length())
|
||||||
|
{
|
||||||
|
landedSole = fallbackSole;
|
||||||
|
landedNorm = fallbackNorm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
ws.FootSole[i] = landedSole;
|
ws.FootSole[i] = landedSole;
|
||||||
ws.FootNormal[i] = landedNorm;
|
ws.FootNormal[i] = landedNorm;
|
||||||
ws.Planted[i] = true;
|
ws.Planted[i] = true;
|
||||||
|
|
@ -1552,7 +1585,7 @@ namespace RustToDust.Ymir
|
||||||
|
|
||||||
// Heel-strike knee compression dip scaled by mass and gait speed
|
// Heel-strike knee compression dip scaled by mass and gait speed
|
||||||
float massScale = MathF.Sqrt(MathF.Max(800f, mass) / 2600f);
|
float massScale = MathF.Sqrt(MathF.Max(800f, mass) / 2600f);
|
||||||
ws.CompressionVelY -= 2.65f * massScale * (0.45f + 0.55f * speedFrac);
|
ws.CompressionVelY -= 1.50f * massScale * (0.45f + 0.55f * speedFrac);
|
||||||
|
|
||||||
ws.StanceGroup = 1 - ws.StanceGroup;
|
ws.StanceGroup = 1 - ws.StanceGroup;
|
||||||
ws.SwingTime = 0f;
|
ws.SwingTime = 0f;
|
||||||
|
|
@ -1598,7 +1631,7 @@ namespace RustToDust.Ymir
|
||||||
float s = uSwing * uSwing * (3f - 2f * uSwing);
|
float s = uSwing * uSwing * (3f - 2f * uSwing);
|
||||||
float env = MathF.Sin(MathF.PI * uSwing);
|
float env = MathF.Sin(MathF.PI * uSwing);
|
||||||
swingSin = env;
|
swingSin = env;
|
||||||
swingToePitch = 0.20f * MathF.Sin(MathF.Tau * uSwing);
|
swingToePitch = -0.14f * env;
|
||||||
|
|
||||||
float remainingT = MathF.Max(0f, effectiveDur * (1f - u));
|
float remainingT = MathF.Max(0f, effectiveDur * (1f - u));
|
||||||
Vector3 predCom = comPos + new Vector3(vel.X, 0f, vel.Z) * MathF.Min(remainingT, effectiveDur * 0.65f);
|
Vector3 predCom = comPos + new Vector3(vel.X, 0f, vel.Z) * MathF.Min(remainingT, effectiveDur * 0.65f);
|
||||||
|
|
@ -1623,7 +1656,7 @@ namespace RustToDust.Ymir
|
||||||
{
|
{
|
||||||
restLocal.X *= 0.86f;
|
restLocal.X *= 0.86f;
|
||||||
}
|
}
|
||||||
else if (n == 4 && horizSpeed > 0.5f)
|
else if (n == 4 && geom.IsArachnidUp && horizSpeed > 0.5f)
|
||||||
{
|
{
|
||||||
float centerT = 0.50f * speedFrac;
|
float centerT = 0.50f * speedFrac;
|
||||||
restLocal.X += (geom.Legs[i].HipInCom.X * scale - restLocal.X) * centerT;
|
restLocal.X += (geom.Legs[i].HipInCom.X * scale - restLocal.X) * centerT;
|
||||||
|
|
@ -1632,6 +1665,10 @@ namespace RustToDust.Ymir
|
||||||
Vector3 nominal = predCom + Vector3.Transform(restLocal, predYaw);
|
Vector3 nominal = predCom + Vector3.Transform(restLocal, predYaw);
|
||||||
|
|
||||||
float maxStep = geom.MaxStepRadius * scale * (1f - 0.25f * (1f - legIntegrities[i]));
|
float maxStep = geom.MaxStepRadius * scale * (1f - 0.25f * (1f - legIntegrities[i]));
|
||||||
|
if (geom.Legs[i].KneeBendSign < 0f)
|
||||||
|
{
|
||||||
|
maxStep = MathF.Min(maxStep, 1.45f * scale);
|
||||||
|
}
|
||||||
if (stepOffset.Length() > maxStep)
|
if (stepOffset.Length() > maxStep)
|
||||||
{
|
{
|
||||||
stepOffset = Vector2.Normalize(stepOffset) * maxStep;
|
stepOffset = Vector2.Normalize(stepOffset) * maxStep;
|
||||||
|
|
@ -1678,9 +1715,9 @@ namespace RustToDust.Ymir
|
||||||
float sz = ws.SwingStartSole[i].Z + (ws.SwingTargetSole[i].Z - ws.SwingStartSole[i].Z) * s;
|
float sz = ws.SwingStartSole[i].Z + (ws.SwingTargetSole[i].Z - ws.SwingStartSole[i].Z) * s;
|
||||||
float syBase = ws.SwingStartSole[i].Y + (ws.SwingTargetSole[i].Y - ws.SwingStartSole[i].Y) * s;
|
float syBase = ws.SwingStartSole[i].Y + (ws.SwingTargetSole[i].Y - ws.SwingStartSole[i].Y) * s;
|
||||||
float stepDiff = MathF.Min(MathF.Abs(ws.SwingTargetSole[i].Y - ws.SwingStartSole[i].Y), 1.0f * scale);
|
float stepDiff = MathF.Min(MathF.Abs(ws.SwingTargetSole[i].Y - ws.SwingStartSole[i].Y), 1.0f * scale);
|
||||||
float arcLift = (geom.SwingArcHeight * scale * 0.65f + 0.12f * stepDiff) * MathF.Pow(env, 1.40f);
|
float arcLift = (geom.SwingArcHeight * scale * 0.85f + 0.12f * stepDiff) * MathF.Pow(env, 1.40f);
|
||||||
var underHit = SampleGroundAt(terrain, world, sx, sz, comPos.Y + 0.8f);
|
var underHit = SampleGroundAt(terrain, world, sx, sz, comPos.Y + 0.8f);
|
||||||
float minGround = underHit.SurfaceY + 0.06f * scale * env;
|
float minGround = underHit.SurfaceY + 0.10f * scale * env;
|
||||||
ws.FootSole[i] = new Vector3(sx, MathF.Max(syBase + arcLift, minGround), sz);
|
ws.FootSole[i] = new Vector3(sx, MathF.Max(syBase + arcLift, minGround), sz);
|
||||||
|
|
||||||
Vector3 nBlend = Vector3.Lerp(ws.SwingStartNormal[i], ws.SwingTargetNormal[i], s);
|
Vector3 nBlend = Vector3.Lerp(ws.SwingStartNormal[i], ws.SwingTargetNormal[i], s);
|
||||||
|
|
@ -1700,6 +1737,10 @@ namespace RustToDust.Ymir
|
||||||
if (cClear < minAnkleClear) minAnkleClear = cClear;
|
if (cClear < minAnkleClear) minAnkleClear = cClear;
|
||||||
}
|
}
|
||||||
float maxDip = MathF.Max(0.12f * scale, MathF.Min(0.55f * scale, minAnkleClear * 0.45f));
|
float maxDip = MathF.Max(0.12f * scale, MathF.Min(0.55f * scale, minAnkleClear * 0.45f));
|
||||||
|
if (n == 4 && !geom.IsArachnidUp)
|
||||||
|
{
|
||||||
|
maxDip = MathF.Min(maxDip, 0.06f * scale);
|
||||||
|
}
|
||||||
ws.CompressionY = Math.Clamp(ws.CompressionY + ws.CompressionVelY * dt, -maxDip, 0.16f * scale);
|
ws.CompressionY = Math.Clamp(ws.CompressionY + ws.CompressionVelY * dt, -maxDip, 0.16f * scale);
|
||||||
|
|
||||||
Vector3 targetPelvis = Vector3.Zero;
|
Vector3 targetPelvis = Vector3.Zero;
|
||||||
|
|
@ -1716,23 +1757,27 @@ namespace RustToDust.Ymir
|
||||||
float targetPelvisX = plantedSignX * lateralAmp * swingSin * speedWeight + limpShiftX;
|
float targetPelvisX = plantedSignX * lateralAmp * swingSin * speedWeight + limpShiftX;
|
||||||
|
|
||||||
float sprintCrouchFrac = Math.Clamp(horizSpeed / MathF.Max(6f, grid.Spec.MaxSpeed * 0.42f), 0f, 1f);
|
float sprintCrouchFrac = Math.Clamp(horizSpeed / MathF.Max(6f, grid.Spec.MaxSpeed * 0.42f), 0f, 1f);
|
||||||
float sprintCrouchY = -0.135f * geom.ModelHalfHeight * scale * sprintCrouchFrac;
|
bool isCompactBiped = geom.ModelHalfHeight < 3.20f;
|
||||||
float vaultAmp = 0.11f * scale * (0.35f + 0.65f * speedFrac);
|
float sprintCrouchCoeff = isCompactBiped ? 0.115f : 0.055f;
|
||||||
float vaultY = (swingSin - 0.35f) * vaultAmp;
|
float sprintCrouchY = -sprintCrouchCoeff * geom.ModelHalfHeight * scale * sprintCrouchFrac;
|
||||||
|
float vaultAmp = (isCompactBiped ? 0.11f : 0.09f) * scale * (0.35f + 0.65f * speedFrac);
|
||||||
|
float vaultY = (isCompactBiped ? (swingSin - 0.35f) : swingSin) * vaultAmp;
|
||||||
targetPelvis = new Vector3(targetPelvisX, sprintCrouchY + vaultY + ws.CompressionY, 0f);
|
targetPelvis = new Vector3(targetPelvisX, sprintCrouchY + vaultY + ws.CompressionY, 0f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float meanSoleY = 0.25f * (ws.FootSole[0].Y + ws.FootSole[1].Y + ws.FootSole[2].Y + ws.FootSole[3].Y);
|
float meanSoleY = 0.25f * (ws.FootSole[0].Y + ws.FootSole[1].Y + ws.FootSole[2].Y + ws.FootSole[3].Y);
|
||||||
var centerG = SampleGroundAt(terrain, world, comPos.X, comPos.Z, comPos.Y + 0.6f);
|
var centerG = SampleGroundAt(terrain, world, comPos.X, comPos.Z, comPos.Y + 0.6f);
|
||||||
float polyAdjY = Math.Clamp(meanSoleY - centerG.SurfaceY, -0.40f * scale, 0.40f * scale);
|
float minPolyAdj = !geom.IsArachnidUp ? -0.06f * scale : -0.35f * scale;
|
||||||
|
float polyAdjY = Math.Clamp(meanSoleY - centerG.SurfaceY, minPolyAdj, 0.40f * scale);
|
||||||
float diagSignX = (ws.Planted[0] && !ws.Planted[1]) ? +1f : ((!ws.Planted[0] && ws.Planted[1]) ? -1f : 0f);
|
float diagSignX = (ws.Planted[0] && !ws.Planted[1]) ? +1f : ((!ws.Planted[0] && ws.Planted[1]) ? -1f : 0f);
|
||||||
float latShiftX = diagSignX * 0.08f * scale * swingSin * Math.Clamp(horizSpeed / 6.0f, 0.25f, 1f);
|
float latShiftX = diagSignX * 0.08f * scale * swingSin * Math.Clamp(horizSpeed / 6.0f, 0.25f, 1f);
|
||||||
float vaultY = (swingSin - 0.35f) * 0.045f * scale * (0.25f + 0.75f * speedFrac);
|
float baseLift = !geom.IsArachnidUp ? 0.02f * scale : 0.04f * scale;
|
||||||
|
float vaultY = swingSin * 0.065f * scale * (0.25f + 0.75f * speedFrac) + baseLift;
|
||||||
targetPelvis = new Vector3(latShiftX, polyAdjY + vaultY + ws.CompressionY, 0f);
|
targetPelvis = new Vector3(latShiftX, polyAdjY + vaultY + ws.CompressionY, 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float pelvisBlend = Math.Clamp(dt * 24f, 0f, 1f);
|
float pelvisBlend = Math.Clamp(dt * 14f, 0f, 1f);
|
||||||
ws.PelvisOffset = Vector3.Lerp(ws.PelvisOffset, targetPelvis, pelvisBlend);
|
ws.PelvisOffset = Vector3.Lerp(ws.PelvisOffset, targetPelvis, pelvisBlend);
|
||||||
|
|
||||||
// Secondary Damped Torso Spring (<= 8 deg bipeds, <= 14.5 deg dorsal quads)
|
// Secondary Damped Torso Spring (<= 8 deg bipeds, <= 14.5 deg dorsal quads)
|
||||||
|
|
@ -1831,11 +1876,12 @@ namespace RustToDust.Ymir
|
||||||
Quaternion qLean = Quaternion.CreateFromYawPitchRoll(0f, ws.LeanPitch, ws.LeanRoll);
|
Quaternion qLean = Quaternion.CreateFromYawPitchRoll(0f, ws.LeanPitch, ws.LeanRoll);
|
||||||
Quaternion qTotal = Quaternion.Normalize(qYaw * qLean);
|
Quaternion qTotal = Quaternion.Normalize(qYaw * qLean);
|
||||||
|
|
||||||
// Prevent planted legs from hyper-extending vertically over steep ridges/strides by dropping pelvis when needed
|
// Prevent planted legs from hyper-extending or hitting MinLegReach over ridges/strides, rate-limited so actuators track cleanly
|
||||||
if (ws.Grounded)
|
if (ws.Grounded)
|
||||||
{
|
{
|
||||||
Vector3 horizPelvisShift = Vector3.Transform(new Vector3(ws.PelvisOffset.X, 0f, ws.PelvisOffset.Z), qYaw);
|
Vector3 horizPelvisShift = Vector3.Transform(new Vector3(ws.PelvisOffset.X, 0f, ws.PelvisOffset.Z), qYaw);
|
||||||
float maxAllowedPelvisY = float.PositiveInfinity;
|
float maxAllowedPelvisY = float.PositiveInfinity;
|
||||||
|
float minAllowedPelvisY = -0.85f * scale;
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
if (!ws.Planted[i]) continue;
|
if (!ws.Planted[i]) continue;
|
||||||
|
|
@ -1844,14 +1890,30 @@ namespace RustToDust.Ymir
|
||||||
float dx = (comPos.X + horizPelvisShift.X + hipOff.X) - ankle.X;
|
float dx = (comPos.X + horizPelvisShift.X + hipOff.X) - ankle.X;
|
||||||
float dz = (comPos.Z + horizPelvisShift.Z + hipOff.Z) - ankle.Z;
|
float dz = (comPos.Z + horizPelvisShift.Z + hipOff.Z) - ankle.Z;
|
||||||
float hSq = dx * dx + dz * dz;
|
float hSq = dx * dx + dz * dz;
|
||||||
float maxR = geom.Legs[i].MaxLegReach * scale * 0.985f;
|
float maxR = geom.Legs[i].MaxLegReach * scale * 0.992f;
|
||||||
float remY = MathF.Sqrt(MathF.Max(0f, maxR * maxR - hSq));
|
float remYMax = MathF.Sqrt(MathF.Max(0f, maxR * maxR - hSq));
|
||||||
float maxComY = ankle.Y - hipOff.Y + remY;
|
float maxComY = ankle.Y - hipOff.Y + remYMax;
|
||||||
maxAllowedPelvisY = MathF.Min(maxAllowedPelvisY, maxComY - comPos.Y);
|
maxAllowedPelvisY = MathF.Min(maxAllowedPelvisY, maxComY - comPos.Y);
|
||||||
|
|
||||||
|
float minR = geom.Legs[i].MinLegReach * scale * (n == 4 ? 1.15f : 1.02f);
|
||||||
|
float remYMin = MathF.Sqrt(MathF.Max(0f, minR * minR - hSq));
|
||||||
|
float minComY = ankle.Y - hipOff.Y + remYMin;
|
||||||
|
minAllowedPelvisY = MathF.Max(minAllowedPelvisY, minComY - comPos.Y);
|
||||||
}
|
}
|
||||||
if (maxAllowedPelvisY < ws.PelvisOffset.Y)
|
if (minAllowedPelvisY > maxAllowedPelvisY)
|
||||||
{
|
{
|
||||||
ws.PelvisOffset.Y = MathF.Max(-0.85f * scale, maxAllowedPelvisY);
|
minAllowedPelvisY = maxAllowedPelvisY;
|
||||||
|
}
|
||||||
|
float clampedPelvisY = Math.Clamp(ws.PelvisOffset.Y, minAllowedPelvisY, maxAllowedPelvisY);
|
||||||
|
if (clampedPelvisY < ws.PelvisOffset.Y)
|
||||||
|
{
|
||||||
|
float maxDropPerTick = 2.8f * scale * dt;
|
||||||
|
ws.PelvisOffset.Y = MathF.Max(clampedPelvisY, ws.PelvisOffset.Y - maxDropPerTick);
|
||||||
|
}
|
||||||
|
else if (clampedPelvisY > ws.PelvisOffset.Y)
|
||||||
|
{
|
||||||
|
float maxRisePerTick = 2.8f * scale * dt;
|
||||||
|
ws.PelvisOffset.Y = MathF.Min(clampedPelvisY, ws.PelvisOffset.Y + maxRisePerTick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1890,14 +1952,14 @@ namespace RustToDust.Ymir
|
||||||
if (ws.Grounded && ws.Planted[i]) activePlantedCount++;
|
if (ws.Grounded && ws.Planted[i]) activePlantedCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
float subDt = dt * 0.5f;
|
float subDt = dt * 0.25f;
|
||||||
float limbI = MathF.Max(1f, mass * scale * scale * 0.025f);
|
float limbI = MathF.Max(1f, mass * scale * scale * 0.025f);
|
||||||
float kpStance = limbI * 1200f;
|
float kpStance = limbI * (n == 4 ? 2600f : 3800f);
|
||||||
float kpSwing = limbI * 850f;
|
float kpSwing = limbI * (n == 4 ? 1900f : 2800f);
|
||||||
float kdStance = limbI * (2f * 0.88f * MathF.Sqrt(1200f));
|
float kdStance = limbI * (2f * (n == 4 ? 0.84f : 0.75f) * MathF.Sqrt(n == 4 ? 2600f : 3800f));
|
||||||
float kdSwing = limbI * (2f * 0.85f * MathF.Sqrt(850f));
|
float kdSwing = limbI * (2f * (n == 4 ? 0.84f : 0.75f) * MathF.Sqrt(n == 4 ? 1900f : 2800f));
|
||||||
float tauLimitBase = limbI * 650f;
|
float tauLimitBase = limbI * 700f;
|
||||||
float tauLimitAnkle = limbI * 450f;
|
float tauLimitAnkle = limbI * 600f;
|
||||||
|
|
||||||
float impactSpike = Math.Clamp(-ws.CompressionVelY * 0.55f, 0f, 1.4f);
|
float impactSpike = Math.Clamp(-ws.CompressionVelY * 0.55f, 0f, 1.4f);
|
||||||
|
|
||||||
|
|
@ -1915,7 +1977,7 @@ namespace RustToDust.Ymir
|
||||||
float tauAnkleMax = tauLimitAnkle * legIntegrities[i];
|
float tauAnkleMax = tauLimitAnkle * legIntegrities[i];
|
||||||
|
|
||||||
ref var act = ref ws.Actuators[i];
|
ref var act = ref ws.Actuators[i];
|
||||||
for (int sub = 0; sub < 2; sub++)
|
for (int sub = 0; sub < 4; sub++)
|
||||||
{
|
{
|
||||||
StepDof(ref act.Theta.HipPitch, ref act.Omega.HipPitch, target.HipPitch, kp, kd, tauMax, limbI, 0f, subDt);
|
StepDof(ref act.Theta.HipPitch, ref act.Omega.HipPitch, target.HipPitch, kp, kd, tauMax, limbI, 0f, subDt);
|
||||||
StepDof(ref act.Theta.HipRoll, ref act.Omega.HipRoll, target.HipRoll, kp, kd, tauMax, limbI, 0f, subDt);
|
StepDof(ref act.Theta.HipRoll, ref act.Omega.HipRoll, target.HipRoll, kp, kd, tauMax, limbI, 0f, subDt);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue