cut11b: break 0.35>0.25 grounded deadlock, unify air reach margin, and cap liftoff step
This commit is contained in:
parent
70c484a6d4
commit
b1944e9a78
1 changed files with 26 additions and 9 deletions
|
|
@ -1093,14 +1093,14 @@ namespace RustToDust.Ymir
|
|||
}
|
||||
|
||||
// 1b. Suppress spurious Box3D curb/corner solver launch when not on an explicit external blast
|
||||
if (!ws.PreStepHadUpwardImpulse && !ws.InExternalBlastArc && vel.Y > 0.35f)
|
||||
if (!ws.PreStepHadUpwardImpulse && !ws.InExternalBlastArc && vel.Y > 0.25f)
|
||||
{
|
||||
Vector3 curTerrN = WalkerState.SampleTerrainNormal(terrain, pos.X, pos.Z);
|
||||
Vector3 slopeN = ws.GroundNormal.Y >= 0.45f ? ws.GroundNormal : curTerrN;
|
||||
float rawSlopeVy = slopeN.Y >= 0.45f ? -(vel.X * slopeN.X + vel.Z * slopeN.Z) / slopeN.Y : 0f;
|
||||
float maxSlopeVy = (ws.WasGrounded || ws.Grounded)
|
||||
? Math.Clamp(rawSlopeVy + 0.45f, 0.35f, 9.45f)
|
||||
: 0.35f;
|
||||
? Math.Clamp(rawSlopeVy + 0.45f, 0.25f, 9.45f)
|
||||
: 0.25f;
|
||||
if (vel.Y > maxSlopeVy)
|
||||
{
|
||||
vel.Y = maxSlopeVy;
|
||||
|
|
@ -1232,7 +1232,7 @@ namespace RustToDust.Ymir
|
|||
|
||||
ws.Grounded = (steppedThisTick || staticGround || terrGround) &&
|
||||
!(ws.PreStepHadUpwardImpulse && vel.Y > 0.25f) &&
|
||||
(ws.WasGrounded || vel.Y <= 0.25f);
|
||||
(ws.WasGrounded || vel.Y <= 0.25f || (!ws.PreStepHadUpwardImpulse && !ws.InExternalBlastArc));
|
||||
if (staticGround)
|
||||
{
|
||||
ws.GroundNormal = staticNorm;
|
||||
|
|
@ -1251,13 +1251,13 @@ namespace RustToDust.Ymir
|
|||
ws.InExternalBlastArc = false;
|
||||
}
|
||||
|
||||
if (!ws.PreStepHadUpwardImpulse && !ws.InExternalBlastArc && vel.Y > 0.35f)
|
||||
if (!ws.PreStepHadUpwardImpulse && !ws.InExternalBlastArc && vel.Y > 0.25f)
|
||||
{
|
||||
Vector3 slopeN = ws.GroundNormal.Y >= 0.45f ? ws.GroundNormal : gTerrN;
|
||||
float rawSlopeVy = slopeN.Y >= 0.45f ? -(vel.X * slopeN.X + vel.Z * slopeN.Z) / slopeN.Y : 0f;
|
||||
float maxSlopeVy = (ws.Grounded || ws.WasGrounded)
|
||||
? Math.Clamp(rawSlopeVy + 0.45f, 0.35f, 9.45f)
|
||||
: 0.35f;
|
||||
? Math.Clamp(rawSlopeVy + 0.45f, 0.25f, 9.45f)
|
||||
: 0.25f;
|
||||
if (vel.Y > maxSlopeVy)
|
||||
{
|
||||
vel.Y = maxSlopeVy;
|
||||
|
|
@ -1305,6 +1305,7 @@ namespace RustToDust.Ymir
|
|||
int n = geom.LegCount;
|
||||
float rideHeight = geom.ModelRideHeight * scale;
|
||||
bool preTickPlanted0 = ws.Planted[0], preTickPlanted1 = ws.Planted[1], preTickPlanted2 = ws.Planted[2], preTickPlanted3 = ws.Planted[3];
|
||||
Vector3 preTickSole0 = ws.FootSole[0], preTickSole1 = ws.FootSole[1], preTickSole2 = ws.FootSole[2], preTickSole3 = ws.FootSole[3];
|
||||
|
||||
Span<float> legIntegrities = stackalloc float[4];
|
||||
grid.GetLegIntegrities(legIntegrities);
|
||||
|
|
@ -1438,7 +1439,7 @@ namespace RustToDust.Ymir
|
|||
Vector3 nominal = comPos + Vector3.Transform(restLocal, qYaw);
|
||||
Vector3 hipAirW = comPos + airPelvisW + Vector3.Transform(geom.Legs[i].HipInCom * scale, qYaw);
|
||||
float ankleH = geom.Legs[i].AnkleH * scale;
|
||||
float maxAirReach = geom.Legs[i].MaxLegReach * scale * 0.96f;
|
||||
float maxAirReach = geom.Legs[i].MaxLegReach * scale * 0.995f;
|
||||
float targetAnkleY = hipAirW.Y - maxAirReach;
|
||||
var gHit = SampleGroundAt(terrain, world, nominal.X, nominal.Z, comPos.Y + 0.8f);
|
||||
float targetSoleY = MathF.Max(gHit.SurfaceY + airClearance, targetAnkleY - ankleH);
|
||||
|
|
@ -1451,7 +1452,7 @@ namespace RustToDust.Ymir
|
|||
Vector3 carriedFoot = ws.FootSole[i] + bodyDelta;
|
||||
Vector3 diff = targetAirSole - carriedFoot;
|
||||
float diffLen = diff.Length();
|
||||
float maxLocalRetract = Math.Clamp(MathF.Max(6f, horizSpeed * 0.9f) * dt, 0.25f * scale, 0.48f * MathF.Max(1f, scale));
|
||||
float maxLocalRetract = Math.Clamp(MathF.Max(6f, horizSpeed * 0.8f) * dt, 0.25f * scale, 0.35f * MathF.Max(1f, scale));
|
||||
Vector3 nextSole = diffLen > maxLocalRetract && diffLen > 1e-5f
|
||||
? carriedFoot + diff * (maxLocalRetract / diffLen)
|
||||
: targetAirSole;
|
||||
|
|
@ -2175,6 +2176,22 @@ namespace RustToDust.Ymir
|
|||
ws.FootSole[i] = clampedSole;
|
||||
}
|
||||
}
|
||||
|
||||
if (ws.Grounded && !ws.WasAirborne)
|
||||
{
|
||||
bool wasPlanted = i switch { 0 => preTickPlanted0, 1 => preTickPlanted1, 2 => preTickPlanted2, _ => preTickPlanted3 };
|
||||
if (wasPlanted && !ws.Planted[i])
|
||||
{
|
||||
Vector3 startS = i switch { 0 => preTickSole0, 1 => preTickSole1, 2 => preTickSole2, _ => preTickSole3 };
|
||||
Vector3 liftDelta = ws.FootSole[i] - startS;
|
||||
float liftLen = liftDelta.Length();
|
||||
float maxLiftoffMove = 0.31f * MathF.Max(1f, scale);
|
||||
if (liftLen > maxLiftoffMove && liftLen > 1e-5f)
|
||||
{
|
||||
ws.FootSole[i] = startS + liftDelta * (maxLiftoffMove / liftLen);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int activePlantedCount = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue