feat(vfx): decode retail hooks and typed tables

Replace the incomplete package path with one DatCollection-backed compatibility seam for PhysicsScripts and Animations. Preserve CreateBlockingParticle's inherited payload and following cursor, route every production and audit consumer through the corrected loaders, and apply retail's post-UnPack StartTime ordering.

Add exact stored-order PhysicsScriptTable upper-threshold resolution, high-byte DID and embedded-ID validation, plus live effect profiles with Setup-to-PhysicsDesc precedence across top-level and attached entity lifetimes. Keep blocking execution deferred and narrow TS-11 accordingly.

Pin synthetic malformed/cursor/order fixtures, installed-DAT blocking and recall audits, high-index IDs, IEEE boundaries, profile teardown, and ordinary decoder parity; synchronize architecture, inventory, milestones, roadmap, research, and memory.

Co-Authored-By: Codex <noreply@openai.com>
This commit is contained in:
Erik 2026-07-14 08:17:44 +02:00
parent 8dd996053d
commit 363e046112
31 changed files with 1102 additions and 73 deletions

View file

@ -230,6 +230,18 @@ public sealed class EquippedChildRenderController : IDisposable
out IReadOnlyList<MeshRef> parts))
return;
// A parented object may materialize here before the ordinary world
// hydration path sees it. Install its logical effect profile before
// MaterializeLiveEntity registers runtime resources, exactly as for a
// top-level projection; rebucketing/reattachment must never recreate it.
if (!_liveEntities.TryGetEffectProfile(childGuid, out _))
{
var effectProfile = childSpawn.Physics is { } physics
? Vfx.EntityEffectProfile.CreateLive(childSetup, physics)
: Vfx.EntityEffectProfile.CreateDatStatic(childSetup);
_liveEntities.SetEffectProfile(childGuid, effectProfile);
}
Remove(childGuid);
WorldEntity? entity = _liveEntities.MaterializeLiveEntity(
childGuid,

View file

@ -313,7 +313,7 @@ public sealed class GameWindow : IDisposable
AcDream.Core.World.WorldEntity Entity,
AnimatedEntity? Animation);
private AcDream.Core.Physics.DatCollectionLoader? _animLoader;
private AcDream.Core.Physics.IAnimationLoader? _animLoader;
// Phase E.1: central fan-out for animation hooks. Audio (E.2),
// particles (E.3), combat (E.4), and renderer state mutators all
@ -336,6 +336,7 @@ public sealed class GameWindow : IDisposable
// from the server and schedules the dat-defined hooks (particle spawns,
// sounds, light toggles) at their StartTime offsets.
private AcDream.Core.Vfx.PhysicsScriptRunner? _scriptRunner;
private AcDream.Content.Vfx.RetailPhysicsScriptLoader? _physicsScriptLoader;
private AcDream.App.Rendering.ParticleRenderer? _particleRenderer;
// Retail GameSky copies SkyObject.PesObjectId into CelestialPosition but
// never consumes it in CreateDeletePhysicsObjects/MakeObject/UseTime.
@ -1432,7 +1433,7 @@ public sealed class GameWindow : IDisposable
_cameraController.ModeChanged += OnCameraModeChanged;
_dats = new DatCollection(_datDir, DatAccessType.Read);
_animLoader = new AcDream.Core.Physics.DatCollectionLoader(_dats);
_animLoader = new AcDream.Content.Vfx.RetailAnimationLoader(_dats);
_emitterRegistry = new AcDream.Core.Vfx.EmitterDescRegistry(_dats);
// Phase E.3 particles: always-on, no driver dependency. Registered
@ -1447,7 +1448,10 @@ public sealed class GameWindow : IDisposable
// resolve PlayScript ids, and the same ParticleHookSink the
// animation system uses, so CreateParticleHook fired from a
// script spawns through the normal particle pipeline.
_scriptRunner = new AcDream.Core.Vfx.PhysicsScriptRunner(_dats, _particleSink);
_physicsScriptLoader = new AcDream.Content.Vfx.RetailPhysicsScriptLoader(_dats);
_scriptRunner = new AcDream.Core.Vfx.PhysicsScriptRunner(
_physicsScriptLoader.LoadPhysicsScript,
_particleSink);
// Phase G.2 lighting hooks: SetLightHook flips IsLit on
// owner-tagged lights so ignite-torch animations light up,
@ -3319,7 +3323,7 @@ public sealed class GameWindow : IDisposable
// animated entry registered) — this happens for entities the
// resolver short-circuits on.
var idleCycle = AcDream.Core.Meshing.MotionResolver.GetIdleCycle(
setup, _dats,
setup, _dats, _animLoader!,
motionTableIdOverride: spawn.MotionTableId,
stanceOverride: stanceOverride,
commandOverride: commandOverride);
@ -3688,6 +3692,14 @@ public sealed class GameWindow : IDisposable
return;
}
if (!_liveEntities!.TryGetEffectProfile(spawn.Guid, out _))
{
var effectProfile = spawn.Physics is { } physics
? AcDream.App.Rendering.Vfx.EntityEffectProfile.CreateLive(setup, physics)
: AcDream.App.Rendering.Vfx.EntityEffectProfile.CreateDatStatic(setup);
_liveEntities.SetEffectProfile(spawn.Guid, effectProfile);
}
bool createdProjection = false;
var entity = _liveEntities!.MaterializeLiveEntity(
spawn.Guid,
@ -4169,7 +4181,7 @@ public sealed class GameWindow : IDisposable
// garbage frame count → OOM).
uint poseDid = ResolvePaperdollPoseDid();
if ((poseDid >> 24) != 0x03u) return;
var anim = dats.Get<DatReaderWriter.DBObjs.Animation>(poseDid);
var anim = _animLoader?.LoadAnimation(poseDid);
var setup = dats.Get<DatReaderWriter.DBObjs.Setup>(setupId);
if (anim is null || setup is null || anim.PartFrames.Count == 0) return;
@ -4361,6 +4373,14 @@ public sealed class GameWindow : IDisposable
private void RouteSameGenerationCreateObject(
AcDream.App.World.SameGenerationCreateObjectEvents refresh)
{
if (_liveEntities!.TryGetEffectProfile(
refresh.Appearance.Guid,
out var effectProfile)
&& effectProfile is AcDream.App.Rendering.Vfx.EntityEffectProfile liveProfile)
{
liveProfile.ApplyNetworkDescription(refresh.Description);
}
OnLiveAppearanceUpdated(refresh.Appearance);
if (refresh.Parent is { } parent
@ -4481,7 +4501,7 @@ public sealed class GameWindow : IDisposable
if (mt is null) return null;
var pose = AcDream.Core.Physics.Motion.MotionTablePose.DefaultStatePartFrames(
mt, id => _dats.Get<DatReaderWriter.DBObjs.Animation>(id));
mt, id => _animLoader?.LoadAnimation(id));
if (Environment.GetEnvironmentVariable("ACDREAM_DUMP_MOTION") == "1")
{
@ -5464,7 +5484,7 @@ public sealed class GameWindow : IDisposable
// a concrete Animation + frame range. Only swap when the resolver
// returns a clearly-better cycle.
var newCycle = AcDream.Core.Meshing.MotionResolver.GetIdleCycle(
ae.Setup, _dats,
ae.Setup, _dats, _animLoader!,
motionTableIdOverride: null,
stanceOverride: stance,
commandOverride: command);

View file

@ -135,7 +135,7 @@ public static class RenderBootstrap
var textureCache = new TextureCache(gl, dats, bindless);
// --- AnimLoader (GameWindow ~1240) ---
var animLoader = new AcDream.Core.Physics.DatCollectionLoader(dats);
var animLoader = new AcDream.Content.Vfx.RetailAnimationLoader(dats);
// --- WbMeshAdapter (GameWindow ~2286-2287) ---
var wbLogger = NullLogger<Wb.WbMeshAdapter>.Instance;

View file

@ -0,0 +1,73 @@
using AcDream.App.World;
using AcDream.Core.Net.Messages;
using AcDream.Core.Vfx;
using DatReaderWriter.DBObjs;
namespace AcDream.App.Rendering.Vfx;
/// <summary>
/// DAT defaults and the currently installed network effect description for
/// one logical entity incarnation.
/// </summary>
/// <remarks>
/// Retail precedence comes from <c>CPhysicsObj::InitDefaults</c>
/// (<c>0x005139D0</c>) followed by <c>CPhysicsObj::set_description</c>
/// (<c>0x00514F40</c>). Setup's direct default PES runs during initialization;
/// a network PhysicsDesc then unconditionally replaces the typed table, even
/// when PeTable was absent or zero.
/// </remarks>
public sealed class EntityEffectProfile : ILiveEntityEffectProfile
{
private EntityEffectProfile(Setup setup)
{
SetupDefaultScriptDid = NormalizePhysicsScriptDid(setup.DefaultScript.DataId);
CurrentPhysicsScriptTableDid = NormalizeTableDid((uint)setup.DefaultScriptTable);
}
public uint? SetupDefaultScriptDid { get; }
public uint? CurrentPhysicsScriptTableDid { get; private set; }
public uint RawDefaultScriptType { get; private set; }
public float DefaultScriptIntensity { get; private set; }
public bool HasNetworkDescription { get; private set; }
/// <summary>Setup defaults remain active for a DAT/static object.</summary>
public static EntityEffectProfile CreateDatStatic(Setup setup)
{
ArgumentNullException.ThrowIfNull(setup);
return new EntityEffectProfile(setup);
}
/// <summary>
/// Applies Setup initialization followed by the live PhysicsDesc, matching
/// retail construction order.
/// </summary>
public static EntityEffectProfile CreateLive(
Setup setup,
PhysicsSpawnData physics)
{
ArgumentNullException.ThrowIfNull(setup);
var profile = new EntityEffectProfile(setup);
profile.ApplyNetworkDescription(physics);
return profile;
}
/// <summary>
/// Replaces all network-owned effect defaults. Nullable wire fields use
/// PhysicsDesc's initialized zero values; they never resurrect Setup's
/// typed table.
/// </summary>
public void ApplyNetworkDescription(PhysicsSpawnData physics)
{
CurrentPhysicsScriptTableDid = NormalizeTableDid(
physics.PhysicsScriptTableId.GetValueOrDefault());
RawDefaultScriptType = physics.DefaultScriptType.GetValueOrDefault();
DefaultScriptIntensity = physics.DefaultScriptIntensity.GetValueOrDefault();
HasNetworkDescription = true;
}
private static uint? NormalizePhysicsScriptDid(uint did) =>
PhysicsScriptTableResolver.IsPhysicsScriptDid(did) ? did : null;
private static uint? NormalizeTableDid(uint did) =>
PhysicsScriptTableResolver.IsPhysicsScriptTableDid(did) ? did : null;
}

View file

@ -542,6 +542,7 @@ public sealed class InboundPhysicsStateController
: null;
return new SameGenerationCreateObjectEvents(
physics,
new ObjDescEvent.Parsed(
incoming.Guid,
new CreateObject.ModelData(
@ -632,6 +633,7 @@ public readonly record struct CreateParentUpdate(
ushort ChildPositionSequence);
public readonly record struct SameGenerationCreateObjectEvents(
PhysicsSpawnData Description,
ObjDescEvent.Parsed Appearance,
CreateParentUpdate? Parent,
WorldSession.EntityPositionUpdate? Position,

View file

@ -477,6 +477,30 @@ public sealed class LiveEntityRuntime
return true;
}
public void SetEffectProfile(uint serverGuid, ILiveEntityEffectProfile profile)
{
ArgumentNullException.ThrowIfNull(profile);
if (!_recordsByGuid.TryGetValue(serverGuid, out LiveEntityRecord? record))
throw new InvalidOperationException(
$"Cannot bind an effect profile before live entity 0x{serverGuid:X8} exists.");
record.EffectProfile = profile;
}
public bool TryGetEffectProfile(
uint serverGuid,
out ILiveEntityEffectProfile profile)
{
if (_recordsByGuid.TryGetValue(serverGuid, out LiveEntityRecord? record)
&& record.EffectProfile is { } found)
{
profile = found;
return true;
}
profile = null!;
return false;
}
public bool TryGetSnapshot(uint guid, out WorldSession.EntitySpawn spawn) =>
_inbound.TryGetSnapshot(guid, out spawn);