fix(render): clip walk content to authored portal views

This commit is contained in:
Erik 2026-08-31 06:15:12 +02:00
parent 90eba0ec3c
commit 11e68aad82
10 changed files with 408 additions and 78 deletions

View file

@ -45,6 +45,22 @@ public sealed class WalkStaticStreamPopulatorTests
Calls.Add((serverGuid, localEntityId, partIndex, gfxObjId, partWorld));
}
private sealed class FixedWalkViews(params uint[] slots) : IWalkLookInViewSource
{
public IReadOnlyList<uint> LookInCellTurns { get; } = [0x8C040112u];
public bool SphereVisibleInLookInTurn(
int routeIndex,
in Vector3 center,
float radius) => slots.Length != 0;
public IReadOnlyList<uint> VisibleClipSlotsInLookInTurn(
int routeIndex,
in Vector3 center,
float radius,
bool testSphere) => slots;
}
// ── Synthetic RenderProjectionRecord construction ──────────────────────
private static RenderProjectionRecord MakeRecord(
@ -212,6 +228,35 @@ public sealed class WalkStaticStreamPopulatorTests
Assert.Equal((uint)leavesGfxObj, selectionParts[1].GfxObjId);
}
[Fact]
public void ClassifyEntityForWalk_EmitsOneGpuClippedInstancePerPortalViewSlice()
{
using var fx = new DispatcherFixture();
const ulong gfxObj = 0x0100_0013UL;
InjectRenderData(fx.Manager, gfxObj, MakeFlatMesh(
MakeBatch(0x08000013u, TranslucencyKind.Opaque, 0, 0, 3, 1)));
RenderProjectionRecord record = MakeRecord(
201, 0, Vector3.Zero,
[new MeshRef((uint)gfxObj, Matrix4x4.Identity)],
parentCellId: 0x8C040112u);
var batches = new List<WbDrawDispatcher.WalkClassifiedBatch>();
var selectionParts = new List<WbDrawDispatcher.WalkClassifiedSelectionPart>();
var views = new FixedWalkViews(7u, 9u);
fx.Dispatcher.ClassifyEntityForWalk(
in record,
0x8C04u,
batches,
selectionParts,
liveDynamic: true,
views,
lookInRouteIndex: 0,
lookInCellId: 0x8C040112u);
Assert.Equal([7u, 9u], batches.Select(static batch => batch.ClipSlot));
Assert.Single(selectionParts);
}
// ── Deliverable 2: WalkStaticStreamPopulator routing ───────────────────
[Fact]