feat(interaction): Slice 4 - equipped-child world picking
A click on a remote character's wielded weapon reported nothing. The picker was already correct: RetailSelectionScene publishes every drawn part under its own live-entity server GUID and RetailWorldPicker returns the weapon as the polygon winner. The failure was downstream eligibility - WorldSelectionQuery required TryGetInteractionEligibleRecord, whose _visible set admits LiveEntityProjectionKind.World only, so the winning hit was discarded. Retail has no such gate. Render::GfxObjUnderSelectionRay @ 0x0054C740 accumulates each hit under the drawn part's own physics-object id (CPhysicsPart::get_physobj_id @ 0x0050D490), and CPhysicsPart::Draw @ 0x0050D7A0 admits any drawn part whose physobj id is nonzero. An equipped item is a first-class CPhysicsObj with its own id and part array (CPhysicsObj::add_child @ 0x0050F870 via CSetup::GetHoldingLocation @ 0x005213F0). There is no parent redirection and no wielded-specific rule, so a click on a wielded weapon returns THE WEAPON'S GUID. PositionState.WIELDED is distinct from IN_CONTAINER (acclient.h:6802), so container suppression never hid a wielded selection either. LiveEntityRuntime gains two scoped predicates: TryGetAttachedProjectedRecord (a current Attached projection that is spatially projected) and TryGetPickEligibleRecord (that arm plus today's World visible-set arm, with the same WorldEntity.Id staleness recheck). TryGetInteractionEligibleRecord and the _visible set are deliberately NOT widened - they feed radar, auto-target, sticky/MoveTo establishment, and CombatAttackTargetSource, and retail's radar has no wielded blips. A regression test asserts an attached child stays out of that set while picking admits it. Marker anchoring had the twin problem. SmartBox::GetObjectBoundingBox @ 0x00452E20 pushes the picked object's OWN m_position - which for a child is the frame CPhysicsObj::UpdateChild @ 0x00512D50 recomposes each tick as Frame::combine(parent part frame, holding frame) - and CPartArray::GetSelectionSphere @ 0x00518B80 scales the authored sphere by that object's own part-array scale. acdream stores the PARENT's root in the child projection's Position/Rotation because the child's MeshRefs are parent-relative, which put the vivid brackets at the wielder's feet. The composed child root is already published per frame to EntityEffectPoseRegistry by EquippedChildRenderController.PublishChildPose, so selection now borrows it through an injected Func<uint, Matrix4x4?> wired in LivePresentationComposition beside the existing selection-sphere hook. There is no parent fallback: a child with no published composed root has no live frame this tick and no sphere. Its part-array scale comes from the spawn record, the same source EquippedChildRenderController.TryRealize reads, because an Attached WorldEntity carries the parent-derived pose rather than its own ObjScale. The sr_Use branch of RecvNotice_SmartBoxObjectFound @ 0x004E5AD0 guards ItemHolder::UseObject with `found->pwd._wielderID != SmartBox::player_id` at 0x004E5BE9 while still selecting and flashing. Equipped-child picking makes that click reachable, so the gate ships with it as IWorldSelectionQuery.IsWieldedByPlayer. CPhysicsObj::SetLighting @ 0x00511A80 is non-recursive, so the pulse lights the clicked object's own part array only - clicking a weapon never flashes its wielder. That follows from routing the pulse identity through the same predicate. RetailWorldPicker, RetailSelectionScene, WbDrawDispatcher, and EquippedChildRenderController are untouched, as are all wire and physics paths. The slice REMOVES an undocumented deviation (Attached projections excluded from pick eligibility versus retail's part-id pick) and introduces none, so no retail-divergence-register row is owed in either direction. Gates: dotnet build green; AcDream.App.Tests 3,951 passed / 3 skipped; complete Release solution 9,783 passed / 5 skipped; tools\run-connected-world-lifecycle-gate.ps1 RESULT=PASS. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
9fdfe68c7f
commit
f6db964fd5
9 changed files with 570 additions and 25 deletions
|
|
@ -724,7 +724,18 @@ internal sealed class LivePresentationCompositionPhase
|
|||
}
|
||||
return (sphere.Origin, sphere.Radius);
|
||||
}
|
||||
});
|
||||
},
|
||||
// CPhysicsObj::UpdateChild @ 0x00512D50 recomposes an equipped
|
||||
// child's own m_position from Frame::combine(parent part frame,
|
||||
// holding frame) every tick; SmartBox::GetObjectBoundingBox @
|
||||
// 0x00452E20 anchors the selection sphere on that own frame.
|
||||
// EquippedChildRenderController publishes exactly that composed
|
||||
// root here each frame, so selection borrows it rather than the
|
||||
// parent-derived bookkeeping pose.
|
||||
localEntityId =>
|
||||
d.EffectPoses.TryGetRootPose(localEntityId, out Matrix4x4 childRoot)
|
||||
? childRoot
|
||||
: null);
|
||||
var radarSnapshotProvider = new RadarSnapshotProvider(
|
||||
d.EntityObjects.Objects,
|
||||
liveEntities,
|
||||
|
|
|
|||
|
|
@ -159,7 +159,13 @@ internal sealed class SelectionInteractionController
|
|||
string label = _query.Describe(guid);
|
||||
Console.WriteLine($"[B.4b] pick guid=0x{guid:X8} name={label}");
|
||||
_toast?.Invoke($"Selected: {label}");
|
||||
if (useImmediately)
|
||||
// The sr_Use branch of RecvNotice_SmartBoxObjectFound @ 0x004E5AD0
|
||||
// guards ItemHolder::UseObject with
|
||||
// `if (found->pwd._wielderID != SmartBox::player_id)` at 0x004E5BE9.
|
||||
// Clicking your own wielded weapon selects and flashes it but sends no
|
||||
// Use. Equipped-child picking makes that click reachable, so the gate
|
||||
// ships with it.
|
||||
if (useImmediately && !_query.IsWieldedByPlayer(guid))
|
||||
EnqueueIdentityBound(
|
||||
RuntimeQueuedInteractionKind.Activate,
|
||||
guid,
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ internal interface IWorldSelectionQuery
|
|||
ClosestCombatTarget? FindClosestHostileMonster();
|
||||
bool IsUseable(uint serverGuid);
|
||||
bool IsPickupable(uint serverGuid);
|
||||
bool IsWieldedByPlayer(uint serverGuid);
|
||||
bool TryGetApproach(uint serverGuid, out InteractionApproach approach);
|
||||
Vector3? GetCombatCameraTargetPoint(uint serverGuid);
|
||||
}
|
||||
|
|
@ -105,6 +106,7 @@ internal sealed class WorldSelectionQuery
|
|||
private readonly Func<PlayerInteractionPose?> _playerPose;
|
||||
private readonly Func<uint, WorldEntity, (float Radius, float Height)> _setupCylinder;
|
||||
private readonly Func<uint, (Vector3 Origin, float Radius)?> _selectionSphere;
|
||||
private readonly Func<uint, Matrix4x4?> _childRootPose;
|
||||
|
||||
public WorldSelectionQuery(
|
||||
LiveEntityRuntime liveEntities,
|
||||
|
|
@ -115,7 +117,8 @@ internal sealed class WorldSelectionQuery
|
|||
Func<Vector2> cursor,
|
||||
Func<PlayerInteractionPose?> playerPose,
|
||||
Func<uint, WorldEntity, (float Radius, float Height)> setupCylinder,
|
||||
Func<uint, (Vector3 Origin, float Radius)?> selectionSphere)
|
||||
Func<uint, (Vector3 Origin, float Radius)?> selectionSphere,
|
||||
Func<uint, Matrix4x4?> childRootPose)
|
||||
{
|
||||
_liveEntities = liveEntities ?? throw new ArgumentNullException(nameof(liveEntities));
|
||||
_objects = objects ?? throw new ArgumentNullException(nameof(objects));
|
||||
|
|
@ -126,6 +129,7 @@ internal sealed class WorldSelectionQuery
|
|||
_playerPose = playerPose ?? throw new ArgumentNullException(nameof(playerPose));
|
||||
_setupCylinder = setupCylinder ?? throw new ArgumentNullException(nameof(setupCylinder));
|
||||
_selectionSphere = selectionSphere ?? throw new ArgumentNullException(nameof(selectionSphere));
|
||||
_childRootPose = childRootPose ?? throw new ArgumentNullException(nameof(childRootPose));
|
||||
}
|
||||
|
||||
public uint? PickAtCursor(bool includeSelf)
|
||||
|
|
@ -144,8 +148,12 @@ internal sealed class WorldSelectionQuery
|
|||
camera.View,
|
||||
camera.Projection,
|
||||
includeSelf ? 0u : _playerGuid());
|
||||
// Render::GfxObjUnderSelectionRay @ 0x0054C740 records the winning
|
||||
// part's own physobj id, so an equipped child resolves to the CHILD's
|
||||
// GUID. There is no parent fallback in the retail path: a hit whose
|
||||
// identity is no longer current is simply discarded.
|
||||
return hit is { } found
|
||||
&& _liveEntities.TryGetInteractionEligibleRecord(
|
||||
&& _liveEntities.TryGetPickEligibleRecord(
|
||||
found.ServerGuid,
|
||||
found.LocalEntityId,
|
||||
out _)
|
||||
|
|
@ -175,7 +183,7 @@ internal sealed class WorldSelectionQuery
|
|||
uint serverGuid,
|
||||
out WorldInteractionTarget target)
|
||||
{
|
||||
if (_liveEntities.TryGetInteractionEligibleRecord(
|
||||
if (_liveEntities.TryGetPickEligibleRecord(
|
||||
serverGuid,
|
||||
out LiveEntityRecord record)
|
||||
&& record.WorldEntity is { } entity)
|
||||
|
|
@ -192,7 +200,7 @@ internal sealed class WorldSelectionQuery
|
|||
=> IsCurrent(target.ServerGuid, target.LocalEntityId);
|
||||
|
||||
public bool IsCurrent(uint serverGuid, uint localEntityId)
|
||||
=> _liveEntities.TryGetInteractionEligibleRecord(serverGuid, localEntityId, out _);
|
||||
=> _liveEntities.TryGetPickEligibleRecord(serverGuid, localEntityId, out _);
|
||||
|
||||
public ItemType GetItemType(uint serverGuid)
|
||||
=> _objects.Get(serverGuid)?.Type ?? ItemType.None;
|
||||
|
|
@ -268,12 +276,16 @@ internal sealed class WorldSelectionQuery
|
|||
// ACCWeenieObject::selectedID intact while suppressing its own marker
|
||||
// for self, player-owned objects, and objects whose current state is
|
||||
// IN_CONTAINER. ContainerId is our authoritative placement projection
|
||||
// for that retail state.
|
||||
// for that retail state. PositionState.WIELDED is a distinct retail
|
||||
// state (acclient.h:6802), so a remote character's wielded item keeps
|
||||
// its marker while the local player's own wielded item is suppressed
|
||||
// by the shared IsOwnedByObject test.
|
||||
if (serverGuid == playerGuid
|
||||
|| target is null
|
||||
|| _objects.IsOwnedByObject(serverGuid, playerGuid)
|
||||
|| target.ContainerId != 0u
|
||||
|| !_liveEntities.TryGetSpatiallyProjectedRecord(serverGuid, out _)
|
||||
|| !(_liveEntities.TryGetSpatiallyProjectedRecord(serverGuid, out _)
|
||||
|| _liveEntities.TryGetAttachedProjectedRecord(serverGuid, out _))
|
||||
|| !TryGetSelectionSphere(serverGuid, out Vector3 center, out float radius))
|
||||
{
|
||||
return null;
|
||||
|
|
@ -286,10 +298,25 @@ internal sealed class WorldSelectionQuery
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// SmartBox::GetObjectBoundingBox @ 0x00452E20 delegates to
|
||||
/// CPhysicsObj::GetSelectionSphere @ 0x0050EA40 and uses a 0.1-unit
|
||||
/// fallback when Setup authored no sphere.
|
||||
/// SmartBox::GetObjectBoundingBox @ 0x00452E20 pushes the object's OWN
|
||||
/// <c>m_position</c> (<c>Render::positionPush(3, &obj->m_position)</c>)
|
||||
/// and delegates to CPhysicsObj::GetSelectionSphere @ 0x0050EA40, which
|
||||
/// scales the Setup sphere by that object's own part-array scale
|
||||
/// (CPartArray::GetSelectionSphere @ 0x00518B80). A 0.1-unit fallback is
|
||||
/// used when Setup authored no sphere.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// For an equipped child the object's own m_position is the frame
|
||||
/// CPhysicsObj::UpdateChild @ 0x00512D50 composes each tick as
|
||||
/// <c>Frame::combine(parent part frame, holding frame)</c>. acdream stores
|
||||
/// the PARENT's root in the child projection's Position/Rotation
|
||||
/// (EquippedChildRenderController.ApplyParentWorldPose) because the child's
|
||||
/// MeshRefs are parent-relative, so the exact equivalent anchor is the
|
||||
/// composed child root already published per frame to
|
||||
/// EntityEffectPoseRegistry (EquippedChildRenderController.PublishChildPose).
|
||||
/// There is no parent fallback: with no published child root the child has
|
||||
/// no live composed frame this tick and has no sphere.
|
||||
/// </remarks>
|
||||
public bool TryGetSelectionSphere(
|
||||
uint serverGuid,
|
||||
out Vector3 worldCenter,
|
||||
|
|
@ -300,7 +327,17 @@ internal sealed class WorldSelectionQuery
|
|||
if (!_liveEntities.TryGetWorldEntity(serverGuid, out WorldEntity entity))
|
||||
return false;
|
||||
|
||||
worldCenter = entity.Position;
|
||||
bool attached =
|
||||
_liveEntities.TryGetAttachedProjectedRecord(serverGuid, out _);
|
||||
Matrix4x4 childRoot = Matrix4x4.Identity;
|
||||
if (attached)
|
||||
{
|
||||
if (_childRootPose(entity.Id) is not { } published)
|
||||
return false;
|
||||
childRoot = published;
|
||||
}
|
||||
|
||||
worldCenter = attached ? childRoot.Translation : entity.Position;
|
||||
worldRadius = 0.1f;
|
||||
if (!_liveEntities.TryGetSnapshot(serverGuid, out var spawn)
|
||||
|| spawn.SetupTableId is not uint setupId
|
||||
|
|
@ -310,9 +347,18 @@ internal sealed class WorldSelectionQuery
|
|||
return true;
|
||||
}
|
||||
|
||||
float scale = entity.Scale > 0f ? entity.Scale : 1f;
|
||||
// An attached projection never carries its wire ObjScale on the
|
||||
// WorldEntity — the child's scale is baked into its part transforms by
|
||||
// EquippedChildAttachment.TryComposePoseInto, leaving RootLocal rigid.
|
||||
// The spawn record is therefore the authoritative part-array scale,
|
||||
// exactly as EquippedChildRenderController.TryRealize reads it.
|
||||
float scale = attached
|
||||
? (spawn.ObjScale is { } childScale && childScale > 0f ? childScale : 1f)
|
||||
: (entity.Scale > 0f ? entity.Scale : 1f);
|
||||
Vector3 localCenter = sphere.Origin * scale;
|
||||
worldCenter = entity.Position + Vector3.Transform(localCenter, entity.Rotation);
|
||||
worldCenter = attached
|
||||
? Vector3.Transform(localCenter, childRoot)
|
||||
: entity.Position + Vector3.Transform(localCenter, entity.Rotation);
|
||||
worldRadius = sphere.Radius * scale;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -326,6 +372,22 @@ internal sealed class WorldSelectionQuery
|
|||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retail's sr_Use branch of
|
||||
/// <c>UIElement_SmartBoxWrapper::RecvNotice_SmartBoxObjectFound @
|
||||
/// 0x004E5AD0</c> compares the found object's <c>pwd._wielderID</c> against
|
||||
/// <c>SmartBox::player_id</c> at <c>0x004E5BE9</c> and calls
|
||||
/// <c>ItemHolder::UseObject</c> only when they differ. Selection and the
|
||||
/// click lighting pulse still happen for the player's own wielded item.
|
||||
/// </summary>
|
||||
public bool IsWieldedByPlayer(uint serverGuid)
|
||||
{
|
||||
uint playerGuid = _playerGuid();
|
||||
return playerGuid != 0u
|
||||
&& _objects.Get(serverGuid) is { } item
|
||||
&& item.WielderId == playerGuid;
|
||||
}
|
||||
|
||||
/// <summary>ItemHolder::DetermineUseResult @ 0x00588460 pickup gate.</summary>
|
||||
public bool IsPickupable(uint serverGuid)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1178,7 +1178,77 @@ public sealed class LiveEntityRuntime : ILiveEntityRadarSource
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves a top-level object that currently participates in picking,
|
||||
/// Resolves a current equipped-child projection whose composed frame is
|
||||
/// live. Retail installs an equipped item as a first-class
|
||||
/// <c>CPhysicsObj</c> with its own object id and part array
|
||||
/// (<c>CPhysicsObj::add_child @ 0x0050F870</c> via
|
||||
/// <c>CSetup::GetHoldingLocation @ 0x005213F0</c>), and
|
||||
/// <c>CPhysicsObj::UpdateChild @ 0x00512D50</c> recomposes
|
||||
/// <c>Frame::combine(parent part frame, holding frame)</c> into that child's
|
||||
/// own <c>m_position</c> every frame. An attached projection therefore has
|
||||
/// real world presence even though it is deliberately absent from the
|
||||
/// interaction/radar/auto-target visible set.
|
||||
/// </summary>
|
||||
public bool TryGetAttachedProjectedRecord(
|
||||
uint serverGuid,
|
||||
out LiveEntityRecord record)
|
||||
{
|
||||
if (_projections.TryGetCurrent(serverGuid, out LiveEntityRecord found)
|
||||
&& found.WorldEntity is not null
|
||||
&& found.ProjectionKind is LiveEntityProjectionKind.Attached
|
||||
&& found.IsSpatiallyProjected)
|
||||
{
|
||||
record = found;
|
||||
return true;
|
||||
}
|
||||
|
||||
record = null!;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves an object that currently participates in mouse picking.
|
||||
/// Retail's only candidacy rule is "a drawn part whose owning physics
|
||||
/// object has a nonzero id" (<c>CPhysicsPart::Draw @ 0x0050D7A0</c> guards
|
||||
/// on <c>CPhysicsPart::get_physobj_id @ 0x0050D490</c>, and
|
||||
/// <c>Render::GfxObjUnderSelectionRay @ 0x0054C740</c> accumulates the
|
||||
/// hit under that id) — there is no parent redirection and no
|
||||
/// wielded-specific gate, so a click on a wielded weapon returns the
|
||||
/// weapon's own GUID. Picking therefore admits attached projections on top
|
||||
/// of the ordinary top-level visible set. This is deliberately NOT the
|
||||
/// interaction-eligible predicate: radar, auto-target, and
|
||||
/// MoveTo/Sticky establishment must stay wielded-item free.
|
||||
/// </summary>
|
||||
public bool TryGetPickEligibleRecord(
|
||||
uint serverGuid,
|
||||
out LiveEntityRecord record)
|
||||
=> TryGetInteractionEligibleRecord(serverGuid, out record)
|
||||
|| TryGetAttachedProjectedRecord(serverGuid, out record);
|
||||
|
||||
/// <summary>
|
||||
/// Pick eligibility bound to one logical incarnation. A stale published
|
||||
/// frame must never retarget a replacement which reused the server GUID.
|
||||
/// </summary>
|
||||
public bool TryGetPickEligibleRecord(
|
||||
uint serverGuid,
|
||||
uint localEntityId,
|
||||
out LiveEntityRecord record)
|
||||
{
|
||||
if (serverGuid != 0u
|
||||
&& localEntityId != 0u
|
||||
&& TryGetPickEligibleRecord(serverGuid, out LiveEntityRecord found)
|
||||
&& found.WorldEntity!.Id == localEntityId)
|
||||
{
|
||||
record = found;
|
||||
return true;
|
||||
}
|
||||
|
||||
record = null!;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves a top-level object that currently participates in
|
||||
/// targeting, radar, and wire-driven MoveTo/Sticky establishment.
|
||||
/// Pending, attached, and Hidden projections are intentionally excluded.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue