F1 (BLOCKING, doc-only) — the idle-by-default rationale rested on an unsound "uninitialized C++ member defaults to 0" argument (heap operator-new memory is indeterminate, not zero). Verified and replaced with the real evidence: gmCGAppearancePage::InitializePage @0x0047FDD0 writes an EXPLICIT this->m_bZoomedIn = 0; at 0x004802C3, immediately after that same function points the camera at the zoomed-IN per-heritage eye (0x00480286-0x0048029E). Fixed in all three places: the register's TS-83 retirement clause, ChargenPreviewAnimator's class doc, ChargenPreviewZoomController.IsZoomedIn's doc. Recorded the retail quirk this implies: the character starts framed close-up while not-zoomed-in, so the first Zoom In click (once mounted) tweens close-eye->close-eye (visually null) while still freezing the animation — the port reproduces this faithfully. F2 — ChargenPreviewZoomController and ChargenPreviewAnimator kept independent _zoomedIn bools synced only via a nullable animator parameter, risking desync. Retail's m_bZoomedIn is a single field gating both camera and animation, so the fix makes the animator the sole state owner: ChargenPreviewZoomController now takes its ChargenPreviewAnimator as a required constructor dependency, IsZoomedIn reads straight through to it, and ZoomIn/ZoomOut no longer take a parameter at all — there is no second bool left to disagree. F3 — documented the DoRotation counter-clockwise branch's x87-stack decompiler artifact (BN renders x87_r7_1 = x87_r6_3 at 0x0047CAEB, which would store delta-degrees instead of the timestamp for CCW only); the port already stores "now" in both branches, cited against feedback_bn_decomp_field_names.md. F4 — ChargenPreviewAnimator.ApplyIdleFrame now double-buffers two List<MeshRef> instead of allocating fresh every 30fps tick. F5 — filed docs/ISSUES.md #402 tracking the RetailAnimationCyclePlayback / LiveEntityAnimationPresenter duplication as an owned post-CC follow-up, referenced from the new type's own doc. F6 — reworded the ChargenPreviewEntityBuilder.TryBuild "byte-identical" claim to result-identical (TryBuildAnimated now also resolves the idle DID and loads the idle Animation before the wrapper discards them). F7 — added the missing clockwise >360 clamp test (readable decomp polarity, unlike F3's CCW artifact). ALSO — rewrote the CC6b ledger row's m_alternateSetupID MUST-COVER note per the reviewer's F11 concession: all five write sites belong to gmBarberUI (the post-creation barber shop), not gmCGAppearancePage, which has no option-checkbox-equivalent field at all. Added the enclosing-function citations and an explicit directive that CC6b-mount must NOT build a crown/no-flame checkbox on the Appearance page. Tests: ChargenPreviewRotationControllerTests +1 (10 total), ChargenPreviewZoomControllerTests +2 and every case rewritten for the required-animator constructor (9 total). Core.Tests 4786/1 skip (unchanged), Content.Tests 147/0, App.Tests 5152/6 skips (+3) — zero failures in isolation, full solution Release build green. Two pre-existing flakes observed across repeated full-solution runs, neither caused by this round and neither reproducing standalone: Core.Net.Tests' NakEmissionTests loss soak, and Content.Tests' DecodedTextureCacheTests concurrency race. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
135 lines
4.9 KiB
C#
135 lines
4.9 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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// F7: exercises the <c>>360 -> -360</c> clamp arm (pseudo-C
|
|
/// ~0x0047cb1e-0x0047cb31), the one with readable decomp polarity —
|
|
/// unlike the CCW-branch FPU-stack artifact F3 documents, this branch's
|
|
/// test/subtract shape is unambiguous. One large clockwise tick pushes
|
|
/// heading past 360 in a single call.
|
|
/// </summary>
|
|
[Fact]
|
|
public void Tick_ClockwiseAdvancePast360_ClampsBackBySubtracting360()
|
|
{
|
|
var controller = new ChargenPreviewRotationController();
|
|
controller.Toggle(ChargenRotateDirection.Clockwise);
|
|
controller.Tick(10.0); // seeds lastRotateTime = 10, zero delta.
|
|
controller.Tick(10.0 + 3.5); // 3.5s at 3s/rev = 420 deg -> 420, clamped to 60.
|
|
|
|
Assert.Equal(60f, 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);
|
|
}
|
|
}
|