perf(physics): cut production traversal to flat assets

Make prepared flat BSP data authoritative for gameplay while retaining the parsed graph only as an exact sampled referee. Fail production publication when collision package data is genuinely absent, keep idempotent already-cached publication valid, and move cell membership, floor lookup, camera diagnostics, and live/static shape bounds onto the flat representation.

Validated by 8,402 Release tests, a strict dense-Arwic connected gate with 46,309/46,309 exact referee matches, and graceful shutdown.

Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
Erik 2026-07-25 17:00:04 +02:00
parent d9446030e6
commit 068a06518d
13 changed files with 743 additions and 43 deletions

View file

@ -43,8 +43,15 @@ internal sealed class LiveEntityCollisionBuilder
PhysicsDataCache physicsData,
LiveEntityDefaultPoseResolver defaultPose)
: this(
id => physicsData.GetGfxObj(id)?.BSP?.Root is not null,
id => physicsData.GetGfxObj(id)?.BoundingSphere?.Radius,
id => physicsData.GetGfxObj(id)?.FlatPhysicsBsp?.RootIndex >= 0,
id =>
{
FlatPhysicsBsp? flat =
physicsData.GetGfxObj(id)?.FlatPhysicsBsp;
return flat is { RootIndex: >= 0 }
? flat.Nodes[flat.RootIndex].BoundingSphere.Radius
: null;
},
defaultPose)
{
ArgumentNullException.ThrowIfNull(physicsData);

View file

@ -144,7 +144,8 @@ public sealed class GameWindow :
// Task 4: physics data cache — BSP trees + collision shapes extracted from
// GfxObj/Setup dats during streaming. Populated on the worker thread;
// ConcurrentDictionary inside makes cross-thread access safe.
private readonly AcDream.Core.Physics.PhysicsDataCache _physicsDataCache = new();
private readonly AcDream.Core.Physics.PhysicsDataCache _physicsDataCache =
AcDream.Core.Physics.PhysicsDataCache.CreateProduction();
// #184 Slice 2a: the per-remote dead-reckoning tick, extracted out of the
// >10k-line TickAnimations (Code Structure Rule 1). Reusable setup/motion

View file

@ -77,7 +77,9 @@ public sealed class PhysicsCameraCollisionProbe : ICameraCollisionProbe
if (AcDream.Core.Rendering.RenderingDiagnostics.ProbeFlapEnabled)
{
var cp = _physics.DataCache?.GetCellStruct(startCell);
string bsp = cp?.BSP is null ? "nobsp" : (cp.BSP.Root is null ? "noroot" : "ok");
string bsp = cp?.FlatPhysicsBsp is null
? "noflatbsp"
: (cp.FlatPhysicsBsp.RootIndex < 0 ? "noroot" : "ok");
float desiredBack = Vector3.Distance(pivot, desiredEye);
float eyeBack = Vector3.Distance(pivot, eye);
System.Console.WriteLine(