phase(N.4) Task 17: EntitySpawnAdapter for server-spawned per-instance content
Routes server-spawned (CreateObject) entities through the per-instance rendering path. Filter: ServerGuid != 0. Atlas-tier entities (procedural, ServerGuid == 0) flow through LandblockSpawnAdapter (Task 11) instead. For entities with PaletteOverride set, walks each MeshRef.SurfaceOverrides map and calls TextureCache.GetOrUploadWithPaletteOverride to pre-warm the palette-composed GL texture before the first draw. Surfaces not in the SurfaceOverrides map (i.e. whose ids are only known after opening the GfxObj dat) are decoded lazily by the draw dispatcher on first use, consistent with StaticMeshRenderer. Builds AnimatedEntityState per server-guid via injected sequencer factory (Func<WorldEntity, AnimationSequencer>). The factory decouples the adapter from DatCollection so tests pass a stub lambda without a GL context. OnRemove releases per-entity state. Unknown guids no-op. Introduces ITextureCachePerInstance: thin seam interface over the palette decode path so EntitySpawnAdapter tests can use a CapturingTextureCache mock without constructing a GL context. TextureCache implements it. Adjustment 4 documented in source comments: WorldEntity does not currently expose HiddenPartsMask or AnimPartChanges (they are consumed upstream in the network layer before the WorldEntity is built). HideParts / SetPartOverride calls are placeholder TODO'd for when those fields are promoted. Wired into GpuWorldState.AppendLiveEntity (OnCreate) and RemoveEntityByServerGuid (OnRemove). Constructed in GameWindow under the ACDREAM_USE_WB_FOUNDATION flag alongside LandblockSpawnAdapter. Sequencer factory captures _dats + _animLoader at construction time; falls back to an empty Setup + MotionTable via NullAnimLoader when dats are unavailable. 10 new tests: server-spawn routing, atlas-tier skip, palette decode pre-warm (with and without surface overrides), OnRemove lifecycle, unknown-guid noop, multi-entity isolation. All pass; 8 pre-existing failures unchanged. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
ce72c574e9
commit
c02c307bee
6 changed files with 499 additions and 3 deletions
|
|
@ -8,7 +8,7 @@ using SurfaceType = DatReaderWriter.Enums.SurfaceType;
|
|||
|
||||
namespace AcDream.App.Rendering;
|
||||
|
||||
public sealed unsafe class TextureCache : IDisposable
|
||||
public sealed unsafe class TextureCache : Wb.ITextureCachePerInstance, IDisposable
|
||||
{
|
||||
private readonly GL _gl;
|
||||
private readonly DatCollection _dats;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue