refactor(physics): remove parsed collision graphs

Publish prepared GfxObj, Setup, CellStruct, and EnvCell collision records without retaining their parsed DAT BSP, polygon, vertex, or shape graphs. Strip temporary physics bundles at stable world commit, keep graph traversal only as an explicit test/tooling oracle, and report graph residency from actual retained fields.

Validated by 115 focused collision/streaming tests, a zero-warning Release build, and 8,413 passing Release tests with five pre-existing skips.

Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
Erik 2026-07-25 18:21:19 +02:00
parent feb80a67d9
commit 82f8d4f82e
18 changed files with 923 additions and 104 deletions

View file

@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Numerics;
using AcDream.Core.Physics;
using DatReaderWriter.Enums;
using Xunit;
namespace AcDream.Core.Tests.Physics;
@ -87,4 +89,57 @@ public class CellSurfaceTests
Assert.NotNull(z);
Assert.InRange(z!.Value, 5f, 8f); // approximate
}
[Fact]
public void PreparedPolygonTable_MatchesLegacyWorldSurface()
{
var vertices = new Dictionary<ushort, Vector3>
{
[0] = new(-2f, -2f, 1f),
[1] = new(2f, -2f, 2f),
[2] = new(2f, 2f, 4f),
[3] = new(-2f, 2f, 3f),
};
var table = new FlatPolygonTable(
ImmutableArray.Create(
new FlatCollisionPolygon(
0,
default,
CullMode.None,
4,
new FlatIndexRange(0, 4))),
ImmutableArray.Create(
vertices[0],
vertices[1],
vertices[2],
vertices[3]));
Quaternion rotation = Quaternion.CreateFromAxisAngle(
Vector3.UnitZ,
0.37f);
Vector3 translation = new(17f, -9f, 6f);
var prepared = new CellSurface(
0x0100,
table,
rotation,
translation);
Vector3 localSample = new(0.25f, -0.5f, 0f);
Vector3 worldSample =
Vector3.Transform(localSample, rotation) + translation;
var transformedVertices = vertices.ToDictionary(
static pair => pair.Key,
pair => Vector3.Transform(pair.Value, rotation) + translation);
var legacy = new CellSurface(
0x0100,
transformedVertices,
[new List<short> { 0, 1, 2, 3 }]);
float? expected = legacy.SampleFloorZ(worldSample.X, worldSample.Y);
float? actual = prepared.SampleFloorZ(worldSample.X, worldSample.Y);
Assert.Equal(expected.HasValue, actual.HasValue);
Assert.Equal(
BitConverter.SingleToInt32Bits(expected!.Value),
BitConverter.SingleToInt32Bits(actual!.Value));
}
}