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>
117 lines
4.1 KiB
C#
117 lines
4.1 KiB
C#
using System.Numerics;
|
|
using AcDream.App.Rendering;
|
|
using Xunit;
|
|
|
|
namespace AcDream.App.Tests.Rendering;
|
|
|
|
/// <summary>
|
|
/// Pure (no dat access) tests for <see cref="ChargenPreviewRotationController"/>
|
|
/// — the port of <c>gmCGAppearancePage::Rotate</c>/<c>DoRotation</c>
|
|
/// (<c>0x0047CB50</c>/<c>0x0047CA80</c>).
|
|
/// </summary>
|
|
public sealed class ChargenPreviewRotationControllerTests
|
|
{
|
|
[Fact]
|
|
public void Toggle_StartsRotatingInTheGivenDirection()
|
|
{
|
|
var controller = new ChargenPreviewRotationController();
|
|
controller.Toggle(ChargenRotateDirection.Clockwise);
|
|
|
|
Assert.True(controller.IsRotating);
|
|
Assert.Equal(ChargenRotateDirection.Clockwise, controller.Direction);
|
|
}
|
|
|
|
[Fact]
|
|
public void Toggle_SameDirectionWhileRotating_Stops()
|
|
{
|
|
var controller = new ChargenPreviewRotationController();
|
|
controller.Toggle(ChargenRotateDirection.Clockwise);
|
|
controller.Toggle(ChargenRotateDirection.Clockwise);
|
|
|
|
Assert.False(controller.IsRotating);
|
|
}
|
|
|
|
[Fact]
|
|
public void Toggle_OppositeDirectionWhileRotating_SwitchesDirectionAndKeepsRotating()
|
|
{
|
|
var controller = new ChargenPreviewRotationController();
|
|
controller.Toggle(ChargenRotateDirection.Clockwise);
|
|
controller.Toggle(ChargenRotateDirection.CounterClockwise);
|
|
|
|
Assert.True(controller.IsRotating);
|
|
Assert.Equal(ChargenRotateDirection.CounterClockwise, controller.Direction);
|
|
}
|
|
|
|
[Fact]
|
|
public void Tick_WhileNotRotating_IsANoOp()
|
|
{
|
|
var controller = new ChargenPreviewRotationController();
|
|
controller.Tick(100.0);
|
|
|
|
Assert.Equal(0f, controller.HeadingDegrees);
|
|
}
|
|
|
|
[Fact]
|
|
public void Tick_FirstCallAfterToggle_ContributesZeroDelta()
|
|
{
|
|
// Rotate() invalidates m_dLastRotateTime so the very first DoRotation
|
|
// tick resets it to "now" rather than computing a huge jump from a
|
|
// stale/never-set timestamp.
|
|
var controller = new ChargenPreviewRotationController();
|
|
controller.Toggle(ChargenRotateDirection.Clockwise);
|
|
controller.Tick(1000.0);
|
|
|
|
Assert.Equal(0f, controller.HeadingDegrees);
|
|
}
|
|
|
|
[Fact]
|
|
public void Tick_ClockwiseAdvance_AddsTheExactPerTickFormula()
|
|
{
|
|
// deltaDegrees = ((now - last) / RotationSecondsPerRevolution) * 360.
|
|
// Seed "now" nonzero (0.0 collides with the <= 0 reset-if-invalid
|
|
// guard, same as retail's own sentinel check would if Timer::cur_time
|
|
// could ever read exactly zero — never in practice, so tests avoid
|
|
// it too).
|
|
var controller = new ChargenPreviewRotationController();
|
|
controller.Toggle(ChargenRotateDirection.Clockwise);
|
|
controller.Tick(10.0); // seeds lastRotateTime = 10, zero delta.
|
|
controller.Tick(11.5); // half a revolution at 3 s/rev.
|
|
|
|
Assert.Equal(180f, controller.HeadingDegrees, 3);
|
|
}
|
|
|
|
[Fact]
|
|
public void Tick_CounterClockwiseAdvance_SubtractsAndWrapsPositive()
|
|
{
|
|
var controller = new ChargenPreviewRotationController();
|
|
controller.Toggle(ChargenRotateDirection.CounterClockwise);
|
|
controller.Tick(10.0);
|
|
controller.Tick(11.5); // would go to -180, wraps to +180.
|
|
|
|
Assert.Equal(180f, controller.HeadingDegrees, 3);
|
|
}
|
|
|
|
[Fact]
|
|
public void Tick_AccumulatesAcrossMultipleTicks()
|
|
{
|
|
var controller = new ChargenPreviewRotationController();
|
|
controller.Toggle(ChargenRotateDirection.Clockwise);
|
|
controller.Tick(10.0);
|
|
controller.Tick(10.5); // +60 deg.
|
|
controller.Tick(11.0); // +60 deg more.
|
|
|
|
Assert.Equal(120f, controller.HeadingDegrees, 3);
|
|
}
|
|
|
|
[Fact]
|
|
public void ToOrientation_AtZeroHeading_IsIdentity()
|
|
{
|
|
var controller = new ChargenPreviewRotationController();
|
|
Quaternion orientation = controller.ToOrientation();
|
|
|
|
Assert.Equal(Quaternion.Identity.X, orientation.X, 4);
|
|
Assert.Equal(Quaternion.Identity.Y, orientation.Y, 4);
|
|
Assert.Equal(Quaternion.Identity.Z, orientation.Z, 4);
|
|
Assert.Equal(Quaternion.Identity.W, orientation.W, 4);
|
|
}
|
|
}
|