using System.Numerics; using AcDream.Core.Physics; using Xunit; namespace AcDream.Core.Tests.Physics; /// /// #337 (2026-08-06 — TEMPORARY, delete with the [support] probe). /// /// /// The [support] line's whole value is its support= verdict: /// terrain, an object surface, or nothing. If that classifier is wrong, a /// capture does not merely fail to answer — it answers CONFIDENTLY WRONG, and /// this campaign has already spent two diagnoses on confident wrong answers. /// These cover the decision boundaries directly, so the live capture can be /// read at face value. /// /// public sealed class SupportProbeClassifierTests { private const float FlatNormalZ = 1f; [Fact] public void NoContactPlane_IsUnsupported() { Assert.Equal( "none", PhysicsDiagnostics.ClassifySupport( contactPlaneValid: false, terrainSampled: true, contactPlaneZAtXY: 100f, contactPlaneNormalZ: FlatNormalZ, terrainZ: 100f, terrainNormalZ: FlatNormalZ)); } [Fact] public void PlaneAtTerrainHeightAndTilt_IsTerrain() { Assert.Equal( "terrain", PhysicsDiagnostics.ClassifySupport( contactPlaneValid: true, terrainSampled: true, contactPlaneZAtXY: 41.25f, contactPlaneNormalZ: 0.94f, terrainZ: 41.26f, terrainNormalZ: 0.94f)); } [Fact] public void PlaneWellAboveTerrain_IsObject() { // The rock-plateau shape: the body rests six metres above the ground. Assert.Equal( "object", PhysicsDiagnostics.ClassifySupport( contactPlaneValid: true, terrainSampled: true, contactPlaneZAtXY: 47.5f, contactPlaneNormalZ: FlatNormalZ, terrainZ: 41.5f, terrainNormalZ: 0.9f)); } [Fact] public void SameHeightDifferentTilt_IsReportedSeparately() { // A collision surface lying flat against sloped ground. This must NOT // collapse into either answer: it is precisely the ambiguous case, and // guessing between them is what the probe exists to avoid. Assert.Equal( "coplanar-tilt-mismatch", PhysicsDiagnostics.ClassifySupport( contactPlaneValid: true, terrainSampled: true, contactPlaneZAtXY: 41.5f, contactPlaneNormalZ: 1.0f, terrainZ: 41.5f, terrainNormalZ: 0.72f)); } [Fact] public void NoTerrainUnderTheBody_SaysSoRatherThanGuessing() { Assert.Equal( "no-terrain", PhysicsDiagnostics.ClassifySupport( contactPlaneValid: true, terrainSampled: false, contactPlaneZAtXY: 12f, contactPlaneNormalZ: FlatNormalZ, terrainZ: float.NaN, terrainNormalZ: float.NaN)); } [Fact] public void PlaneHeightIsEvaluatedAtTheBodysOwnXy() { // A 45-degree ramp through the origin: height must track X, or a body // standing on a slope would read as displaced from its own support. var slope = new Plane(Vector3.Normalize(new Vector3(-1f, 0f, 1f)), 0f); Assert.True(PhysicsDiagnostics.TryPlaneZAt(slope, 0f, 0f, out float atOrigin)); Assert.Equal(0f, atOrigin, 3); Assert.True(PhysicsDiagnostics.TryPlaneZAt(slope, 10f, 0f, out float atTen)); Assert.Equal(10f, atTen, 3); } [Fact] public void VerticalPlaneHasNoHeight() { // A wall is never a floor. Reporting a height for one would read as a // wildly displaced surface and manufacture a false positive. var wall = new Plane(new Vector3(1f, 0f, 0f), -5f); Assert.False(PhysicsDiagnostics.TryPlaneZAt(wall, 0f, 0f, out _)); } }