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
Both static sites (LandblockPhysicsPublisher, the headless-only LandblockPhysicsContentBuilder) emitted an authored Setup Sphere as a base-anchored Cylinder of radius r and height 2r. The live path emits a Sphere for the same data, so the same object collided differently by arrival route, and the narrow phase met a flat cap where retail meets a curved surface. Both sites now mirror ShadowShapeBuilder.FromSetup's Sphere block exactly. Combined Opus review: PASS. Its numeric verification of the dispatch test's geometry (head-sphere clearance 0.201 m for the true sphere; the cylinder counterfactual inside by 0.10 m XY with the Z band overlapping) is what makes the discrimination claim more than a sabotage anecdote, and its F8 finding is applied: the test now carries a POSITIVE control — aiming straight through the boulder's centre must block — so a membership/seed regression can no longer masquerade as a curve-hit pass. F4 applied: CylHeight is asserted, not inferred (the C4 lesson). F3 applied: the deleted Quaternion.Inverse base composition is recorded as internally coherent for the old cylinder's world-Z axis — the defect was the shape TYPE, not that rotation math. The review also verified the deleted-cylinder blast radius: the F2 overlay's drawn span is IDENTICAL for both shapes (old [c-r, c+r], new [c-r, c+r]); the flood sphere's centre rises by exactly r, which cannot change outdoor membership (XY rectangle) and lands the indoor half on Session B's dungeon gate alongside S1B; and the sphere-branch flood is now pinned uncapped by a genuine eleventh-shape A/B test. PublishStaticCollision — the headless static path — gains its first test ever. AP-155 is NARROWED, not deleted (review F13): the has-BSP source split (entity.MeshRefs vs setup.Parts + AnimPartChanged) survives and keeps the row active. The shared-primitive-emitter refactor that would make route independence a compile-time property is the filed follow-up (review F20). Population: 3,506 of 5,935 installed Setups, structurally equal to AP-157's third-branch count (byte-identical classifier — three independent routes agree: 3,605 - 99 = 3,506). Clean-room suite at implementation: 11,253 passed / 6 skipped / 0 failed on landed S1B. Post-review-hardening: Publisher tests 25/25, Content tests 2/2, both green. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
111 lines
4.8 KiB
C#
111 lines
4.8 KiB
C#
using System.Collections.Immutable;
|
|
using System.Linq;
|
|
using System.Numerics;
|
|
using AcDream.Content;
|
|
using AcDream.Core.Physics;
|
|
using AcDream.Core.World;
|
|
using DatReaderWriter.DBObjs;
|
|
using DatReaderWriter.Types;
|
|
|
|
namespace AcDream.Content.Tests;
|
|
|
|
/// <summary>
|
|
/// AP-155 parity (route independence) for the second static publication site,
|
|
/// <see cref="LandblockPhysicsContentBuilder.PublishStaticCollision"/>. A
|
|
/// Setup carrying only authored Spheres (no CylSpheres) must register the
|
|
/// SAME shapes — type, local position, radius, scale — as
|
|
/// <see cref="ShadowShapeBuilder.FromSetup"/>, the LIVE path. Before the fix
|
|
/// this site emitted a height-capped Cylinder instead (base = origin - r*ẑ,
|
|
/// height = 2r), identically to <c>LandblockPhysicsPublisher</c>'s copy of
|
|
/// the same bug — see that class's tests
|
|
/// (<c>LandblockPhysicsPublisherTests.CompletePublication_SphereOnlySetup_*</c>)
|
|
/// for the dispatch-level (Cylinder-vs-Sphere narrow phase) proof; the two
|
|
/// sites share the SAME <c>ShadowObjectRegistry</c>/<c>TransitionTypes</c>
|
|
/// query code; this class only needs to prove ITS emission is correct.
|
|
/// </summary>
|
|
public sealed class LandblockPhysicsContentBuilderStaticSphereTests
|
|
{
|
|
private const uint LandblockId = 0xA9B40000u;
|
|
private const uint SetupId = 0x02000042u;
|
|
|
|
[Fact]
|
|
public void PublishStaticCollision_SphereOnlySetup_MatchesFromSetupShapeForShape()
|
|
{
|
|
var setup = new Setup();
|
|
setup.Spheres.Add(new Sphere
|
|
{
|
|
Origin = new Vector3(0.3f, -0.2f, 0.9f),
|
|
Radius = 0.55f,
|
|
});
|
|
setup.Spheres.Add(new Sphere
|
|
{
|
|
Origin = new Vector3(-0.1f, 0.4f, 1.4f),
|
|
Radius = 0.25f,
|
|
});
|
|
FlatSetupCollision flatSetup = FlatCollisionAssetBuilder.FlattenSetup(setup);
|
|
|
|
const float entScale = 1.3f;
|
|
var entity = new WorldEntity
|
|
{
|
|
Id = 0x80A9B401u,
|
|
SourceGfxObjOrSetupId = SetupId,
|
|
Position = Vector3.Zero,
|
|
Rotation = Quaternion.Identity,
|
|
Scale = entScale,
|
|
MeshRefs = Array.Empty<MeshRef>(),
|
|
};
|
|
var landblock = new LoadedLandblock(
|
|
LandblockId,
|
|
new LandBlock { Terrain = new TerrainInfo[81], Height = new byte[81] },
|
|
new[] { entity });
|
|
var collisions = new LandblockCollisionBuild(
|
|
ImmutableDictionary<uint, FlatGfxObjCollisionAsset>.Empty,
|
|
ImmutableDictionary<uint, FlatSetupCollision>.Empty.Add(SetupId, flatSetup),
|
|
ImmutableDictionary<uint, FlatCellStructureCollisionAsset>.Empty,
|
|
ImmutableDictionary<uint, FlatEnvCellTopology>.Empty,
|
|
ImmutableArray<uint>.Empty,
|
|
ImmutableArray.Create(SetupId),
|
|
ImmutableArray<uint>.Empty);
|
|
|
|
var engine = new PhysicsEngine();
|
|
var cache = new PhysicsDataCache();
|
|
LandblockPhysicsContentBuilder.CachePreparedObjects(cache, collisions);
|
|
|
|
LandblockPhysicsContentBuilder.StaticCollisionPublication publication =
|
|
LandblockPhysicsContentBuilder.PublishStaticCollision(
|
|
engine, cache, landblock, collisions, origin: Vector3.Zero);
|
|
|
|
Assert.Equal(1, publication.SetupOwnerCount);
|
|
Assert.Equal(0, publication.BspOwnerCount);
|
|
Assert.Equal(0, publication.NoCollisionCount);
|
|
|
|
// The LIVE-path oracle for the SAME Setup/scale.
|
|
var expected = ShadowShapeBuilder.FromSetup(setup, entScale, _ => false);
|
|
Assert.Equal(2, expected.Count);
|
|
Assert.All(
|
|
expected,
|
|
shape => Assert.Equal(ShadowCollisionType.Sphere, shape.CollisionType));
|
|
|
|
ShadowShape[] expectedOrdered = expected.OrderBy(shape => shape.Radius).ToArray();
|
|
// Entity registered at world origin with identity rotation, so
|
|
// RegisterMultiPart's world composition (entityWorldPos +
|
|
// Transform(shape.LocalPosition, entityWorldRot)) reduces to exactly
|
|
// shape.LocalPosition — the static entry's world Position is directly
|
|
// comparable to FromSetup's LocalPosition.
|
|
ShadowEntry[] entries = engine.ShadowObjects.AllEntriesForDebug()
|
|
.Where(entry => entry.EntityId == entity.Id)
|
|
.OrderBy(entry => entry.Radius)
|
|
.ToArray();
|
|
|
|
Assert.Equal(expectedOrdered.Length, entries.Length);
|
|
for (int i = 0; i < entries.Length; i++)
|
|
{
|
|
Assert.Equal(ShadowCollisionType.Sphere, entries[i].CollisionType);
|
|
Assert.Equal(expectedOrdered[i].LocalPosition, entries[i].Position);
|
|
Assert.Equal(expectedOrdered[i].Radius, entries[i].Radius);
|
|
Assert.Equal(expectedOrdered[i].Scale, entries[i].Scale);
|
|
// Review F4 (2026-08-07): assert, don't infer — the C4 lesson.
|
|
Assert.Equal(expectedOrdered[i].CylHeight, entries[i].CylHeight);
|
|
}
|
|
}
|
|
}
|