Recover sphere response and correct Jimmy ceiling cancellation

This commit is contained in:
UnixNight committed 2026-10-26 16:09:19 -04:00
1 parent 6a7a53c90d
commit 57dfcc64bb
37 files changed
+1324 -18

No files matched your search

@@ -0,0 +1,55 @@
using System.Numerics;
using GamePort.Game;
var wall = new SupportTriangle(new(-100, -100, 0), new(-100, 100, 0), new(100, 100, 0));
var normal = Vector3.UnitZ;
var initial = SphereResponseState.Begin(10);
SphereResponseResult Wall(Vector3 before, Vector3 after, bool edges = true, bool lower = true) =>
OriginalSphereResponse.Resolve(wall, normal, before, after, 10, initial, edges, lower);
void Near(Vector3 actual, Vector3 expected, string label)
{
if (Vector3.Distance(actual, expected) > .002f) throw new Exception($"{label}: {actual} != {expected}");
}
void Check(bool condition, string label) { if (!condition) throw new Exception(label); }
// Numeric references from the isolated copied original47BD80/OMT component.
var face = Wall(new(0, 20, 20), new(0, 20, 5));
Check(face.Contact == SphereContact.Face, "original face hit");
Near(face.Position, new(0, 20, 10), "original face response");
Check(face.State.FaceDistance == 20 && face.State.EdgeDistance == 10, "separate source nearest slots");
Near(Wall(new(0, 20, 20), new(0, 20, -20)).Position, face.Position, "through-plane response");
Check(Wall(new(0, 20, 5), new(0, 20, 20)).Contact == SphereContact.None, "departing source winding");
Console.WriteLine("PASS original face, crossing and departure references");
var edge = Wall(new(105, 100, 20), new(105, 100, 5));
Check(edge.Contact == SphereContact.Edge, "original edge hit");
Near(edge.Position, new(107.071068f, 100, 7.07106781f), "original edge response");
Near(edge.State.Hit!.Value, new(100, 100, 0), "original nearest vertex");
Check(Wall(new(105, 100, 20), new(105, 100, 5), edges: false).Contact == SphereContact.None,
"edge switch does not run face fallback");
Console.WriteLine("PASS original edge reference and disabled edge gate");
var upper = Wall(new(105, 105, 20), new(105, 105, 5));
Check(upper.Contact == SphereContact.Edge, "lower edge allowed");
Near(upper.Position, new(105.77375f, 105, 5.7737484f), "original lower-edge mode1 reference");
Check(Wall(new(105, 105, 20), new(105, 105, 5), lower: false).Contact == SphereContact.None,
"source lower-edge flag");
var ceiling = new SupportTriangle(new(-100, 100, -100), new(100, 100, 100), new(100, 100, -100));
var under = OriginalSphereResponse.Resolve(ceiling, -Vector3.UnitY, new(0, 80, 0), new(0, 95, 0), 10, initial);
Check(under.Contact == SphereContact.Face, "ceiling face");
Near(under.Position, new(0, 90, 0), "ceiling includes Y response");
Console.WriteLine("PASS lower-edge policy and ceiling face response");
var farther = OriginalSphereResponse.Resolve(wall, normal, new(0, 20, 20), new(0, 20, 5), 10,
initial with { FaceDistance = 19 });
Check(farther.Contact == SphereContact.None, "farther face suppressed without edge fallback");
var tied = OriginalSphereResponse.Resolve(wall, normal, new(0, 20, 20), new(0, 20, 5), 10, face.State);
Check(tied.Contact == SphereContact.None && tied.State == face.State, "equal face retains earlier state");
var edgeSuppressed = OriginalSphereResponse.Resolve(wall, normal, new(105, 100, 20), new(105, 100, 5),
10, initial with { EdgeDistance = 1 });
Check(edgeSuppressed.Contact == SphereContact.None, "edge nearest state persists across candidates");
Console.WriteLine("PASS shared nearest-hit and equal-distance boundaries");
try { Wall(new(float.NaN, 0, 0), Vector3.Zero); throw new Exception("NaN accepted"); }
catch (ArgumentOutOfRangeException) { }
Console.WriteLine("PASS bounded finite inputs; complete body solver and x87 boundary parity remain open");