fix(portal): synchronize destination presentation state
This commit is contained in:
parent
4b1bceefbb
commit
e95f55f25b
42 changed files with 2815 additions and 288 deletions
|
|
@ -63,6 +63,17 @@ public sealed class CellGraph
|
|||
if ((id & 0xFFFF0000u) == lb) _envCells.TryRemove(id, out _);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove only a landblock's indoor environment cells while preserving its
|
||||
/// outdoor terrain registration. Used by Near-to-Far streaming demotion.
|
||||
/// </summary>
|
||||
public void RemoveEnvCellsForLandblock(uint landblockPrefix)
|
||||
{
|
||||
uint lb = landblockPrefix & 0xFFFF0000u;
|
||||
foreach (var id in new List<uint>(_envCells.Keys))
|
||||
if ((id & 0xFFFF0000u) == lb) _envCells.TryRemove(id, out _);
|
||||
}
|
||||
|
||||
/// <summary>The universal id->cell resolver (retail CObjCell::GetVisible).</summary>
|
||||
public ObjCell? GetVisible(uint id)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ public static class LandblockLoader
|
|||
|
||||
// When landblockId is non-zero, namespace stab Ids globally:
|
||||
// 0xC0XXYY00 + n, where XX = lbX byte, YY = lbY byte
|
||||
// matching the scenery (0x80XXYY00) and interior (0x40XXYY00) patterns
|
||||
// in GameWindow.cs. The 0xC0 top byte distinguishes stabs from those.
|
||||
// distinct from the 0x8XXYYIII scenery and 0x4XXYYIII interior
|
||||
// namespaces in GameWindow.cs. The 0xC0 top byte distinguishes stabs.
|
||||
//
|
||||
// Pre-Tier-1 callers (existing tests) pass landblockId=0 and get the
|
||||
// legacy starting-from-1 monotonic Ids — compatible with their assertions
|
||||
|
|
|
|||
39
src/AcDream.Core/World/ProceduralSceneryIdAllocator.cs
Normal file
39
src/AcDream.Core/World/ProceduralSceneryIdAllocator.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
namespace AcDream.Core.World;
|
||||
|
||||
/// <summary>
|
||||
/// Allocates stable, collision-free ids for procedurally generated scenery.
|
||||
///
|
||||
/// <para>
|
||||
/// The top nibble is fixed at <c>0x8</c>, so bit 31 continues to identify
|
||||
/// procedural scenery to every renderer and physics consumer. The remaining
|
||||
/// 28 bits are X(8), Y(8), and a 12-bit per-landblock counter:
|
||||
/// <c>0x8XXYYIII</c>. No consumer decodes the former byte-aligned
|
||||
/// <c>0x80XXYYII</c> layout; they classify only on bit 31.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// The old 8-bit counter aborted generation after 256 drawable spawns. That
|
||||
/// exception rejected the entire streamed landblock before render publication,
|
||||
/// exposing the grey clear color as portal space ended. A 12-bit counter gives
|
||||
/// 4096 entries while retaining full landblock coordinates. Overflow fails
|
||||
/// before it can alias the next landblock.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static class ProceduralSceneryIdAllocator
|
||||
{
|
||||
public const uint MaxCounter = 0xFFFu;
|
||||
|
||||
public static uint Base(uint landblockX, uint landblockY)
|
||||
=> 0x80000000u
|
||||
| ((landblockX & 0xFFu) << 20)
|
||||
| ((landblockY & 0xFFu) << 12);
|
||||
|
||||
public static uint Allocate(uint landblockX, uint landblockY, ref uint counter)
|
||||
{
|
||||
if (counter > MaxCounter)
|
||||
throw new InvalidDataException(
|
||||
$"Landblock ({landblockX & 0xFFu:X2},{landblockY & 0xFFu:X2}) exceeds the 4096-entry procedural scenery id namespace.");
|
||||
|
||||
return Base(landblockX, landblockY) + counter++;
|
||||
}
|
||||
}
|
||||
|
|
@ -99,7 +99,8 @@ public sealed class TeleportAnimSequencer
|
|||
|
||||
/// <summary>
|
||||
/// Advance the machine by <paramref name="dt"/> seconds.
|
||||
/// <paramref name="worldReady"/> = destination collision landblock is resident.
|
||||
/// <paramref name="worldReady"/> = the complete destination-load barrier is
|
||||
/// satisfied (Near-tier render meshes/textures plus collision residency).
|
||||
/// Returns the current snapshot + edge-triggered events fired THIS tick.
|
||||
/// </summary>
|
||||
public (TeleportAnimSnapshot snapshot, IReadOnlyList<TeleportAnimEvent> events)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue