refactor(rendering): isolate dispatcher candidate values

This commit is contained in:
Erik 2026-07-25 01:06:57 +02:00
parent accd402dd7
commit 58b712c6ec
5 changed files with 356 additions and 50 deletions

View file

@ -1,6 +1,4 @@
using System.Numerics;
using AcDream.Core.World;
namespace AcDream.App.Rendering.Selection;
/// <summary>
@ -10,7 +8,8 @@ namespace AcDream.App.Rendering.Selection;
internal interface IRetailSelectionRenderSink
{
void AddVisiblePart(
WorldEntity entity,
uint serverGuid,
uint localEntityId,
int partIndex,
uint gfxObjId,
Matrix4x4 partWorld);

View file

@ -103,6 +103,22 @@ internal sealed class RetailSelectionScene :
int partIndex,
uint gfxObjId,
Matrix4x4 partWorld)
{
ArgumentNullException.ThrowIfNull(entity);
AddVisiblePart(
entity.ServerGuid,
entity.Id,
partIndex,
gfxObjId,
partWorld);
}
public void AddVisiblePart(
uint serverGuid,
uint localEntityId,
int partIndex,
uint gfxObjId,
Matrix4x4 partWorld)
{
// WbDrawDispatcher is also shared by sealed CreatureMode-style UI
// viewports (paperdoll and appraisal). Those draws occur after the
@ -110,10 +126,13 @@ internal sealed class RetailSelectionScene :
// enter the world picking product.
if (!_frameOpen)
return;
if (entity.ServerGuid == 0u)
if (serverGuid == 0u)
return;
if (!_buildingKeys.Add(new PartKey(entity.Id, partIndex, gfxObjId)))
if (!_buildingKeys.Add(new PartKey(
localEntityId,
partIndex,
gfxObjId)))
return;
RetailSelectionMesh? mesh = _geometry.Resolve(gfxObjId);
if (mesh is null)
@ -123,14 +142,14 @@ internal sealed class RetailSelectionScene :
return;
_building.Add(new RetailSelectionPart(
entity.ServerGuid,
entity.Id,
serverGuid,
localEntityId,
partIndex,
partWorld,
mesh));
_currentRenderSceneObserver?.ObserveSelectionPart(
entity.ServerGuid,
entity.Id,
serverGuid,
localEntityId,
partIndex,
gfxObjId,
partWorld,