Revert "fix(physics): TS-4 retired — Path-6 steep-poly shortcut deleted"

This reverts commit 5e2be19b4e.
This commit is contained in:
Erik 2026-07-30 17:02:22 +02:00
parent 2e27d066e8
commit a8a7d64b47
5 changed files with 156 additions and 254 deletions

View file

@ -1979,17 +1979,6 @@ public static class BSPQuery
FindWalkableInternal(root, resolved, path, ref validPos, movement, localSpaceZ,
ref hitPoly, ref _hitPolyId, ref changed);
// #116 shape-2 instrumentation (Campaign P final physics slice,
// 2026-07-30; docs/research/2026-07-30-ts4-116-oracle-plan.md
// §3.3 step 1): names whether Path 4's find_walkable probe found
// a candidate for this specific poly set, settling the D4
// first-airborne-frame routing question without a live cdb trace.
if (PhysicsDiagnostics.ProbeIndoorBspEnabled)
{
Console.WriteLine(System.FormattableString.Invariant(
$"[path4-diag] changed={changed} hitPoly={(hitPoly is not null)}"));
}
if (changed && hitPoly is not null)
{
// ACE: var offset = LocalToGlobalVec(validPos.Center - localSphere.Center) * scale
@ -2207,35 +2196,57 @@ public static class BSPQuery
var worldNormal0 = L2W(hitPoly0!.Plane.Normal);
// TS-4 RETIRED (Campaign P final physics slice, 2026-07-30;
// docs/research/2026-07-30-ts4-116-oracle-plan.md §1, §4 item 2).
// The L.4 steep-poly slide-tangent shortcut that used to live
// here (worldNormal0.Z < FloorZ → project-and-Slid,
// SetCollisionNormal + SetSlidingNormal) is deleted. Retail's
// BSP layer never differentiates by slope here — it calls
// SetCollide unconditionally for every hit, steep or shallow
// (acclient_2013_pseudo_c.txt:323783-323821, 0x0053a793;
// no steepness test at this layer at all), and never writes
// collision_info.sliding_normal from the BSP/sphere layer —
// only validate_transition (0x0050ac21/0x0050aa70) does.
// L.4 slide-tangent for steep airborne hits (2026-04-30).
//
// The decisive confirming run (Ts4SteepRoofWedgeCaptureTests):
// with the shortcut removed, a steep-roof fall carrying a
// small residual horizontal velocity (the realistic case —
// WASD input, jump momentum) converges cleanly to the flat
// floor with no freeze
// (FallOntoSteepSlope_WithHorizontalVelocity_...). Only the
// DEGENERATE pure-vertical drop (zero horizontal velocity)
// still freezes — and that freeze is retail-faithful too
// (see the pinned FallOntoSteepSlope_NeverFreezesFor... test
// and AD-56 for the mechanism: AdjustOffset's crease
// projection, Cross(ContactPlane.Normal, SlidingNormal), is
// mathematically orthogonal to a purely-Z input offset,
// crushing it to zero every tick and short-circuiting before
// TransitionalInsert runs again — present identically in the
// raw decomp, ACE's port, and this port).
// For polygons too steep to walk on (worldNormal.Z < FloorZ),
// skip the SetCollide → Path-4 → ContactPlane landing chain.
// That chain commits the body to the steep surface, leading
// to the "stuck in falling animation on the roof" bug — once
// grounded with a steep ContactPlane, our step_up_slide /
// cliff_slide / edge_slide chain can't produce smooth
// descent and the body wedges or "falls a bit at a time"
// when bumped.
//
// ─── SetCollide response (unconditional, retail-faithful) ──
// Instead: project the move along the steep face (remove
// the into-wall displacement), set CollisionNormal +
// SlidingNormal, return Slid. Same shape as Path 5's
// step-up fallback (line 1545-1547) and CylinderCollision
// (TransitionTypes.cs:1518-1522). Position is updated in-
// place; on the next resolver iteration the sphere is
// outside the poly, FindCollisions returns OK, and
// ValidateTransition commits the new position. Body stays
// airborne, falling animation continues, and gravity's
// tangent component drifts the body downhill until it
// slides off the slope's edge.
//
// This is a deliberate deviation from retail (retail uses
// SetCollide unconditionally and lets find_walkable +
// step_up_slide produce the slide). Validated against
// retail debugger trace 2026-04-30: retail body did not
// wedge; our retail-faithful port DID wedge because we're
// missing implementation details of the step_up_slide /
// cliff_slide chain on grounded-steep movement. The
// slide-tangent here produces user-acceptable behavior
// (slides off naturally) while the deeper chain port is
// researched. Filed as L.5+ followup for retail-strict.
if (worldNormal0.Z < PhysicsGlobals.FloorZ)
{
Vector3 currWorld = path.GlobalCurrCenter[0].Origin;
Vector3 endWorld = path.GlobalSphere[0].Origin;
Vector3 gDelta = endWorld - currWorld;
float diff = Vector3.Dot(worldNormal0, gDelta);
if (diff < 0f)
path.AddOffsetToCheckPos(-worldNormal0 * diff);
collisions.SetCollisionNormal(worldNormal0);
collisions.SetSlidingNormal(worldNormal0);
// L.2d slice 1 (2026-05-13): diagnostic side-channel.
if (PhysicsDiagnostics.ProbeBuildingEnabled || PhysicsDiagnostics.ProbeIndoorBspEnabled)
PhysicsDiagnostics.LastBspHitPoly = hitPoly0;
return TransitionState.Slid;
}
// ─── SetCollide response (shallow / walkable) ───────────
// Per retail (acclient_2013_pseudo_c.txt:323783-323821).
path.SetCollide(worldNormal0);
path.WalkableAllowance = PhysicsGlobals.LandingZ;

View file

@ -2034,18 +2034,24 @@ internal static class FlatBspQuery
localToWorld);
}
// TS-4 RETIRED (Campaign P final physics slice, 2026-07-30;
// docs/research/2026-07-30-ts4-116-oracle-plan.md §1, §4 item 2).
// Retail's BSP layer has no steepness test at this layer at all
// (acclient_2013_pseudo_c.txt:323783-323821, 0x0053a793) — every
// hit (steep or shallow) falls through to the same unconditional
// SetCollide. The old L.4 slide-tangent shortcut (worldNormal0.Z
// < FloorZ -> project-and-Slid with its own SetSlidingNormal
// write) is deleted; see BSPQuery.cs's Path 6 for the mirrored
// fix and full citation. Kept in parity with BSPQuery.cs per the
// FlatBspQueryDifferentialTests graph-vs-flat comparison.
Vector3 worldNormal0 = LocalToWorld(
tree.PolygonTable.Polygons[defaultHitPolygonIndex0].Plane.Normal);
if (worldNormal0.Z < PhysicsGlobals.FloorZ)
{
Vector3 currentWorld =
path.GlobalCurrCenter[0].Origin;
Vector3 endWorld =
path.GlobalSphere[0].Origin;
Vector3 globalDelta = endWorld - currentWorld;
float difference = Vector3.Dot(worldNormal0, globalDelta);
if (difference < 0f)
path.AddOffsetToCheckPos(-worldNormal0 * difference);
collisions.SetCollisionNormal(worldNormal0);
collisions.SetSlidingNormal(worldNormal0);
RecordDiagnosticHit(tree, defaultHitPolygonIndex0);
return TransitionState.Slid;
}
path.SetCollide(worldNormal0);
path.WalkableAllowance = PhysicsGlobals.LandingZ;
@ -2067,22 +2073,30 @@ internal static class FlatBspQuery
if (defaultHit1 || defaultHitPolygonIndex1 >= 0)
{
// #116 shape-1 fix (Campaign P final physics slice,
// 2026-07-30; docs/research/2026-07-30-ts4-116-oracle-plan.md
// §2.3-§2.4). Retail's airborne (not-yet-Contact)
// find_collisions dispatch, when the FOOT sphere is
// completely clear but the HEAD sphere hits or near-misses,
// records the head polygon's normal directly and hard-stops
// rather than deferring through SetCollide/Adjusted:
// pc:323824-323834 (0x0053a793/0x0053a7a4), cross-checked
// against ACE BSPTree.cs:221-230. See BSPQuery.cs's Path 6
// for the mirrored fix and full citation.
Vector3 worldNormal1 = LocalToWorld(
tree.PolygonTable.Polygons[defaultHitPolygonIndex1].Plane.Normal);
if (worldNormal1.Z < PhysicsGlobals.FloorZ)
{
Vector3 currentWorld =
path.GlobalCurrCenter[0].Origin;
Vector3 endWorld =
path.GlobalSphere[0].Origin;
Vector3 globalDelta = endWorld - currentWorld;
float difference =
Vector3.Dot(worldNormal1, globalDelta);
if (difference < 0f)
path.AddOffsetToCheckPos(-worldNormal1 * difference);
collisions.SetCollisionNormal(worldNormal1);
collisions.SetCollisionNormal(worldNormal1);
collisions.SetSlidingNormal(worldNormal1);
RecordDiagnosticHit(tree, defaultHitPolygonIndex1);
return TransitionState.Slid;
}
path.SetCollide(worldNormal1);
path.WalkableAllowance = PhysicsGlobals.LandingZ;
RecordDiagnosticHit(tree, defaultHitPolygonIndex1);
return TransitionState.Collided;
return TransitionState.Adjusted;
}
}