acdream/tests/AcDream.Core.Tests/Physics/Scratch347DiagTests.cs
Erik 535f41bbdf
Some checks are pending
Headless portability / portable-headless (ubuntu-latest) (push) Waiting to run
Headless portability / portable-headless (windows-latest) (push) Waiting to run
Headless portability / linux-graphical (push) Waiting to run
Headless portability / linux-vulkan (push) Waiting to run
docs(physics): #347 premise revision — retail may alternate too; ftp:edge ratio is the discriminator
The cliff_slide arms are conformant in ACE, our port, and the bytes
(compare constant at 0x794610 verified 0.0), the round-1 slidn:edge
ratio (538:594) refutes a retail retry storm, and the user's
side-by-side speed observation fits alternation. Round-2 cdb script
now counts find_transitional_position; H-A (identical, retire AD-70)
vs H-B (within-tick yield) resolves on one ratio. The temporary
Scratch347 diagnostic test rides along until #347 closes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-07 13:42:14 +02:00

72 lines
2.4 KiB
C#

using System;
using System.IO;
using System.Numerics;
using AcDream.Core.Physics;
using Xunit;
using Xunit.Abstractions;
namespace AcDream.Core.Tests.Physics;
// TEMPORARY #347 diagnostic — deleted before landing.
public sealed class Scratch347DiagTests
{
private readonly ITestOutputHelper _out;
public Scratch347DiagTests(ITestOutputHelper output) => _out = output;
[Fact]
public void DumpFirstArmingTick()
{
var heights = new byte[81];
heights[3 * 9 + 4] = 32;
var heightTable = new float[256];
for (int i = 0; i < 256; i++) heightTable[i] = i;
var engine = new PhysicsEngine();
engine.AddLandblock(0xA9B4FFFFu, new TerrainSurface(heights, heightTable),
Array.Empty<CellSurface>(), Array.Empty<PortalPlane>(), 0f, 0f);
var body = new PhysicsBody
{
State = PhysicsStateFlags.Gravity,
TransientState = TransientStateFlags.Active | TransientStateFlags.Contact | TransientStateFlags.OnWalkable,
};
float dx = 0f, dy = 0.23f;
var position = new Vector3(80.4f, 79.8f, 0f);
uint cell = TerrainSurface.ComputeOutdoorCellId(0xA9B4FFFFu, 80.4f, 79.8f);
PhysicsDiagnostics.DumpTransitFailEnabled = true;
var saved = Console.Out;
var sw = new StringWriter();
Console.SetOut(sw);
try
{
for (int tick = 0; tick < 3; tick++)
{
var result = engine.ResolveWithTransition(
currentPos: position,
targetPos: new Vector3(position.X + dx, position.Y + dy, position.Z),
cellId: cell,
sphereRadius: 0.47f,
sphereHeight: 1.20f,
stepUpHeight: 0.60f,
stepDownHeight: 1.50f,
isOnGround: true,
body: body,
moverFlags: ObjectInfoState.IsPlayer | ObjectInfoState.EdgeSlide,
movingEntityId: 0x5000000Au);
position = result.Position;
cell = result.CellId;
if (tick < 2) sw.GetStringBuilder().Clear(); // keep only the arming tick
}
}
finally
{
Console.SetOut(saved);
PhysicsDiagnostics.DumpTransitFailEnabled = false;
}
foreach (var line in sw.ToString().Split('\n'))
_out.WriteLine(line.TrimEnd());
}
}