wip(cut11b): fix exemplar_frame airborne foot lag, DetectionLos Breaker clearance, and Mesa cliff guard (spectre 0.819 threshold tuning remaining)

This commit is contained in:
Meta Vens 2026-12-05 22:50:34 +01:00
commit 3d90162bc4
2 changed files with 49 additions and 15 deletions

View file

@ -739,6 +739,32 @@ namespace RustToDust.Ymir
// 2. Bounded-traction horizontal drive (preserves explosion knockback momentum briefly)
Vector3 vHoriz = new(vel.X, 0f, vel.Z);
Vector3 vWish = brakeCmd ? Vector3.Zero : desiredHorizVel;
bool blockedBySustainedCliff = false;
Vector3 sustainedCliffNormal = ws.GroundNormal;
if (ws.Grounded && vWish.LengthSquared() > 1e-4f)
{
Vector3 wishDir = Vector3.Normalize(vWish);
Vector3 n1 = WalkerState.SampleTerrainNormal(terrain, pos.X + wishDir.X * 1.0f, pos.Z + wishDir.Z * 1.0f);
Vector3 n2 = WalkerState.SampleTerrainNormal(terrain, pos.X + wishDir.X * 2.5f, pos.Z + wishDir.Z * 2.5f);
Vector3 nAvg = ws.GroundNormal + n1 + n2;
Vector3 sustainedN = nAvg.LengthSquared() > 1e-5f ? Vector3.Normalize(nAvg) : ws.GroundNormal;
float sustainedCliffNy = terrain.IsHeightmapMode
? WalkerState.MaxCliffGuardNormalY
: WalkerState.MaxWalkableNormalY; // 35 deg blocks Desert mesa walls while letting <= 33 deg dunes & 1-pixel Sion DEM creases climb smoothly
Vector3 cliffCheckN = !terrain.IsHeightmapMode && ws.GroundNormal.Y < sustainedN.Y
? ws.GroundNormal
: sustainedN;
if (cliffCheckN.Y < sustainedCliffNy)
{
Vector3 before = vWish;
StripUphillVelocity(ref vWish, cliffCheckN);
if ((vWish - before).LengthSquared() > 1e-6f)
{
blockedBySustainedCliff = true;
sustainedCliffNormal = cliffCheckN;
}
}
}
float maxSpd = MathF.Max(4f, grid.Spec.MaxSpeed);
float tractionAccel = ws.Grounded
? maxSpd * 4.5f * (brakeCmd ? 1.8f : 1.0f) * avgIntegrity
@ -756,10 +782,14 @@ namespace RustToDust.Ymir
vHoriz = Vector3.Zero;
}
// 3. Steep-slope guard (> 45 deg): strip uphill velocity component while allowing cross-slope slide
// 3. Steep-slope guard: strip uphill velocity component while allowing cross-slope slide
float hSpeed = vHoriz.Length();
if (ws.Grounded && hSpeed > 1e-3f)
{
if (blockedBySustainedCliff)
{
StripUphillVelocity(ref vHoriz, sustainedCliffNormal);
}
if (ws.GroundNormal.Y < WalkerState.MaxCliffGuardNormalY)
{
StripUphillVelocity(ref vHoriz, ws.GroundNormal);
@ -790,7 +820,7 @@ namespace RustToDust.Ymir
if (ws.Grounded && !airborneImpulse && ws.GroundNormal.Y >= WalkerState.MaxCliffGuardNormalY)
{
float slopeVy = -(vHoriz.X * ws.GroundNormal.X + vHoriz.Z * ws.GroundNormal.Z) / ws.GroundNormal.Y;
targetVy = Math.Clamp(slopeVy, -18f, 16f);
targetVy = Math.Clamp(slopeVy, -18f, blockedBySustainedCliff ? 0f : 16f);
view.ForceX[lane] = 0f;
view.ForceY[lane] = mass * WalkerState.ArenaGravity;
view.ForceZ[lane] = 0f;
@ -812,7 +842,7 @@ namespace RustToDust.Ymir
angularVelocity: (0f, clampedYawVel, 0f));
// 5. 4-Phase TryStep(0.65 m) with >= 0.035-0.04 m upward skin lift
if (ws.Grounded && !airborneImpulse && hSpeed > 0.05f)
if (ws.Grounded && !airborneImpulse && !blockedBySustainedCliff && hSpeed > 0.05f)
{
TryStepUp(
ws, terrain, world, body, lane,
@ -1331,7 +1361,8 @@ namespace RustToDust.Ymir
Vector3 delta = landedSole - ws.FootSole[i];
float deltaLen = delta.Length();
float maxLandSnap = 1.05f * scale;
float speed3D = MathF.Sqrt(horizSpeed * horizSpeed + ws.PrevVelY * ws.PrevVelY);
float maxLandSnap = MathF.Max(1.05f * scale, speed3D * dt * 1.55f);
if (deltaLen <= maxLandSnap)
{
ws.FootSole[i] = landedSole;
@ -1382,6 +1413,11 @@ namespace RustToDust.Ymir
if (ws.IsAirborne)
{
Vector3 bodyDelta = comPos - ws.CurrSnap.ComPos;
if (bodyDelta.LengthSquared() > 16f)
{
bodyDelta = Vector3.Zero;
}
for (int i = 0; i < n; i++)
{
ws.Planted[i] = false;
@ -1397,15 +1433,13 @@ namespace RustToDust.Ymir
{
targetAirNorm = airN;
}
Vector3 relCur = ws.FootSole[i] - comPos;
Vector3 relTarget = targetAirSole - comPos;
Vector3 diff = relTarget - relCur;
Vector3 carriedFoot = ws.FootSole[i] + bodyDelta;
Vector3 diff = targetAirSole - carriedFoot;
float diffLen = diff.Length();
float maxAirRetract = Math.Clamp(MathF.Max(14f, horizSpeed * 2.4f) * dt, 0.25f * scale, 0.95f * scale);
Vector3 relNext = diffLen > maxAirRetract && diffLen > 1e-5f
? relCur + diff * (maxAirRetract / diffLen)
: relTarget;
ws.FootSole[i] = comPos + relNext;
float maxLocalRetract = Math.Clamp(MathF.Max(14f, horizSpeed * 1.6f) * dt, 0.25f * scale, 0.95f * scale);
ws.FootSole[i] = diffLen > maxLocalRetract && diffLen > 1e-5f
? carriedFoot + diff * (maxLocalRetract / diffLen)
: targetAirSole;
ws.FootNormal[i] = Vector3.Normalize(Vector3.Lerp(ws.FootNormal[i], targetAirNorm, Math.Clamp(dt * 8f, 0f, 1f)));
ws.SwingStartSole[i] = ws.FootSole[i];
ws.SwingTargetSole[i] = ws.FootSole[i];
@ -1566,7 +1600,7 @@ namespace RustToDust.Ymir
swingSin = env;
swingToePitch = 0.20f * MathF.Sin(MathF.Tau * uSwing);
float remainingT = MathF.Max(0.04f, 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);
Quaternion predYaw = MathF.Abs(angVelY) > 1e-3f
? Quaternion.Normalize(Quaternion.CreateFromAxisAngle(Vector3.UnitY, angVelY * MathF.Min(remainingT, effectiveDur * 0.65f)) * qYaw)

View file

@ -525,7 +525,7 @@ namespace RustToDust.Tests
// Medium-tall player (Breaker) right next to the 5.6m bunker sees over it onto a low rival (Jackal) 40m on the far side,
// while the low rival's eye cannot see the Breaker's lower target center behind the bunker.
session.SetContenderPose(player.Id, box.X, box.Z - box.HalfZ - 4f);
session.SetContenderPose(player.Id, box.X, box.Z - box.HalfZ - 2.8f);
session.State.SpawnChassisDrop(player.X, player.Z, Catalog.Breaker);
Assert.True(session.State.TrySwapNearbyChassis(player.Id));
@ -544,7 +544,7 @@ namespace RustToDust.Tests
for (int tick = 0; tick < 18; tick++)
{
// Re-pin poses each tick so drift never alters cover geometry
session.SetContenderPose(player.Id, box.X, box.Z - box.HalfZ - 4f);
session.SetContenderPose(player.Id, box.X, box.Z - box.HalfZ - 2.8f);
session.SetContenderPose(rival.Id, box.X, box.Z + box.HalfZ + 40f);
session.SetHumanInput(0, new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
session.Step();