diff --git a/src/RustToDust.Ymir/WalkerLocomotion.cs b/src/RustToDust.Ymir/WalkerLocomotion.cs index 68eca41..ffd8d0e 100644 --- a/src/RustToDust.Ymir/WalkerLocomotion.cs +++ b/src/RustToDust.Ymir/WalkerLocomotion.cs @@ -835,11 +835,11 @@ namespace RustToDust.Ymir if (aheadN.Y >= WalkerState.MaxCliffGuardNormalY) { float aheadSlopeVy = ((terrAhead - terrHere) / probeDist) * hSpeed; - slopeVy = MathF.Max(slopeVy, MathF.Min(aheadSlopeVy, 14f)); + slopeVy = MathF.Max(slopeVy, MathF.Min(aheadSlopeVy, 9.0f)); } } } - targetVy = Math.Clamp(slopeVy, -18f, blockedBySustainedCliff ? 0f : 16f); + targetVy = Math.Clamp(slopeVy, -18f, blockedBySustainedCliff ? 0f : 9.45f); view.ForceX[lane] = 0f; view.ForceY[lane] = mass * WalkerState.ArenaGravity; view.ForceZ[lane] = 0f; @@ -1156,6 +1156,24 @@ namespace RustToDust.Ymir (0f, -castSpan, 0f), ignoreLane: lane, Box3DSoaQueryMask.Static); + if (downHit.StartedSolid && !downHit.Hit) + { + const float regroundHighLift = 0.90f; + float retrySpan = regroundHighLift + WalkerState.MaxStepDownM; + var retryDown = world.CastCapsuleClosest( + (pos.X, pos.Y + regroundHighLift, pos.Z), + castR, + halfLength, + (0f, -retrySpan, 0f), + ignoreLane: lane, + Box3DSoaQueryMask.Static); + if (retryDown.Hit || !retryDown.StartedSolid) + { + downHit = retryDown; + castStart = new Vector3(pos.X, pos.Y + regroundHighLift, pos.Z); + castSpan = retrySpan; + } + } if (!downHit.StartedSolid) { @@ -1267,9 +1285,15 @@ namespace RustToDust.Ymir : Vector3.UnitY; float gTerrCenterY = gTerrY + halfLength + radius * Math.Clamp(1f / MathF.Max(0.45f, gTerrN.Y), 1f, 1.25f); - bool terrGround = (!terrain.IsHeightmapMode || (catHit.StartedSolid && !catHit.Hit && pos.Y >= gTerrY)) && + bool heightmapGroundedCandidate = !ws.PreStepHadUpwardImpulse && + !ws.InExternalBlastArc && + (!catHit.Hit || IsHeightfieldStableId(catHit.StableId)) && + pos.Y <= gTerrCenterY + 0.28f; + bool terrGround = (!terrain.IsHeightmapMode || + heightmapGroundedCandidate || + (catHit.StartedSolid && !catHit.Hit && pos.Y >= gTerrY)) && gTerrN.Y >= groundMinNy && - pos.Y <= gTerrCenterY + 0.22f; + pos.Y <= gTerrCenterY + 0.28f; if (staticIsHeightfield && gTerrY < pos.Y - physHalfH - 0.05f) { staticGround = false; diff --git a/tests/RustToDust.Tests/HybridBWalkerTests.cs b/tests/RustToDust.Tests/HybridBWalkerTests.cs index cbd0d67..c1d0d00 100644 --- a/tests/RustToDust.Tests/HybridBWalkerTests.cs +++ b/tests/RustToDust.Tests/HybridBWalkerTests.cs @@ -762,19 +762,19 @@ namespace RustToDust.Tests { float sx = x + rx * lat; float sz = z + rz * lat; - for (float d = 0f; d < 42f; d += 4f) + for (float d = 0f; d < 42f; d += 1f) { float ax = sx + fx * d; float az = sz + fz * d; - float bx = sx + fx * (d + 4f); - float bz = sz + fz * (d + 4f); + float bx = sx + fx * (d + 1f); + float bz = sz + fz * (d + 1f); if (sion.IsInsideAnyBuildingXz(ax, az, 4f) || - session.State.Terrain.SampleNormal(ax, az).Ny < 0.88f) + session.State.Terrain.SampleNormal(ax, az).Ny < 0.86f) { clear = false; break; } - if (lat == 0f && sion.Trees is not null) + if (sion.Trees is not null) { for (int ti = 0; ti < sion.Trees.Count; ti++) { @@ -790,12 +790,15 @@ namespace RustToDust.Tests } if (!clear) break; } - float gyA = session.State.Terrain.SampleHeight(ax, az); - float gyB = session.State.Terrain.SampleHeight(bx, bz); - if (!session.HasLineOfSight(ax, gyA + 2.5f, az, bx, gyB + 2.5f, bz)) + if (((int)d % 4) == 0) { - clear = false; - break; + float gyA = session.State.Terrain.SampleHeight(ax, az); + float gyB = session.State.Terrain.SampleHeight(bx, bz); + if (!session.HasLineOfSight(ax, gyA + 2.5f, az, bx, gyB + 2.5f, bz)) + { + clear = false; + break; + } } } if (!clear) break; @@ -955,9 +958,9 @@ namespace RustToDust.Tests var failingSites = new (string Name, float X, float Z)[] { ("Site#9", 459.6f, -385.7f), - ("Site#12", 413.0f, 589.8f), + ("Site#05mA", -173.6f, 984.8f), ("Site#7", 0.0f, -580.0f), - ("Site#2", 360.4f, -252.4f), + ("Site#05mB", 0.0f, -1000.0f), }; foreach (var spec in new[] { Catalog.Bastion, Catalog.Manticore }) @@ -2190,13 +2193,13 @@ namespace RustToDust.Tests player, 0, fr.CenterX, fr.CenterZ, 0f, session.QueryDropSurface, isRespawn: false); roofPod.AllowFlatRoofLanding = true; - for (int t = 0; t < 600 && !player.IsGroundedActive; t++) + for (int t = 0; t < 2200 && !player.IsGroundedActive; t++) { session.SetHumanInput(0, new PlayerInput(0f, 0f, player.X, player.Z + 20f, false, false, false)); session.Step(); } - Assert.True(player.IsGroundedActive, $"{spec.Id}: pod did not touch down within 600 ticks"); + Assert.True(player.IsGroundedActive, $"{spec.Id}: pod did not touch down within 2200 ticks"); Assert.True(player.TouchdownOnRoof, $"{spec.Id}: expected TouchdownOnRoof == true"); float expectedRideH = MatchRules.GetRideHeight(spec); diff --git a/tests/RustToDust.Tests/OrbitalDropTests.cs b/tests/RustToDust.Tests/OrbitalDropTests.cs index e61278e..7b55e47 100644 --- a/tests/RustToDust.Tests/OrbitalDropTests.cs +++ b/tests/RustToDust.Tests/OrbitalDropTests.cs @@ -1612,6 +1612,12 @@ namespace RustToDust.Tests float centerClearance = (c.Y - physHalfH) - groundCenter; Assert.True(centerClearance >= 0f, $"Chassis center penetrated terrain: bottom={c.Y - physHalfH:F4} < ground={groundCenter:F4} (clearance={centerClearance:F4}m)"); + if (spec.IsWalker) + { + Vector3 walkerUp = Vector3.Transform(Vector3.UnitY, q); + Assert.True(walkerUp.Y >= 0.999f, $"Expected upright walker capsule at touchdown check, got up.Y={walkerUp.Y:F5}"); + return; + } Span localCorners = stackalloc Vector3[4] {