fix(physics): keep remote placement and targeting in one world frame
CreateObject positions are landblock-local, but Runtime first-entry previously submitted remotes with a zero world offset. Runtime now owns the accepted local-player world-frame center and converts remote placements before SetPosition. The local physics host also publishes body.Position rather than CellPosition's landblock-local origin, so TargetManager no longer directs monsters toward a phantom player position. User gate: monster/static placement, chase, and attacks accepted outside Tusker Barracks.
This commit is contained in:
parent
01f4791e95
commit
670f307c84
7 changed files with 140 additions and 12 deletions
|
|
@ -448,6 +448,7 @@ public sealed class RuntimePhysicsState : IDisposable
|
|||
private int _collisionMutationThreadId;
|
||||
private long _nextCollisionPreparationSequence;
|
||||
private ulong _collisionWorldAuthority = 1UL;
|
||||
private uint _worldFrameCenterLandblockId;
|
||||
private readonly List<Action<RuntimeCollisionGenerationCommitted>>
|
||||
_collisionGenerationCommittedObservers = new();
|
||||
private bool _disposed;
|
||||
|
|
@ -524,6 +525,52 @@ public sealed class RuntimePhysicsState : IDisposable
|
|||
internal double PlacementSimulationTime(double fallback) =>
|
||||
_gameClock?.SimulationTimeSeconds ?? fallback;
|
||||
|
||||
/// <summary>
|
||||
/// Establishes the landblock that maps to world-frame XY (0,0). The
|
||||
/// local-player Create initializes it before remote first-entry work;
|
||||
/// only an accepted teleport moves it afterward. Ordinary walking across
|
||||
/// a landblock boundary does not rebase the streamed world.
|
||||
/// </summary>
|
||||
internal void ObserveLocalWorldFrame(
|
||||
uint fullCellId,
|
||||
bool teleportAdvanced)
|
||||
{
|
||||
EnsureNotDisposed();
|
||||
if (fullCellId == 0u)
|
||||
return;
|
||||
if (_worldFrameCenterLandblockId == 0u || teleportAdvanced)
|
||||
{
|
||||
_worldFrameCenterLandblockId =
|
||||
(fullCellId & 0xFFFF0000u) | 0xFFFFu;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a retail landblock-local network frame into the Runtime's
|
||||
/// current world frame without consulting presentation or waiting for
|
||||
/// the destination collision package.
|
||||
/// </summary>
|
||||
internal bool TryGetWorldFrameOffset(
|
||||
uint fullCellId,
|
||||
out float worldOffsetX,
|
||||
out float worldOffsetY)
|
||||
{
|
||||
if (_worldFrameCenterLandblockId == 0u || fullCellId == 0u)
|
||||
{
|
||||
worldOffsetX = 0f;
|
||||
worldOffsetY = 0f;
|
||||
return false;
|
||||
}
|
||||
|
||||
int centerX = (int)((_worldFrameCenterLandblockId >> 24) & 0xFFu);
|
||||
int centerY = (int)((_worldFrameCenterLandblockId >> 16) & 0xFFu);
|
||||
int landblockX = (int)((fullCellId >> 24) & 0xFFu);
|
||||
int landblockY = (int)((fullCellId >> 16) & 0xFFu);
|
||||
worldOffsetX = (landblockX - centerX) * 192f;
|
||||
worldOffsetY = (landblockY - centerY) * 192f;
|
||||
return true;
|
||||
}
|
||||
|
||||
public RuntimePhysicsOwnershipSnapshot CaptureOwnership()
|
||||
{
|
||||
RuntimeSetPositionOwnershipSnapshot setPosition =
|
||||
|
|
@ -1315,6 +1362,7 @@ public sealed class RuntimePhysicsState : IDisposable
|
|||
_collisionAdmissions.Clear();
|
||||
SetPosition.ResetSession();
|
||||
CollisionReports.ResetSession();
|
||||
_worldFrameCenterLandblockId = 0u;
|
||||
AdvanceCollisionWorldAuthority();
|
||||
Volatile.Write(ref _collisionMutationThreadId, 0);
|
||||
}
|
||||
|
|
@ -2007,6 +2055,7 @@ public sealed class RuntimePhysicsState : IDisposable
|
|||
_collisionPrefixMutations.Clear();
|
||||
_collisionAdmissions.Clear();
|
||||
_collisionGenerations.Clear();
|
||||
_worldFrameCenterLandblockId = 0u;
|
||||
CellCommitted = null;
|
||||
_collisionGenerationCommittedObservers.Clear();
|
||||
_disposed = true;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,8 @@ internal readonly record struct RuntimeSetPositionMoverPreparation(
|
|||
uint ScatterAttempts = 0u,
|
||||
float ShadowWorldOffsetX = 0f,
|
||||
float ShadowWorldOffsetY = 0f,
|
||||
RuntimePortalPlacementAuthority Portal = default);
|
||||
RuntimePortalPlacementAuthority Portal = default,
|
||||
bool ResolveWorldOffsetFromRuntimeFrame = false);
|
||||
|
||||
/// <summary>
|
||||
/// Pure preparation port of the mover inputs consumed by retail
|
||||
|
|
|
|||
|
|
@ -1522,6 +1522,32 @@ internal sealed class RuntimeSetPositionState : IDisposable
|
|||
.RetrySetupUnavailable;
|
||||
}
|
||||
|
||||
RuntimeSetPositionMoverPreparation effectivePreparation = preparation;
|
||||
if (preparation.ResolveWorldOffsetFromRuntimeFrame)
|
||||
{
|
||||
// CreateObject/Position origins are local to their authored
|
||||
// landblock. Resolve them through Runtime's accepted world frame,
|
||||
// which is initialized by the local-player Create and advanced
|
||||
// only by authoritative teleport transitions. This is available
|
||||
// before streaming publishes the target collision generation, so
|
||||
// remote admission cannot starve world loading while still using
|
||||
// the exact same coordinate frame that generation will publish.
|
||||
if (!_physics.TryGetWorldFrameOffset(
|
||||
authority.AcceptedPosition.LandblockId,
|
||||
out float worldOffsetX,
|
||||
out float worldOffsetY))
|
||||
{
|
||||
return RuntimeSetPositionMoverPreparationStatus
|
||||
.RetrySetupUnavailable;
|
||||
}
|
||||
|
||||
effectivePreparation = preparation with
|
||||
{
|
||||
ShadowWorldOffsetX = worldOffsetX,
|
||||
ShadowWorldOffsetY = worldOffsetY,
|
||||
};
|
||||
}
|
||||
|
||||
if (!RuntimeSetPositionMoverPreparer.TryBuild(
|
||||
operation.Record,
|
||||
authority.AcceptedPosition,
|
||||
|
|
@ -1529,7 +1555,7 @@ internal sealed class RuntimeSetPositionState : IDisposable
|
|||
operation.Kind,
|
||||
operation.Portal,
|
||||
authority.VelocityAuthorityVersion,
|
||||
preparation,
|
||||
effectivePreparation,
|
||||
out command)
|
||||
|| !IsStructurallyValid(command.Physics))
|
||||
{
|
||||
|
|
@ -1586,7 +1612,8 @@ internal sealed class RuntimeSetPositionState : IDisposable
|
|||
float scatterRadiusY = 0f,
|
||||
uint scatterAttempts = 0u,
|
||||
float shadowWorldOffsetX = 0f,
|
||||
float shadowWorldOffsetY = 0f)
|
||||
float shadowWorldOffsetY = 0f,
|
||||
bool resolveWorldOffsetFromRuntimeFrame = false)
|
||||
{
|
||||
outcome = default;
|
||||
|
||||
|
|
@ -1606,7 +1633,8 @@ internal sealed class RuntimeSetPositionState : IDisposable
|
|||
scatterRadiusY,
|
||||
scatterAttempts,
|
||||
shadowWorldOffsetX,
|
||||
shadowWorldOffsetY);
|
||||
shadowWorldOffsetY,
|
||||
resolveWorldOffsetFromRuntimeFrame);
|
||||
if (status != RuntimeSetPositionMoverPreparationStatus.Prepared)
|
||||
return status;
|
||||
|
||||
|
|
@ -1644,7 +1672,8 @@ internal sealed class RuntimeSetPositionState : IDisposable
|
|||
float scatterRadiusY = 0f,
|
||||
uint scatterAttempts = 0u,
|
||||
float shadowWorldOffsetX = 0f,
|
||||
float shadowWorldOffsetY = 0f)
|
||||
float shadowWorldOffsetY = 0f,
|
||||
bool resolveWorldOffsetFromRuntimeFrame = false)
|
||||
{
|
||||
EnsureNotDisposed();
|
||||
ArgumentNullException.ThrowIfNull(record);
|
||||
|
|
@ -1683,7 +1712,8 @@ internal sealed class RuntimeSetPositionState : IDisposable
|
|||
scatterAttempts,
|
||||
shadowWorldOffsetX,
|
||||
shadowWorldOffsetY,
|
||||
portal);
|
||||
portal,
|
||||
resolveWorldOffsetFromRuntimeFrame);
|
||||
return PrepareMover(token, preparation, out command);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue