cut11b(ymir): gate short durFloor by tick reach ratio and harden ProjectSoleAboveGroundWithinReach
This commit is contained in:
parent
1020d9305e
commit
5855e6768c
1 changed files with 25 additions and 4 deletions
|
|
@ -1552,7 +1552,7 @@ namespace RustToDust.Ymir
|
|||
float availReach = geom.Legs[i].MaxLegReach * scale;
|
||||
float maxHorizStride = MathF.Sqrt(MathF.Max(0.25f * scale * scale, availReach * availReach - nominalDy * nominalDy));
|
||||
float reachDur = (0.92f * maxHorizStride) / horizSpeed;
|
||||
if (reachDur < 0.085f && reachDur < durFloor)
|
||||
if (horizSpeed * dt > 0.18f * availReach && reachDur < durFloor)
|
||||
{
|
||||
durFloor = MathF.Max(0.062f, reachDur);
|
||||
}
|
||||
|
|
@ -2531,7 +2531,7 @@ namespace RustToDust.Ymir
|
|||
}
|
||||
|
||||
sole.Y = minY;
|
||||
for (int iter = 0; iter < 4; iter++)
|
||||
for (int iter = 0; iter < 6; iter++)
|
||||
{
|
||||
Vector3 ank = sole + under.Normal * ankleH;
|
||||
Vector3 d = ank - hipWorld;
|
||||
|
|
@ -2561,8 +2561,8 @@ namespace RustToDust.Ymir
|
|||
else
|
||||
{
|
||||
// Ground at sole XZ lies above hip upper sphere: step horizontally inward toward hipWorld
|
||||
sole.X += (hipWorld.X - sole.X) * 0.35f;
|
||||
sole.Z += (hipWorld.Z - sole.Z) * 0.35f;
|
||||
sole.X += (hipWorld.X - sole.X) * 0.45f;
|
||||
sole.Z += (hipWorld.Z - sole.Z) * 0.45f;
|
||||
under = SampleGroundAt(terrain, world, sole.X, sole.Z, referenceMaxY);
|
||||
sole.Y = under.SurfaceY + clearance;
|
||||
}
|
||||
|
|
@ -2573,6 +2573,27 @@ namespace RustToDust.Ymir
|
|||
{
|
||||
sole.Y = under.SurfaceY + clearance;
|
||||
}
|
||||
Vector3 finalAnk = sole + under.Normal * ankleH;
|
||||
if ((finalAnk - hipWorld).Length() > maxReach)
|
||||
{
|
||||
float dy = finalAnk.Y - hipWorld.Y;
|
||||
if (MathF.Abs(dy) < maxReach * 0.995f)
|
||||
{
|
||||
float maxHoriz = MathF.Sqrt(MathF.Max(0.0004f, maxReach * maxReach - dy * dy)) * 0.995f;
|
||||
float dx = finalAnk.X - hipWorld.X;
|
||||
float dz = finalAnk.Z - hipWorld.Z;
|
||||
float hDist = MathF.Sqrt(dx * dx + dz * dz);
|
||||
if (hDist > maxHoriz && hDist > 1e-4f)
|
||||
{
|
||||
float k = maxHoriz / hDist;
|
||||
sole.X = hipWorld.X + dx * k - under.Normal.X * ankleH;
|
||||
sole.Z = hipWorld.Z + dz * k - under.Normal.Z * ankleH;
|
||||
var postUnder = SampleGroundAt(terrain, world, sole.X, sole.Z, referenceMaxY);
|
||||
sole.Y = MathF.Max(sole.Y, postUnder.SurfaceY + clearance);
|
||||
under = postUnder;
|
||||
}
|
||||
}
|
||||
}
|
||||
normal = under.Normal;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue