perf(streaming): reserve destination reveal capacity

Join destination scheduling to the canonical reveal generation, protect its share across every typed frame-budget dimension, and prevent stale work from clearing a replacement reservation. Remove forced incomplete materialization and project retail's centered portal wait cue while the authored tunnel remains active.

Tests: Release build clean; 91 focused reservation/reveal tests; full solution 8,158 passed, 5 skipped.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Erik 2026-07-24 19:39:23 +02:00
parent 98f1ac8934
commit 2ff8f844b0
33 changed files with 870 additions and 230 deletions

View file

@ -127,8 +127,6 @@ internal interface ILocalPlayerTeleportStreamingOperations
bool BeginRecenter(int x, int y, bool isSealedDungeon);
bool ResetRecenter(bool sessionEnding);
bool IsSealedDungeon(uint cellId);
void SetPriority(uint landblockId, int radius);
void ClearPriority();
}
internal sealed class LocalPlayerTeleportStreamingOperations
@ -165,22 +163,11 @@ internal sealed class LocalPlayerTeleportStreamingOperations
public bool IsSealedDungeon(uint cellId) =>
_sealedDungeonCells.IsSealedDungeon(cellId);
public void SetPriority(uint landblockId, int radius)
{
_streaming.PriorityLandblockId = landblockId;
_streaming.PriorityRadius = radius;
}
public void ClearPriority()
{
_streaming.PriorityLandblockId = 0u;
_streaming.PriorityRadius = 0;
}
}
internal interface ILocalPlayerTeleportPlacement
{
void Place(Vector3 position, uint cellId, Quaternion rotation, bool forced);
void Place(Vector3 position, uint cellId, Quaternion rotation);
}
/// <summary>
@ -218,7 +205,7 @@ internal sealed class LocalPlayerTeleportPlacement : ILocalPlayerTeleportPlaceme
_spatial = spatial ?? throw new ArgumentNullException(nameof(spatial));
}
public void Place(Vector3 position, uint cellId, Quaternion rotation, bool forced)
public void Place(Vector3 position, uint cellId, Quaternion rotation)
{
PlayerMovementController controller = _controller.Controller
?? throw new InvalidOperationException(
@ -233,13 +220,6 @@ internal sealed class LocalPlayerTeleportPlacement : ILocalPlayerTeleportPlaceme
resolved.Position.Y,
resolved.Position.Z);
if (forced)
{
Console.WriteLine(
$"live: teleport HOLD gave up (impossible/timeout) - force-snapping "
+ $"cell=0x{cellId:X8} pos={position} -> 0x{resolved.CellId:X8} {snapped}");
}
uint playerGuid = _identity.ServerGuid;
controller.SetPosition(
snapped,
@ -270,7 +250,7 @@ internal sealed class LocalPlayerTeleportPlacement : ILocalPlayerTeleportPlaceme
PhysicsDiagnostics.LogTeleport(
"PLACED",
controller.CellId,
$"forced={forced}");
"readiness=complete");
Console.WriteLine(
$"live: teleport materialized - snapped to {controller.Position} "
+ $"cell=0x{controller.CellId:X8}");
@ -315,6 +295,7 @@ internal interface ILocalPlayerTeleportPresentation : IDisposable
void TickTunnel(float deltaSeconds);
void EnterTunnel();
void ExitTunnel();
void SetWaitCue(bool visible);
void Reset();
Matrix4x4 ApplyViewPlane(Matrix4x4 projection);
ICamera ApplyViewPlane(ICamera camera);
@ -354,6 +335,7 @@ internal sealed class LocalPlayerTeleportPresentation
public void TickTunnel(float deltaSeconds) => _tunnel.Tick(deltaSeconds);
public void EnterTunnel() => _tunnel.Enter();
public void ExitTunnel() => _tunnel.Exit();
public void SetWaitCue(bool visible) => _tunnel.SetWaitCue(visible);
public void Reset()
{
@ -384,10 +366,6 @@ internal sealed class LocalPlayerTeleportController
AcDream.App.Interaction.ISelectionViewPlaneSource,
IDisposable
{
internal const float MaximumWorldHoldSeconds = 10f;
internal const int NearRingRadius =
WorldRevealReadinessBarrier.OutdoorNeighborhoodRadius;
private readonly TeleportTransitCoordinator<WorldSession.EntityPositionUpdate> _transit = new();
private readonly ILocalPlayerTeleportAuthority _authority;
private readonly ILocalPlayerTeleportInputLifetime _input;
@ -404,7 +382,6 @@ internal sealed class LocalPlayerTeleportController
private bool _hasAcceptedDestination;
private WorldSession.EntityPositionUpdate _acceptedDestination;
private float _holdSeconds;
private bool _forced;
private long _lifetimeGeneration;
private bool _disposed;
@ -496,15 +473,13 @@ internal sealed class LocalPlayerTeleportController
if (!IsCurrentLifetime(generation, sequence))
return;
if (haveDestination && originReady && !ready)
{
if (haveDestination && !ready)
_holdSeconds += deltaSeconds;
if (_holdSeconds >= MaximumWorldHoldSeconds)
{
ready = true;
_forced = true;
}
}
_presentation.SetWaitCue(
haveDestination
&& !ready
&& _worldReveal.ObserveWait(
TimeSpan.FromSeconds(_holdSeconds)));
var (_, events) = _presentation.Tick(deltaSeconds, ready);
if (!IsCurrentLifetime(generation, sequence))
@ -518,14 +493,10 @@ internal sealed class LocalPlayerTeleportController
_placement.Place(
_pendingPosition,
_pendingCell,
_pendingRotation,
_forced);
_pendingRotation);
if (!IsCurrentLifetime(generation, sequence))
return;
_worldReveal.ObserveMaterialized();
if (!IsCurrentLifetime(generation, sequence))
return;
_streaming.ClearPriority();
if (!IsCurrentLifetime(generation, sequence))
return;
break;
@ -590,7 +561,6 @@ internal sealed class LocalPlayerTeleportController
}
_holdSeconds = 0f;
_forced = false;
_presentation.Begin(_mode.Projection);
if (_lifetimeGeneration != generation || !_transit.HasPendingStart)
return;
@ -677,7 +647,7 @@ internal sealed class LocalPlayerTeleportController
// Retail SmartBox enters blocking_for_cells before old-world object,
// physics, landscape, and ambient owners may advance again. Begin the
// reveal generation before a recenter can start detaching that world.
_worldReveal.Begin(WorldRevealKind.Portal);
_worldReveal.Begin(WorldRevealKind.Portal, position.LandblockId);
if (!IsCurrentLifetime(generation, sequence))
return false;
@ -713,13 +683,6 @@ internal sealed class LocalPlayerTeleportController
_pendingPosition = worldPosition;
_pendingCell = position.LandblockId;
_holdSeconds = 0f;
_forced = false;
_streaming.SetPriority(
StreamingRegion.EncodeLandblockId(landblockX, landblockY),
NearRingRadius);
if (!IsCurrentLifetime(generation, sequence))
return false;
PhysicsDiagnostics.LogTeleport(
"AIM",
position.LandblockId,
@ -748,25 +711,19 @@ internal sealed class LocalPlayerTeleportController
_hasAcceptedDestination = false;
_acceptedDestination = default;
_holdSeconds = 0f;
_forced = false;
_streaming.ResetRecenter(clearSession);
if (_lifetimeGeneration != generation)
return generation;
if (clearSession)
{
_worldReveal.Cancel();
if (_lifetimeGeneration != generation)
return generation;
}
_worldReveal.Cancel();
if (_lifetimeGeneration != generation)
return generation;
_presentation.Reset();
if (_lifetimeGeneration != generation)
return generation;
_streaming.ClearPriority();
return generation;
}