Adds ACDREAM_PROBE_BUILDING — a read-only per-shadow-entry probe that
captures full BSP collision evidence whenever TransitionTypes.FindObjCollisions
attributes a hit (via the existing L.2a slice 3 chain). One multi-line
[resolve-bldg] entry per attributed hit: partIdx, hasPhys, bspR vs
vAabbR, world-space entOrigin_lb, and the actual hit polygon's vertices
in both object-local and world space.
Paired with a one-time [entity-source] line at every ShadowObjects.Register
call site in GameWindow so entityId from a probe line is greppable to its
WorldEntity source within a single log file.
Plumbing: BSPQuery writes the resolved hit polygon to a new
PhysicsDiagnostics.LastBspHitPoly side-channel at the 5 SetCollisionNormal
sites in Paths 5/6 + CollideWithPt. TransitionTypes clears that field
before each shadow-entry dispatch and reads it back at the L.2a slice 3
attribution site to emit the probe line.
Spec component 4 originally described an out ResolvedPolygon? parameter
on BSPQuery.FindCollisions; the static side-channel achieves the same
observable behavior without plumbing through BSPQuery's recursive private
methods. Deviation noted in PhysicsDiagnostics.LastBspHitPoly's XML doc.
Reframes the plan-of-record's L.2d sub-direction paragraph: the 2026-05-12
handoff proposed porting CBuildingObj + per-cell walkability, but ACE
BuildingObj.cs:39-52 + named-retail acclient_2013_pseudo_c.txt:701260
show find_building_collisions is one BSP test on Parts[0]. Per-cell
walkability belongs to L.2e, not L.2d. L.2d slice 1 is the diagnostic;
slice 2 is the actual fix scoped from slice 1's evidence (one of three
hypotheses: wrong BSP loaded / over-registered parts / BSPQuery flaw).
Tests: 2 synthetic unit tests in PhysicsDiagnosticsTests.cs pin the
static API contract that the BSPQuery → side-channel → TransitionTypes
emission chain depends on. The multi-line line format itself is verified
by acceptance criterion 2 (live Holtburg-doorway capture) — covering it
here would require a heavy PhysicsEngine + Transition fixture for a
diagnostic-only emission.
Verified: dotnet build green; the 2 new tests pass; the 8 pre-existing
test failures listed in the L.2a handoff (MotionInterpreter GetMaxSpeed_*,
PositionManager.ComputeOffset_BothActive_Combined,
PlayerMovementController.Update_ForwardInput_*, Dispatcher.W_held_*,
BSPStepUpTests.{D4,C3}) remain failing — none introduced by this slice.
Spec: docs/superpowers/specs/2026-05-13-l2d-cbuildingobj-collision-design.md
Conformance anchors:
- acclient_2013_pseudo_c.txt:701260 (CBuildingObj::find_building_collisions)
- acclient_2013_pseudo_c.txt:323725 (BSPTREE::find_collisions)
- ACE references/ACE/Source/ACE.Server/Physics/Common/BuildingObj.cs:39-52
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
97 lines
4.4 KiB
C#
97 lines
4.4 KiB
C#
using System;
|
|
|
|
namespace AcDream.Core.Physics;
|
|
|
|
/// <summary>
|
|
/// L.2a slice 1 (2026-05-12) — runtime-toggleable physics probe flags.
|
|
/// Initialized from env vars at process start; flippable at runtime via
|
|
/// the DebugPanel mirror (or by direct assignment). Log call sites read
|
|
/// these statics so a checkbox toggle takes effect on the next resolve
|
|
/// without relaunching.
|
|
///
|
|
/// <para>
|
|
/// L.2d slice 1 (2026-05-13) adds <see cref="ProbeBuildingEnabled"/> +
|
|
/// the <see cref="LastBspHitPoly"/> diagnostic side-channel. Future
|
|
/// slices may fold the older <c>ACDREAM_DUMP_*</c> env vars into this
|
|
/// class for unified runtime toggling. Until then, those older flags
|
|
/// remain sticky-at-startup per their original implementation.
|
|
/// </para>
|
|
/// </summary>
|
|
public static class PhysicsDiagnostics
|
|
{
|
|
/// <summary>
|
|
/// When true, <see cref="PhysicsEngine.ResolveWithTransition"/> emits
|
|
/// one structured <c>[resolve]</c> line per call: input + target +
|
|
/// output position/cell, grounded state, contact-plane status,
|
|
/// collision-normal validity, walkable polygon status, moving entity
|
|
/// id. Initial state from <c>ACDREAM_PROBE_RESOLVE=1</c>.
|
|
/// </summary>
|
|
public static bool ProbeResolveEnabled { get; set; } =
|
|
Environment.GetEnvironmentVariable("ACDREAM_PROBE_RESOLVE") == "1";
|
|
|
|
/// <summary>
|
|
/// When true, every change to <c>PlayerMovementController.CellId</c>
|
|
/// emits one <c>[cell-transit]</c> line: old → new cell, current
|
|
/// world position, reason tag (<c>resolver</c> / <c>teleport</c>).
|
|
/// Initial state from <c>ACDREAM_PROBE_CELL=1</c>.
|
|
/// </summary>
|
|
public static bool ProbeCellEnabled { get; set; } =
|
|
Environment.GetEnvironmentVariable("ACDREAM_PROBE_CELL") == "1";
|
|
|
|
/// <summary>
|
|
/// L.2d slice 1 (2026-05-13). When true, every BSP-shadow-entry hit
|
|
/// attributed by <c>TransitionTypes.FindObjCollisions</c> emits a
|
|
/// multi-line <c>[resolve-bldg]</c> entry: which part (partIdx vs 0),
|
|
/// physics-BSP root radius vs visual AABB radius, world-space entity
|
|
/// origin, and the specific hit polygon's vertices in both
|
|
/// object-local and world space. Designed to distinguish the three
|
|
/// L.2d hypotheses (wrong BSP loaded / over-registered parts /
|
|
/// BSPQuery flaw) from a single Holtburg-doorway capture.
|
|
///
|
|
/// <para>
|
|
/// Also gates a one-time <c>[entity-source]</c> log line at every
|
|
/// <c>ShadowObjects.Register(...)</c> call site in <c>GameWindow</c>
|
|
/// — makes <c>entityId=0xA9B479</c> in a probe line greppable to its
|
|
/// source registration within the same log file.
|
|
/// </para>
|
|
///
|
|
/// <para>
|
|
/// Initial state from <c>ACDREAM_PROBE_BUILDING=1</c>. Mirrorable
|
|
/// via <c>DebugVM.ProbeBuilding</c> when <c>ACDREAM_DEVTOOLS=1</c>.
|
|
/// </para>
|
|
///
|
|
/// <para>
|
|
/// Spec: <c>docs/superpowers/specs/2026-05-13-l2d-cbuildingobj-collision-design.md</c>.
|
|
/// </para>
|
|
/// </summary>
|
|
public static bool ProbeBuildingEnabled { get; set; } =
|
|
Environment.GetEnvironmentVariable("ACDREAM_PROBE_BUILDING") == "1";
|
|
|
|
/// <summary>
|
|
/// L.2d slice 1 (2026-05-13). Diagnostic side-channel: the
|
|
/// <see cref="ResolvedPolygon"/> that <see cref="BSPQuery"/>
|
|
/// recorded for the most recent collision-normal write.
|
|
/// <see cref="TransitionTypes.FindObjCollisions"/> clears this to
|
|
/// <see langword="null"/> before each shadow-entry test and reads it
|
|
/// back after, so emitting the <c>[resolve-bldg]</c> probe line can
|
|
/// reference the actual hit poly without plumbing an out-param
|
|
/// through BSPQuery's recursive private methods.
|
|
///
|
|
/// <para>
|
|
/// Written by <see cref="BSPQuery"/> only when
|
|
/// <see cref="ProbeBuildingEnabled"/> is true, so this stays
|
|
/// zero-cost in normal play. Cylinder collisions leave this
|
|
/// <see langword="null"/> — the probe line emits
|
|
/// <c>hitPoly: n/a (cylinder)</c> in that case.
|
|
/// </para>
|
|
///
|
|
/// <para>
|
|
/// Not threadsafe — physics runs on a single thread. If that
|
|
/// changes, this needs <c>[ThreadStatic]</c> or rethink. Deviation
|
|
/// from spec component 4 (which described an out-param); the
|
|
/// side-channel keeps BSPQuery's signature stable and the diagnostic
|
|
/// path off the production code surface.
|
|
/// </para>
|
|
/// </summary>
|
|
public static ResolvedPolygon? LastBspHitPoly { get; set; }
|
|
}
|