fix(chargen): Campaign CC CC6b-PRE review fix round — F1-F7 + F11 concession rewrite
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>
This commit is contained in:
parent
8dfee1118f
commit
1ba22a01a8
10 changed files with 195 additions and 50 deletions
|
|
@ -24,6 +24,39 @@ What does NOT go here:
|
|||
- Every session: scan OPEN issues at start; promote/close anything we touched during the session before ending.
|
||||
- Promoting to a Phase: mark as `DONE (promoted to Phase X)` + commit SHA where the Phase entry landed.
|
||||
|
||||
## #402 — Consolidate RetailAnimationCyclePlayback into LiveEntityAnimationPresenter's legacy branch
|
||||
|
||||
**Status:** OPEN (post-CC consolidation follow-up)
|
||||
**Severity:** LOW
|
||||
**Filed:** 2026-08-15 (Campaign CC slice CC6b-PRE review fix round, F5)
|
||||
**Component:** `src/AcDream.Core/Physics/RetailAnimationCyclePlayback.cs`,
|
||||
`src/AcDream.App/Rendering/LiveEntityAnimationPresenter.cs`
|
||||
|
||||
`RetailAnimationCyclePlayback` (advance-with-wrap + lerp/slerp) is a Core,
|
||||
pure, unit-tested extraction of the SAME algorithm
|
||||
`LiveEntityAnimationPresenter.Present`'s legacy (no-`AnimationSequencer`)
|
||||
branch already carries inline for NPC idle cycles
|
||||
(`CurrFrame += legacyAdvanceSeconds * Framerate` with the same modulo wrap,
|
||||
plus its own private `TryResolvePartFrame` doing the same frame-bracket
|
||||
lerp/slerp). The chargen preview (`ChargenPreviewAnimator`) consumes the
|
||||
new shared type; the two implementations were deliberately left
|
||||
un-consolidated at CC6b-PRE — `LiveEntityAnimationPresenter` is live,
|
||||
heavily-tested, in-flight production entity-rendering code with zero
|
||||
relation to the preview-only feature that motivated the extraction, so
|
||||
touching it was judged out of that slice's blast radius.
|
||||
|
||||
That decision has no tracked owner. Someone should, in a dedicated pass
|
||||
after Campaign CC closes: redirect `LiveEntityAnimationPresenter`'s inline
|
||||
copy through `RetailAnimationCyclePlayback` (a behavior-preserving
|
||||
mechanical swap — same formulas, same order of operations) and delete the
|
||||
duplicate. Verify byte-identical output first (a differential test against
|
||||
the pre-change behavior over a representative NPC idle set) before landing.
|
||||
|
||||
**Acceptance:** one call site for the advance-with-wrap + lerp/slerp
|
||||
algorithm; `LiveEntityAnimationPresenter`'s legacy branch calls
|
||||
`RetailAnimationCyclePlayback` instead of reimplementing it; no behavior
|
||||
change to any currently-animated NPC.
|
||||
|
||||
## #401 — RetailUi should default ON (opt-out), not per-path forced
|
||||
|
||||
**Status:** OPEN (product-default decision)
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -26,6 +26,17 @@ namespace AcDream.App.Rendering;
|
|||
/// at frame 0 on every transition INTO the playing state for the same
|
||||
/// reason: <c>set_sequence_animation</c>'s <c>arg3=1</c> clears the sequence
|
||||
/// before appending, so every <c>StartAnimation</c> call restarts the clip.
|
||||
/// The DEFAULT-false claim itself rests on <c>gmCGAppearancePage::InitializePage
|
||||
/// @ 0x0047FDD0</c>'s explicit <c>this->m_bZoomedIn = 0;</c> at
|
||||
/// <c>0x004802C3</c> — written immediately after that same function sets the
|
||||
/// camera to the zoomed-IN per-heritage eye (<c>0x00480286-0x0048029E</c>),
|
||||
/// not from the ctor simply never touching the field (heap <c>operator new</c>
|
||||
/// memory is indeterminate, not zero — that argument doesn't hold on its
|
||||
/// own). One retail quirk this implies: the character starts framed close-up
|
||||
/// AND not-zoomed-in at the same time, 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 rather than
|
||||
/// treating it as a bug.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
|
|
@ -47,6 +58,15 @@ internal sealed class ChargenPreviewAnimator
|
|||
private float _currFrame;
|
||||
private bool _zoomedIn;
|
||||
|
||||
// Double-buffered so a 30fps Tick doesn't allocate a fresh List<MeshRef>
|
||||
// every frame: one buffer is whatever Entity.MeshRefs currently points
|
||||
// at (potentially still being read by the renderer's own Render() call
|
||||
// for this frame), the other is safe to Clear()+refill for the NEXT
|
||||
// tick and only gets published once fully populated.
|
||||
private readonly List<MeshRef> _meshRefsBufferA = [];
|
||||
private readonly List<MeshRef> _meshRefsBufferB = [];
|
||||
private bool _nextBufferIsA = true;
|
||||
|
||||
public ChargenPreviewAnimator(ChargenPreviewAnimatedBuild build)
|
||||
{
|
||||
_build = build ?? throw new ArgumentNullException(nameof(build));
|
||||
|
|
@ -112,7 +132,9 @@ internal sealed class ChargenPreviewAnimator
|
|||
{
|
||||
DatReaderWriter.DBObjs.Animation animation = _build.IdleAnimation!;
|
||||
IReadOnlyList<ChargenPreviewDrawablePart> parts = _build.DrawableParts;
|
||||
var meshRefs = new List<MeshRef>(parts.Count);
|
||||
List<MeshRef> meshRefs = _nextBufferIsA ? _meshRefsBufferA : _meshRefsBufferB;
|
||||
_nextBufferIsA = !_nextBufferIsA;
|
||||
meshRefs.Clear();
|
||||
foreach (ChargenPreviewDrawablePart part in parts)
|
||||
{
|
||||
bool resolved = RetailAnimationCyclePlayback.TryInterpolatePart(
|
||||
|
|
|
|||
|
|
@ -144,10 +144,14 @@ internal static class ChargenPreviewEntityBuilder
|
|||
/// resolved body Setup isn't in the dat source (a corrupted/incomplete
|
||||
/// install — the same failure shape
|
||||
/// <see cref="DatLiveEntityProjectionMaterializer"/> treats as "drop this
|
||||
/// spawn"). Unchanged since CC6a — a thin wrapper over
|
||||
/// <see cref="TryBuildAnimated"/> that keeps this method's existing
|
||||
/// callers' behavior byte-identical. New code that wants retail's true
|
||||
/// default (idle loop playing) should call
|
||||
/// spawn"). Unchanged since CC6a for its RESULT — a thin wrapper over
|
||||
/// <see cref="TryBuildAnimated"/> that returns exactly the same
|
||||
/// <c>WorldEntity</c> (rest-posed) this method's existing callers already
|
||||
/// expect; ALL 3 of those callers' tests still pass unmodified. Not
|
||||
/// byte-identical internally any more — <see cref="TryBuildAnimated"/>
|
||||
/// also resolves the idle DID and loads the idle Animation before this
|
||||
/// wrapper discards them, extra dat work the pre-CC6b method never did.
|
||||
/// New code that wants retail's true default (idle loop playing) should call
|
||||
/// <see cref="TryBuildAnimated"/> and wrap the result in a
|
||||
/// <see cref="ChargenPreviewAnimator"/> instead.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -84,7 +84,19 @@ internal sealed class ChargenPreviewRotationController
|
|||
/// <c>[0, 360)</c> — not a full modulo loop; retail's own tail only
|
||||
/// adds/subtracts 360 once (pseudo-C ~0x0047caf3-0x0047cb31), which is
|
||||
/// exactly enough for any realistic per-frame delta and is reproduced
|
||||
/// here verbatim rather than "improved" into a `%=`.
|
||||
/// here verbatim rather than "improved" into a `%=`. Fix round F3: Binary
|
||||
/// Ninja literally renders <c>x87_r7_1 = x87_r6_3</c> at <c>0x0047CAEB</c>
|
||||
/// inside the counter-clockwise branch — reassigning the local that held
|
||||
/// the "now" timestamp to the just-computed delta-degrees value — which
|
||||
/// would make the <c>0x0047CB3D</c> store into <c>m_dLastRotateTime</c>
|
||||
/// write delta-degrees instead of the timestamp for CCW only; that is an
|
||||
/// x87-FPU-stack modeling artifact of the decompiler, not real retail
|
||||
/// behavior (a shipped feature where every counter-clockwise rotation
|
||||
/// visibly diverges from clockwise is implausible, and
|
||||
/// <c>claude-memory/feedback_bn_decomp_field_names.md</c> names exactly
|
||||
/// this x87-stack-register mislabeling as a known decompiler artifact
|
||||
/// class), so this port stores <c>now</c> into <c>_lastRotateTime</c>
|
||||
/// unconditionally in BOTH directions.
|
||||
/// </summary>
|
||||
public void Tick(double now)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,6 +13,24 @@ namespace AcDream.App.Rendering;
|
|||
/// finishes (see <see cref="ChargenPreviewAnimator"/>'s own doc comment).
|
||||
///
|
||||
/// <para>
|
||||
/// <b>One owner of the zoom state (fix round F2):</b> retail's
|
||||
/// <c>m_bZoomedIn</c> is a SINGLE field on <c>gmCGAppearancePage</c> that
|
||||
/// gates both the camera target AND the animation swap — there is no way
|
||||
/// for retail's own camera and animation to disagree about which zoom state
|
||||
/// they're in. The first cut of this port kept two independent bools (one
|
||||
/// here, one on <see cref="ChargenPreviewAnimator"/>) synced only by
|
||||
/// <see cref="ZoomIn"/>/<see cref="ZoomOut"/> calling a NULLABLE animator
|
||||
/// parameter — a null pass, or any direct
|
||||
/// <see cref="ChargenPreviewAnimator.SetZoomedIn"/> call bypassing this
|
||||
/// controller, would desync the camera's target from the animation's pose.
|
||||
/// This class now takes its <see cref="ChargenPreviewAnimator"/> as a
|
||||
/// REQUIRED constructor dependency and <see cref="IsZoomedIn"/> reads
|
||||
/// straight through to <see cref="ChargenPreviewAnimator.IsZoomedIn"/> — the
|
||||
/// animator is the sole state owner, matching retail's own single-field
|
||||
/// design, and there is no longer a second bool that could disagree with it.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// Retail drives <see cref="Tick"/> once per frame from a global-message-3
|
||||
/// tick while <c>m_bShouldZoomAnimate</c> is set
|
||||
/// (<c>gmCGAppearancePage::ListenToGlobalMessage @ 0x0047CED0</c>); the
|
||||
|
|
@ -38,59 +56,68 @@ internal sealed class ChargenPreviewZoomController
|
|||
private const double InvalidDurationSentinel = -0.1;
|
||||
|
||||
private readonly uint _heritageId;
|
||||
private readonly ChargenPreviewAnimator _animator;
|
||||
private Vector3 _startEye;
|
||||
private Vector3 _targetEye;
|
||||
private double _animStartTime;
|
||||
private double _animDuration;
|
||||
private bool _shouldAnimate;
|
||||
private bool _zoomedIn;
|
||||
|
||||
public ChargenPreviewZoomController(uint heritageId, ChargenPreviewCamera camera)
|
||||
public ChargenPreviewZoomController(uint heritageId, ChargenPreviewCamera camera, ChargenPreviewAnimator animator)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(camera);
|
||||
ArgumentNullException.ThrowIfNull(animator);
|
||||
_heritageId = heritageId;
|
||||
Camera = camera;
|
||||
_animator = animator;
|
||||
}
|
||||
|
||||
public ChargenPreviewCamera Camera { get; }
|
||||
|
||||
/// <summary>Mirrors retail's <c>m_bZoomedIn</c> — false (not zoomed in)
|
||||
/// is the ctor-implicit default, matching <see cref="ChargenPreviewAnimator"/>'s
|
||||
/// own default (see that class's doc comment for the shared citation).</summary>
|
||||
public bool IsZoomedIn => _zoomedIn;
|
||||
/// <summary>
|
||||
/// Mirrors retail's <c>m_bZoomedIn</c> — a straight read-through to
|
||||
/// <see cref="ChargenPreviewAnimator.IsZoomedIn"/> (see this class's own
|
||||
/// "one owner" doc above), which itself defaults false per
|
||||
/// <c>gmCGAppearancePage::InitializePage @ 0x0047FDD0</c>'s explicit
|
||||
/// <c>this->m_bZoomedIn = 0;</c> at <c>0x004802C3</c> — written right
|
||||
/// after that same function points the camera at the zoomed-IN
|
||||
/// per-heritage eye (<c>0x00480286-0x0048029E</c>). One retail quirk
|
||||
/// this produces: 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; this port reproduces it faithfully.
|
||||
/// </summary>
|
||||
public bool IsZoomedIn => _animator.IsZoomedIn;
|
||||
|
||||
/// <summary>
|
||||
/// <c>gmCGAppearancePage::ZoomIn @ 0x0047CF00</c>: no-op if already
|
||||
/// zoomed in (retail's own early-return guard). Otherwise starts a tween
|
||||
/// from the camera's CURRENT eye to the default (zoomed-IN) per-heritage
|
||||
/// profile and swaps <paramref name="animator"/> to the frozen rest
|
||||
/// pose IMMEDIATELY (<c>gmCG3DView::StopAnimation</c>'s call site,
|
||||
/// pseudo-C ~0x0047d024, precedes the tween's own completion by
|
||||
/// definition — it runs once, synchronously, inside <c>ZoomIn</c>
|
||||
/// itself).
|
||||
/// profile and swaps the animator to the frozen rest pose IMMEDIATELY
|
||||
/// (<c>gmCG3DView::StopAnimation</c>'s call site, pseudo-C ~0x0047d024,
|
||||
/// precedes the tween's own completion by definition — it runs once,
|
||||
/// synchronously, inside <c>ZoomIn</c> itself).
|
||||
/// </summary>
|
||||
public void ZoomIn(ChargenPreviewAnimator? animator)
|
||||
public void ZoomIn()
|
||||
{
|
||||
if (_zoomedIn)
|
||||
if (IsZoomedIn)
|
||||
return;
|
||||
StartTween(ChargenPreviewCamera.ResolveDefaultEye(_heritageId));
|
||||
_zoomedIn = true;
|
||||
animator?.SetZoomedIn(true);
|
||||
_animator.SetZoomedIn(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <c>gmCGAppearancePage::ZoomOut @ 0x0047D050</c>: no-op if not
|
||||
/// currently zoomed in. Otherwise starts a tween toward the zoomed-OUT
|
||||
/// per-heritage profile and swaps <paramref name="animator"/> back to
|
||||
/// the playing idle loop immediately, mirroring <see cref="ZoomIn"/>.
|
||||
/// per-heritage profile and swaps the animator back to the playing idle
|
||||
/// loop immediately, mirroring <see cref="ZoomIn"/>.
|
||||
/// </summary>
|
||||
public void ZoomOut(ChargenPreviewAnimator? animator)
|
||||
public void ZoomOut()
|
||||
{
|
||||
if (!_zoomedIn)
|
||||
if (!IsZoomedIn)
|
||||
return;
|
||||
StartTween(ChargenPreviewCamera.ResolveZoomedOutEye(_heritageId));
|
||||
_zoomedIn = false;
|
||||
animator?.SetZoomedIn(false);
|
||||
_animator.SetZoomedIn(false);
|
||||
}
|
||||
|
||||
private void StartTween(Vector3 targetEye)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ namespace AcDream.Core.Physics;
|
|||
/// behavior-preserving mechanical follow-up (not done here — that file is
|
||||
/// live, heavily tested production entity-rendering code with zero relation
|
||||
/// to this preview-only feature, so touching it is out of this slice's
|
||||
/// blast radius by design, not oversight).
|
||||
/// blast radius by design, not oversight). Tracked as
|
||||
/// <c>docs/ISSUES.md</c> #402 so the follow-up has an owner.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static class RetailAnimationCyclePlayback
|
||||
|
|
|
|||
|
|
@ -103,6 +103,24 @@ public sealed class ChargenPreviewRotationControllerTests
|
|||
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()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,7 +13,11 @@ namespace AcDream.App.Tests.Rendering;
|
|||
/// — the port of <c>gmCGAppearancePage::ZoomIn</c>/<c>ZoomOut</c>/
|
||||
/// <c>DoZoomAnimation</c> (<c>0x0047CF00</c>/<c>0x0047D050</c>/<c>0x0047C960</c>)
|
||||
/// including its immediate wiring into <see cref="ChargenPreviewAnimator"/>'s
|
||||
/// idle-loop ↔ rest-pose swap.
|
||||
/// idle-loop ↔ rest-pose swap. Fix round F2: the controller now takes its
|
||||
/// <see cref="ChargenPreviewAnimator"/> as a required constructor dependency
|
||||
/// and owns no independent zoom-state bool of its own — every test here
|
||||
/// builds a real (hand-fixture) animator rather than exercising a
|
||||
/// camera-only path that no longer exists.
|
||||
/// </summary>
|
||||
public sealed class ChargenPreviewZoomControllerTests
|
||||
{
|
||||
|
|
@ -53,14 +57,38 @@ public sealed class ChargenPreviewZoomControllerTests
|
|||
return new ChargenPreviewAnimator(build);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_NullAnimator_Throws()
|
||||
{
|
||||
var camera = new ChargenPreviewCamera((uint)ChargenHeritageGroup.Aluvian);
|
||||
Assert.Throws<ArgumentNullException>(
|
||||
() => new ChargenPreviewZoomController((uint)ChargenHeritageGroup.Aluvian, camera, animator: null!));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsZoomedIn_ReadsThroughToTheAnimator_NoIndependentState()
|
||||
{
|
||||
var camera = new ChargenPreviewCamera((uint)ChargenHeritageGroup.Aluvian);
|
||||
var animator = MakeAnimator();
|
||||
var controller = new ChargenPreviewZoomController((uint)ChargenHeritageGroup.Aluvian, camera, animator);
|
||||
|
||||
Assert.False(controller.IsZoomedIn);
|
||||
|
||||
// Flip the animator's OWN state directly (bypassing the controller
|
||||
// entirely) — since the controller now reads straight through, there
|
||||
// is nothing to desync.
|
||||
animator.SetZoomedIn(true);
|
||||
Assert.True(controller.IsZoomedIn);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ZoomIn_StartsATweenTowardTheDefaultEye_AndMarksZoomedIn()
|
||||
{
|
||||
var camera = new ChargenPreviewCamera((uint)ChargenHeritageGroup.Aluvian);
|
||||
camera.Eye = ChargenPreviewCamera.ResolveZoomedOutEye((uint)ChargenHeritageGroup.Aluvian);
|
||||
var controller = new ChargenPreviewZoomController((uint)ChargenHeritageGroup.Aluvian, camera);
|
||||
var controller = new ChargenPreviewZoomController((uint)ChargenHeritageGroup.Aluvian, camera, MakeAnimator());
|
||||
|
||||
controller.ZoomIn(animator: null);
|
||||
controller.ZoomIn();
|
||||
|
||||
Assert.True(controller.IsZoomedIn);
|
||||
// Tween in progress — eye hasn't jumped yet (Tick hasn't run).
|
||||
|
|
@ -72,13 +100,13 @@ public sealed class ChargenPreviewZoomControllerTests
|
|||
{
|
||||
var camera = new ChargenPreviewCamera((uint)ChargenHeritageGroup.Aluvian);
|
||||
camera.Eye = ChargenPreviewCamera.ResolveZoomedOutEye((uint)ChargenHeritageGroup.Aluvian);
|
||||
var controller = new ChargenPreviewZoomController((uint)ChargenHeritageGroup.Aluvian, camera);
|
||||
controller.ZoomIn(animator: null); // real tween: zoomed-out eye -> default eye.
|
||||
var controller = new ChargenPreviewZoomController((uint)ChargenHeritageGroup.Aluvian, camera, MakeAnimator());
|
||||
controller.ZoomIn(); // real tween: zoomed-out eye -> default eye.
|
||||
controller.Tick(10.0);
|
||||
controller.Tick(10.0 + ChargenPreviewCamera.ZoomTweenDurationSeconds + 1.0); // fully complete it.
|
||||
Vector3 eyeAfterCompletion = camera.Eye;
|
||||
|
||||
controller.ZoomIn(animator: null); // second call — retail's own early-return guard.
|
||||
controller.ZoomIn(); // second call — retail's own early-return guard.
|
||||
controller.Tick(9999.0); // if ZoomIn wrongly armed a tween, this would move the eye.
|
||||
|
||||
Assert.Equal(eyeAfterCompletion, camera.Eye);
|
||||
|
|
@ -89,9 +117,9 @@ public sealed class ChargenPreviewZoomControllerTests
|
|||
{
|
||||
var camera = new ChargenPreviewCamera((uint)ChargenHeritageGroup.Aluvian);
|
||||
Vector3 startEye = camera.Eye;
|
||||
var controller = new ChargenPreviewZoomController((uint)ChargenHeritageGroup.Aluvian, camera);
|
||||
var controller = new ChargenPreviewZoomController((uint)ChargenHeritageGroup.Aluvian, camera, MakeAnimator());
|
||||
|
||||
controller.ZoomOut(animator: null);
|
||||
controller.ZoomOut();
|
||||
|
||||
Assert.False(controller.IsZoomedIn);
|
||||
Assert.Equal(startEye, camera.Eye);
|
||||
|
|
@ -102,10 +130,10 @@ public sealed class ChargenPreviewZoomControllerTests
|
|||
{
|
||||
var camera = new ChargenPreviewCamera((uint)ChargenHeritageGroup.Aluvian);
|
||||
Vector3 startEye = camera.Eye; // ctor default == the zoomed-IN eye.
|
||||
var controller = new ChargenPreviewZoomController((uint)ChargenHeritageGroup.Aluvian, camera);
|
||||
controller.ZoomIn(animator: null); // reach the "zoomed in" state (zero-distance tween — Eye already there).
|
||||
var controller = new ChargenPreviewZoomController((uint)ChargenHeritageGroup.Aluvian, camera, MakeAnimator());
|
||||
controller.ZoomIn(); // reach the "zoomed in" state (zero-distance tween — Eye already there).
|
||||
Vector3 targetEye = ChargenPreviewCamera.ResolveZoomedOutEye((uint)ChargenHeritageGroup.Aluvian);
|
||||
controller.ZoomOut(animator: null); // NOW arms a real tween: default eye -> zoomed-out eye.
|
||||
controller.ZoomOut(); // NOW arms a real tween: default eye -> zoomed-out eye.
|
||||
|
||||
controller.Tick(100.0); // seeds the tween's own start time (first tick of a fresh -0.1 sentinel).
|
||||
controller.Tick(100.0 + ChargenPreviewCamera.ZoomTweenDurationSeconds / 2.0);
|
||||
|
|
@ -120,10 +148,10 @@ public sealed class ChargenPreviewZoomControllerTests
|
|||
public void Tick_PastTheFullDuration_ClampsExactlyToTheTargetEye_AndStopsAnimating()
|
||||
{
|
||||
var camera = new ChargenPreviewCamera((uint)ChargenHeritageGroup.Aluvian);
|
||||
var controller = new ChargenPreviewZoomController((uint)ChargenHeritageGroup.Aluvian, camera);
|
||||
controller.ZoomIn(animator: null); // reach "zoomed in" (zero-distance).
|
||||
var controller = new ChargenPreviewZoomController((uint)ChargenHeritageGroup.Aluvian, camera, MakeAnimator());
|
||||
controller.ZoomIn(); // reach "zoomed in" (zero-distance).
|
||||
Vector3 targetEye = ChargenPreviewCamera.ResolveZoomedOutEye((uint)ChargenHeritageGroup.Aluvian);
|
||||
controller.ZoomOut(animator: null); // arms the real tween toward targetEye.
|
||||
controller.ZoomOut(); // arms the real tween toward targetEye.
|
||||
|
||||
controller.Tick(0.0);
|
||||
controller.Tick(100.0); // way past the 0.6s duration.
|
||||
|
|
@ -139,10 +167,10 @@ public sealed class ChargenPreviewZoomControllerTests
|
|||
public void ZoomIn_ImmediatelyFreezesTheAnimatorToTheRestPose_BeforeTheTweenCompletes()
|
||||
{
|
||||
var camera = new ChargenPreviewCamera((uint)ChargenHeritageGroup.Aluvian);
|
||||
var controller = new ChargenPreviewZoomController((uint)ChargenHeritageGroup.Aluvian, camera);
|
||||
var animator = MakeAnimator();
|
||||
var controller = new ChargenPreviewZoomController((uint)ChargenHeritageGroup.Aluvian, camera, animator);
|
||||
|
||||
controller.ZoomIn(animator);
|
||||
controller.ZoomIn();
|
||||
|
||||
// No Tick() call at all — retail's ZoomIn calls StopAnimation
|
||||
// synchronously, before the camera tween has advanced a single frame.
|
||||
|
|
@ -154,11 +182,11 @@ public sealed class ChargenPreviewZoomControllerTests
|
|||
public void ZoomOut_ImmediatelyResumesTheAnimatorsIdleLoop()
|
||||
{
|
||||
var camera = new ChargenPreviewCamera((uint)ChargenHeritageGroup.Aluvian);
|
||||
var controller = new ChargenPreviewZoomController((uint)ChargenHeritageGroup.Aluvian, camera);
|
||||
var animator = MakeAnimator();
|
||||
controller.ZoomIn(animator);
|
||||
var controller = new ChargenPreviewZoomController((uint)ChargenHeritageGroup.Aluvian, camera, animator);
|
||||
controller.ZoomIn();
|
||||
|
||||
controller.ZoomOut(animator);
|
||||
controller.ZoomOut();
|
||||
|
||||
Assert.False(animator.IsZoomedIn);
|
||||
Assert.Equal(new Vector3(1f, 0f, 0f), animator.Entity.MeshRefs[0].PartTransform.Translation);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue