feat(render #53): add optional CachedBatch collector to ClassifyBatches

ClassifyBatches now accepts a restPose parameter (the model-matrix
component without entityWorld baked in) and an optional collector. When
collector is non-null, each classified batch is appended as a CachedBatch
record. Defaults preserve today's behavior. Used in Task 9 to populate
the cache on a static-entity miss.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-05-10 18:14:35 +02:00
parent a65a241981
commit 28513eae88

View file

@ -421,14 +421,15 @@ public sealed unsafe class WbDrawDispatcher : IDisposable
var model = ComposePartWorldMatrix( var model = ComposePartWorldMatrix(
entityWorld, meshRef.PartTransform, partTransform); entityWorld, meshRef.PartTransform, partTransform);
ClassifyBatches(partData, partGfxObjId, model, entity, meshRef, palHash, metaTable); var restPose = partTransform * meshRef.PartTransform;
ClassifyBatches(partData, partGfxObjId, model, entity, meshRef, palHash, metaTable, restPose);
drewAny = true; drewAny = true;
} }
} }
else else
{ {
var model = meshRef.PartTransform * entityWorld; var model = meshRef.PartTransform * entityWorld;
ClassifyBatches(renderData, gfxObjId, model, entity, meshRef, palHash, metaTable); ClassifyBatches(renderData, gfxObjId, model, entity, meshRef, palHash, metaTable, restPose: meshRef.PartTransform);
drewAny = true; drewAny = true;
} }
@ -724,7 +725,9 @@ public sealed unsafe class WbDrawDispatcher : IDisposable
WorldEntity entity, WorldEntity entity,
MeshRef meshRef, MeshRef meshRef,
ulong palHash, ulong palHash,
AcSurfaceMetadataTable metaTable) AcSurfaceMetadataTable metaTable,
Matrix4x4 restPose,
List<CachedBatch>? collector = null)
{ {
for (int batchIdx = 0; batchIdx < renderData.Batches.Count; batchIdx++) for (int batchIdx = 0; batchIdx < renderData.Batches.Count; batchIdx++)
{ {
@ -768,6 +771,7 @@ public sealed unsafe class WbDrawDispatcher : IDisposable
_groups[key] = grp; _groups[key] = grp;
} }
grp.Matrices.Add(model); grp.Matrices.Add(model);
collector?.Add(new CachedBatch(key, texHandle, restPose));
} }
} }