using System.Numerics;
namespace AcDream.App.Rendering.Wb;
///
/// Per-(entity, partIdx, batchIdx) classification result, stored flat inside
/// . For Setup multi-part MeshRefs each
/// subPart contributes its own entries, with
/// already containing the
/// subPart.PartTransform * meshRef.PartTransform product.
/// preserves the authored GfxObj key used by
/// retail's delayed-alpha viewer-distance ordering on cache hits.
/// is a registration-checked fast handle into the
/// dispatcher's bounded group table; a retired or synthetic entry falls back
/// to key lookup and refreshes this array entry.
///
/// Accessibility: internal because is
/// internal and shows up in this struct's constructor / Deconstruct
/// signature. The cache itself is dispatcher-internal coordination state;
/// on AcDream.App exposes the type to
/// AcDream.Core.Tests.
///
internal readonly record struct CachedBatch(
GroupKey Key,
ulong BindlessTextureHandle,
Matrix4x4 RestPose,
Vector3 LocalSortCenter = default,
WbDrawDispatcher.InstanceGroup? Group = null,
long GroupRegistration = 0);
///
/// Immutable retail-picking descriptor for one static entity part. The cache
/// stores only authored identity and rest pose; the current entity transform
/// and the selection system's live frustum/geometry verdict remain per-frame.
///
internal readonly record struct CachedSelectionPart(
int PartIndex,
uint GfxObjId,
Matrix4x4 RestPose);
///
/// One entity's cached classification. is flat across
/// (partIdx, batchIdx) and ordered as WbDrawDispatcher.ClassifyBatches
/// produced them. lets
/// sweep entries
/// efficiently when a landblock demotes or unloads.
///
/// Accessibility: internal for the same reason as
/// — its property is CachedBatch[], which
/// transitively involves .
///
internal sealed class EntityCacheEntry
{
public required uint EntityId { get; init; }
public required uint LandblockHint { get; init; }
public required CachedBatch[] Batches { get; init; }
public CachedSelectionPart[] SelectionParts { get; init; } = [];
}