Delivers the CC6a foundation half of the chargen 3D preview: the missing index->ObjDesc appearance factory the campaign plan's acdream-seams section named, plus a static-pose offscreen renderer following PrivateEntityViewportRenderer's proven paperdoll/appraisal architecture. Page mount, spin/color-wheel controls, and rotate/zoom behavior stay out of scope per the CC4-parallel worktree contract (CC6b, after CC4 merges). Core (src/AcDream.Core/CharGen/, pure, no Chorizite on public surfaces): ChargenAppearanceFactory.TryCompose ports gmCG3DView::Update @0x004EE9D0's ObjDesc rebuild in its exact decompiled order - base body, hair style, clothing in retail's own Headgear/Trousers/Shirt/Footwear order (not the UI tab order or the wire's field order, both of which differ), eyes (bald-aware), nose, mouth, then the unconditional skin subpalette, hair color, eye color. ChargenPalSetMath ports PalSet::GetPaletteID's shade-to-index formula, cross-checked three ways (decomp control flow, ACE's PaletteSet.GetPaletteID "Taken from acclient.c" citation, ACViewer's identical slider math). ChargenPalSet/ChargenClothingTable are pure projections behind IChargenPalSetSource/IChargenClothingTableSource so the factory itself never touches a dat. Content (src/AcDream.Content/CharGen/): ChargenAppearanceCatalog is the cached dat-backed implementation of those two source interfaces, mirroring ChargenTableReader's no-leak discipline. App (src/AcDream.App/Rendering/): ChargenPreviewRenderer is a third facade over PrivateEntityViewportRenderer beside PaperdollViewportRenderer and CreatureAppraisalViewportRenderer - no existing rendering file touched. ChargenPreviewCamera carries the four retail-verbatim per-heritage eye profiles from gmCGAppearancePage::Update @0x0047E8F0 (cross-checked against ZoomIn/ZoomOut's identical literals) plus the recovered rotation (3.0 s/revolution) and zoom-tween (0.6 s, reconstructed from the decompiler's garbled float literals - the plan's own "measure if it matters" note is resolved, not garbled beyond recovery). Rotation applies to the character model, not the camera, per gmCGAppearancePage::DoRotation. ChargenPreviewEntityBuilder resolves Setup/GfxObj/Surface/Animation itself (there is no live entity yet), reusing DatLiveEntityProjectionMaterializer's surface-override algorithm and RetailPaperdollPoseApplicator's held-pose technique, generalized to chargen's per-heritage rest-pose DID. Two register rows filed: TS-83 (the plan-named CC6a static-pose-vs-retail- idle-loop staging, CC6b to retire) and TS-82 (measured, not assumed - the un-ported clothing Setup-substitution fallback chain costs nothing for the 9 standard heritages with clothing UI, but Undead's default gear choices genuinely lack ClothingBaseEffects coverage for Undead's own body Setup). Tests: ChargenPalSetMathTests, ChargenAppearanceFactoryTests (hand-built fixtures), ChargenAppearanceCatalogInstalledDatTests (installed-DAT sweep, all 26 heritage/gender combinations, zero missing PalSet/ClothingTable ids), ChargenPreviewCameraTests, ChargenPreviewEntityBuilderTests (installed-DAT-gated, proves a real 34-part Aluvian mesh resolves). Core.Tests 4767/1 skip, Content.Tests 146/0, App.Tests 5121/6 skips - all pre-existing skips, zero failures, full solution Release build green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
63 lines
2.2 KiB
C#
63 lines
2.2 KiB
C#
using AcDream.Core.CharGen;
|
|
|
|
namespace AcDream.Core.Tests.CharGen;
|
|
|
|
/// <summary>
|
|
/// Pins <see cref="ChargenPalSetMath.GetPaletteIndex"/> against the exact
|
|
/// formula ACE's <c>PaletteSet.GetPaletteID</c> cites as "Taken from
|
|
/// acclient.c (PalSet::GetPaletteID)": <c>(int)((count - 0.000001) * shade)</c>,
|
|
/// clamped to <c>[0, count-1]</c>, with an out-of-<c>[0,1]</c> shade (or a
|
|
/// non-positive count) returning -1.
|
|
/// </summary>
|
|
public class ChargenPalSetMathTests
|
|
{
|
|
[Theory]
|
|
[InlineData(5, 0.0, 0)]
|
|
[InlineData(5, 1.0, 4)]
|
|
[InlineData(5, 0.5, 2)]
|
|
[InlineData(1, 0.0, 0)]
|
|
[InlineData(1, 1.0, 0)]
|
|
public void GetPaletteIndex_matches_the_cited_acclient_formula(int count, double shade, int expected)
|
|
{
|
|
Assert.Equal(expected, ChargenPalSetMath.GetPaletteIndex(count, shade));
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(0, 0.5)]
|
|
[InlineData(-1, 0.5)]
|
|
public void GetPaletteIndex_returns_negative_one_for_non_positive_count(int count, double shade)
|
|
{
|
|
Assert.Equal(-1, ChargenPalSetMath.GetPaletteIndex(count, shade));
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(5, -0.0001)]
|
|
[InlineData(5, 1.0001)]
|
|
[InlineData(5, ChargenAppearanceSelection.UnsetShade)] // retail's own "unset" sentinel is out of [0,1].
|
|
public void GetPaletteIndex_returns_negative_one_for_out_of_range_shade(int count, double shade)
|
|
{
|
|
Assert.Equal(-1, ChargenPalSetMath.GetPaletteIndex(count, shade));
|
|
}
|
|
|
|
[Fact]
|
|
public void GetPaletteIndex_never_exceeds_count_minus_one_near_the_upper_bound()
|
|
{
|
|
// shade == 1.0 exactly must land on the LAST index, not overflow past it —
|
|
// the (count - 0.000001) fudge factor exists precisely to guarantee this.
|
|
for (int count = 1; count <= 64; count++)
|
|
Assert.Equal(count - 1, ChargenPalSetMath.GetPaletteIndex(count, 1.0));
|
|
}
|
|
|
|
[Fact]
|
|
public void GetPaletteIndex_is_monotonic_non_decreasing_in_shade()
|
|
{
|
|
const int count = 13;
|
|
int previous = -1;
|
|
for (double shade = 0.0; shade <= 1.0; shade += 0.01)
|
|
{
|
|
int index = ChargenPalSetMath.GetPaletteIndex(count, shade);
|
|
Assert.True(index >= previous, $"index regressed at shade={shade}");
|
|
previous = index;
|
|
}
|
|
}
|
|
}
|