Idle animation loop: decomp re-read of gmCGAppearancePage::Update's trailing StartAnimation/StopAnimation gate (~0x0047EF01-0x0047EF12) plus the ctor evidence that m_bZoomedIn is a decompiler-elided bool (never explicitly set away from its zero default, unlike its two sibling bools) establishes that retail's chargen preview defaults to the idle loop PLAYING, not the frozen rest pose CC6a shipped as a deliberate simplification (TS-83) — the rest pose only appears once Zoom In fires. New Core primitive RetailAnimationCyclePlayback ports CPhysicsObj::set_sequence_animation's advance-with-wrap + lerp/slerp effect (the same algorithm LiveEntityAnimationPresenter's legacy NPC-idle branch already carries inline; not consolidated this round — out of blast radius for a preview-only feature, noted in the new type's own doc). New ChargenPreviewAnimator drives the per-tick swap; ChargenPreviewEntityBuilder gained TryBuildAnimated alongside the byte-behavior-unchanged TryBuild. Olthoi/OlthoiAcid use the SAME enum key for idle and rest DIDs (decomp-confirmed quirk). TS-83 retired in the register (§4 count 50->49). Rotation controller: ChargenPreviewRotationController ports Rotate/DoRotation (0x0047CB50/0x0047CA80) verbatim — toggle-to-stop, deltaDegrees = ((now-last)/RotationSecondsPerRevolution)*360, single-pass +-360 clamp (not a full modulo, matching retail's own tail), the -1.0 invalidation sentinel. Applies to the entity's heading via the existing MoveToMath.SetHeading port, not the camera, confirming CC6a's own note. Zoom tween: ChargenPreviewZoomController ports ZoomIn/ZoomOut/ DoZoomAnimation (0x0047CF00/0x0047D050/0x0047C960) — a LINEAR 0.6s tween (no easing curve in the decomp) between the already-recorded camera eye profiles, calling into the animator's zoom swap IMMEDIATELY at button-press time, matching retail's call order exactly. m_alternateSetupID (research correction): re-reading the decomp function-by-function found all five m_alternateSetupID write sites — including the two the CC6a review cited — belong to gmBarberUI (the post-creation barber shop), not gmCGAppearancePage, which has no m_pOption1Checkbox-equivalent field and never writes the field. For character creation the field is always INVALID_DID in retail. TryCompose still gained a real, decomp-cited alternateSetupIdOverride parameter (default no-op) implementing gmCG3DView::Update's generic override precedence, for a future non-chargen consumer. RetailHeldPose extraction: shared ResolvePoseDid/ComposePartTransform between RetailPaperdollPoseApplicator and ChargenPreviewEntityBuilder — a clean mechanical extraction, behavior-identical on the paperdoll side. Bookkeeping: CC6a ledger row now cites its real commit SHAs (55bfd9ca,1774d8b2); new CC6b-PRE ledger row records scope done + the page-mount half still owed. Tests: RetailAnimationCyclePlaybackTests (10, Core), ChargenAppearanceFactoryTests (+4), ChargenPreviewRotationControllerTests (9), ChargenPreviewZoomControllerTests (7), ChargenPreviewAnimatorTests (7, hand-built fixtures), ChargenPreviewEntityBuilderTests (+5, installed-DAT). Core.Tests 4786/1 skip, Content.Tests 147/0, App.Tests 5149/6 skips — zero failures, full solution Release build green. One pre-existing, unrelated flake noted: Core.Net.Tests' NakEmissionTests loss soak failed once in the full-suite run, passed 1/1 isolated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
61 lines
2.9 KiB
C#
61 lines
2.9 KiB
C#
using System.Numerics;
|
|
using AcDream.Content;
|
|
using DatReaderWriter;
|
|
using DatReaderWriter.DBObjs;
|
|
|
|
namespace AcDream.App.Rendering;
|
|
|
|
/// <summary>
|
|
/// Shared primitives behind retail's "resolve a rest-pose DID via master-map
|
|
/// slot 7, load its Animation, hold the final frame" algorithm — the
|
|
/// mechanism <see cref="RetailPaperdollPoseApplicator"/> (paperdoll,
|
|
/// <c>gmPaperDollUI::RedressCreature @ 0x004A3C22</c>) and
|
|
/// <see cref="ChargenPreviewEntityBuilder"/> (chargen preview,
|
|
/// <c>gmCG3DView::StopAnimation @ 0x004EE640</c>) both implement. Extracted
|
|
/// per the CC6a review's F11/F12 note ("before adding a FOURTH consumer... a
|
|
/// shared <c>RetailHeldPose</c> helper is worth extracting before a fourth
|
|
/// held-pose consumer exists") — CC6b's own idle-loop work makes chargen's
|
|
/// implementation grow enough that mechanically sharing the two primitives
|
|
/// BOTH sites already had byte-identical (DID resolution, final-frame
|
|
/// transform composition) is a clean win without forcing the two sites'
|
|
/// slightly different per-index LOOP shapes (paperdoll walks an
|
|
/// already-built, already-filtered <c>WorldEntity.MeshRefs</c>; chargen
|
|
/// walks the pre-filter, Setup-part-indexed scratch list) into one method
|
|
/// they don't actually share.
|
|
/// </summary>
|
|
internal static class RetailHeldPose
|
|
{
|
|
/// <summary>
|
|
/// <c>DBCache::GetDIDFromEnumStatic(poseEnum, 7)</c> equivalent: master
|
|
/// map → slot 7's sub-map → <paramref name="poseEnum"/>'s Animation DID.
|
|
/// Returns 0 if any link in the chain is missing. MUST be called under
|
|
/// the caller's dat lock (see <see cref="ChargenPreviewEntityBuilder.TryBuild"/>'s
|
|
/// <c>datLock</c> doc — <c>DatCollection</c> is not thread-safe).
|
|
/// </summary>
|
|
public static uint ResolvePoseDid(IDatReaderWriter dats, uint poseEnum)
|
|
{
|
|
uint masterDid = (uint)dats.Portal.Db.Header.MasterMapId;
|
|
if (masterDid == 0
|
|
|| !dats.Portal.TryGet<EnumIDMap>(masterDid, out var master)
|
|
|| !master.ClientEnumToID.TryGetValue(7u, out uint subDid)
|
|
|| !dats.Portal.TryGet<EnumIDMap>(subDid, out var sub))
|
|
{
|
|
return 0u;
|
|
}
|
|
|
|
return sub.ClientEnumToID.TryGetValue(poseEnum, out uint did) ? did : 0u;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Retail's per-part pose transform: <c>Scale(defaultScale) *
|
|
/// Rotate(orientation) * Translate(origin)</c> — the SAME composition
|
|
/// both <c>RetailPaperdollPoseApplicator.Apply</c> and
|
|
/// <see cref="ChargenPreviewEntityBuilder"/>'s pose steps use, whether
|
|
/// the (origin, orientation) pair comes from a held final frame or an
|
|
/// interpolated idle-cycle frame.
|
|
/// </summary>
|
|
public static Matrix4x4 ComposePartTransform(Vector3 defaultScale, Vector3 origin, Quaternion orientation) =>
|
|
Matrix4x4.CreateScale(defaultScale)
|
|
* Matrix4x4.CreateFromQuaternion(orientation)
|
|
* Matrix4x4.CreateTranslation(origin);
|
|
}
|