fix #426: extract solid-colour (NO_POS_UVS) faces; skip untextured subsets only on building shells and cells like retail

The Holtburg windmill axle (GfxObj 0x010010CE, 8 polygons, all
Stippling.NoPos + SurfaceType.Base1Solid) extracted to a 0-vertex mesh.
NoPos ("NO_POS_UVS", acclient.h:7380-7388) means "this side has no
texture coordinates" — true of every solid-colour polygon, since
nothing samples them — not "there is no positive face". Extraction read
it as the latter and dropped the polygon entirely, client-wide, for
every untextured polygon on every object.

Retail's D3DPolyRender::DrawMesh (@0x0059d4a0, named-retail decomp
~line 426048) draws an untextured subset on an ordinary object exactly
like a textured one; the only retail cases that skip an untextured
subset are a building shell (RenderDeviceD3D::DrawBuilding @0x0059f2a0
sets ObjBuildingOrBuildingPart=1) or an EnvCell interior
(RenderDeviceD3D::DrawEnvCell @0x0059f170, arg4=1). The #119
investigation's "retail's skipNoTexture never draws them either"
conclusion was itself wrong as a general rule.

- MeshExtractor.PrepareGfxObjMeshData / GfxObjMesh.Build: emit the
  positive side whenever PosSurface is a valid index, regardless of
  NoPos; the existing UV-index-0 fallback already produces zero
  texcoords for a NoPos polygon with no UVs on the wire.
- RetailUntexturedSurfacePolicy.IsUntextured(SurfaceType): the one
  place that answers "is this surface textured"
  ((type & (Base1Image|Base1ClipMap)) == 0), replacing the old
  `isSolid = NoPos || Base1Solid` (which also mis-classified a NEG-side
  batch by the POS-side's NoPos flag).
- RetailUntexturedSubsetPolicy.Draws(isBuildingShell, isUntextured):
  the shared draw-time gate wired into WbDrawDispatcher.ClassifyBatches,
  .PackedOracle.ClassifyPackedBatches, and
  .DirectionalShadows.AddDirectionalShadowBatches — one predicate so the
  three walks cannot drift (Campaign VM VM6 lesson).
- CellMesh.cs / MeshExtractor.PrepareCellStructMeshData deliberately
  KEEP their NoPos-gated skip for cell-wall geometry — retail's
  DrawEnvCell really does skip untextured subsets there; register row
  AP-234 documents the NoPos-vs-Surface.Type approximation.
- PakFormat.CurrentBakeToolVersion 4->5 (LauncherInstallRecordStore in
  lockstep): a pak baked by an older tool is missing every untextured
  face. No bake was run as part of this commit.

Also fixed: WorldBuilder's own upstream ObjectMeshManager.cs has the
identical NoPos bug (ObjectMeshManager.cs:959,984) — our port had
faithfully carried it over, and our own conformance test
(Build_NoPosFlag_OnlyEmitsNegSide) asserted the bug as correct WB
conformance. Renamed/reworded to Build_NoPosFlag_EmitsBothPosAndNegSide
with a citation for why retail decomp overrides WB here.

Issue119UpNullGfxObjDumpTests re-run against the installed DAT:
#119's own two objects (0x010002B4 9/9 polys, 0x010008A8 1/1 poly) now
gate DRAWS on every polygon instead of extracting to nothing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-23 11:20:24 +02:00
parent 51a5fe99ef
commit 517d17b4b3
18 changed files with 755 additions and 40 deletions

View file

@ -0,0 +1,294 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Numerics;
using AcDream.Content;
using DatReaderWriter;
using DatReaderWriter.DBObjs;
using DatReaderWriter.Enums;
using DatReaderWriter.Lib.IO;
using DatReaderWriter.Types;
using Microsoft.Extensions.Logging.Abstractions;
namespace AcDream.Content.Tests;
/// <summary>
/// #426 (2026-08-23, the Holtburg windmill axle 0x010010CE, 8 polygons all
/// NoPos + Base1Solid): MeshExtractor.PrepareGfxObjMeshData used to gate the
/// positive side on <c>!Stippling.NoPos</c>, dropping every solid-colour
/// polygon on every object client-wide (NoPos means "no positive UVs" —
/// acclient.h:7386 — not "no positive face"). These tests exercise the fix
/// through the PUBLIC PrepareMeshData entry point against a synthetic,
/// entirely in-memory dat graph (no installed DAT directory required — this
/// lane stays hermetic), using a hand-rolled <see cref="IDatReaderWriter"/> /
/// <see cref="IDatDatabase"/> pair in the same shape as
/// DatResolutionPrecedenceTests' ResolutionSource/StubDatabase.
/// </summary>
public sealed class MeshExtractorSolidFaceExtractionTests
{
private const uint GfxObjId = 0x01000001u;
private const uint SolidSurfaceId = 0x08000001u;
private const uint TexturedSurfaceId = 0x08000002u;
private const uint SurfaceTextureId = 0x05000001u;
private const uint RenderSurfaceId = 0x06000001u;
/// <summary>
/// One quad polygon, NoPos + Base1Solid: the exact shape of the windmill
/// axle's own polygons. Must now extract to 4 vertices / 6 indices in a
/// single batch flagged solid, instead of the pre-#426 0-vertex mesh.
/// </summary>
[Fact]
public void PrepareMeshData_NoPosSolidQuad_EmitsSolidBatchWithFourVerticesAndSixIndices()
{
var dats = new FakeMeshExtractorDats();
dats.RegisterRootGfxObj(GfxObjId, BuildQuadGfxObj(SolidSurfaceId, noPos: true));
var color = new ColorARGB { Alpha = 255, Red = 12, Green = 34, Blue = 56 };
dats.Register(SolidSurfaceId, new Surface
{
Type = SurfaceType.Base1Solid,
ColorValue = color,
});
var extractor = new MeshExtractor(dats, NullLogger.Instance, sideStagedSink: null);
ObjectMeshData? mesh = extractor.PrepareMeshData(GfxObjId, isSetup: false);
Assert.NotNull(mesh);
Assert.Equal(4, mesh!.Vertices.Length);
List<TextureBatchData> batches = mesh.TextureBatches.Values.Single();
TextureBatchData batch = Assert.Single(batches);
Assert.Equal(6, batch.Indices.Count);
Assert.True(batch.Key.IsSolid);
// GetOrCreateSolidColorTexture bakes the surface's own ColorValue.
Assert.Equal((byte)color.Red, batch.TextureData[0]);
Assert.Equal((byte)color.Green, batch.TextureData[1]);
Assert.Equal((byte)color.Blue, batch.TextureData[2]);
Assert.Equal((byte)color.Alpha, batch.TextureData[3]);
}
/// <summary>
/// Same NoPos quad, but the positive surface is TEXTURED
/// (Base1Image) rather than solid. NoPos still means "no UVs on this
/// polygon's wire data" regardless of what the surface is — the emitted
/// vertices fall back to UV (0,0), and the batch must be classified
/// non-solid (IsSolid == false) so it decodes the real texture instead
/// of baking a flat colour fill.
/// </summary>
[Fact]
public void PrepareMeshData_NoPosTexturedQuad_EmitsWithZeroUVsAndIsSolidFalse()
{
var dats = new FakeMeshExtractorDats();
dats.RegisterRootGfxObj(GfxObjId, BuildQuadGfxObj(TexturedSurfaceId, noPos: true));
dats.Register(TexturedSurfaceId, new Surface
{
Type = SurfaceType.Base1Image,
OrigTextureId = SurfaceTextureId,
});
dats.Register(SurfaceTextureId, new SurfaceTexture
{
Textures = new List<QualifiedDataId<RenderSurface>> { RenderSurfaceId },
});
dats.Register(RenderSurfaceId, new RenderSurface
{
Width = 1,
Height = 1,
Format = PixelFormat.PFID_A8R8G8B8,
SourceData = new byte[] { 10, 20, 30, 255 },
});
var extractor = new MeshExtractor(dats, NullLogger.Instance, sideStagedSink: null);
ObjectMeshData? mesh = extractor.PrepareMeshData(GfxObjId, isSetup: false);
Assert.NotNull(mesh);
Assert.Equal(4, mesh!.Vertices.Length);
Assert.All(mesh.Vertices, v => Assert.Equal(Vector2.Zero, v.UV));
List<TextureBatchData> batches = mesh.TextureBatches.Values.Single();
TextureBatchData batch = Assert.Single(batches);
Assert.Equal(6, batch.Indices.Count);
Assert.False(batch.Key.IsSolid);
}
/// <summary>One quad (4 verts), single polygon, PosSurface referencing <paramref name="surfaceId"/>.</summary>
private static GfxObj BuildQuadGfxObj(uint surfaceId, bool noPos)
{
return new GfxObj
{
Surfaces = { surfaceId },
VertexArray = new VertexArray
{
Vertices =
{
// No UVs at all — matches a real NoPos polygon's vertices,
// which carry no UV entries because nothing samples them.
[0] = new SWVertex { Origin = new Vector3(0, 0, 0), Normal = Vector3.UnitZ },
[1] = new SWVertex { Origin = new Vector3(1, 0, 0), Normal = Vector3.UnitZ },
[2] = new SWVertex { Origin = new Vector3(1, 1, 0), Normal = Vector3.UnitZ },
[3] = new SWVertex { Origin = new Vector3(0, 1, 0), Normal = Vector3.UnitZ },
},
},
Polygons =
{
[0] = new Polygon
{
Stippling = noPos ? StipplingType.NoPos : default,
PosSurface = 0,
NegSurface = -1,
VertexIds = { 0, 1, 2, 3 },
},
},
};
}
/// <summary>
/// Minimal in-memory <see cref="IDatReaderWriter"/> for MeshExtractor:
/// resolves exactly one "root" GfxObj through Portal (the only path
/// PrepareMeshData needs for TryResolvePreferred's default
/// implementation), plus arbitrary typed lookups (Surface,
/// SurfaceTexture, RenderSurface) also through Portal.
/// </summary>
private sealed class FakeMeshExtractorDats : IDatReaderWriter
{
private readonly Dictionary<uint, IDBObj> _portalObjects = new();
private uint _rootId;
public FakeMeshExtractorDats() => Portal = new FakeDatDatabase(_portalObjects);
public void RegisterRootGfxObj(uint id, GfxObj gfxObj)
{
_rootId = id;
_portalObjects[id] = gfxObj;
}
public void Register<T>(uint id, T obj) where T : IDBObj => _portalObjects[id] = obj;
public string SourceDirectory => string.Empty;
public IDatDatabase Portal { get; }
public IDatDatabase Cell => EmptyDatDatabase.Instance;
public ReadOnlyDictionary<uint, IDatDatabase> CellRegions { get; } =
new(new Dictionary<uint, IDatDatabase>());
public IDatDatabase HighRes => EmptyDatDatabase.Instance;
public IDatDatabase Language => EmptyDatDatabase.Instance;
public IDatDatabase Local => EmptyDatDatabase.Instance;
public ReadOnlyDictionary<uint, uint> RegionFileMap { get; } =
new(new Dictionary<uint, uint>());
public int PortalIteration => 0;
public int CellIteration => 0;
public int HighResIteration => 0;
public int LanguageIteration => 0;
public bool TryGetFileBytes(uint regionId, uint fileId, ref byte[] bytes, out int bytesRead)
{
bytesRead = 0;
return false;
}
public IEnumerable<uint> GetAllIdsOfType<T>() where T : IDBObj => Array.Empty<uint>();
public IEnumerable<IDatReaderWriter.IdResolution> ResolveId(uint id) =>
id == _rootId
? new[] { new IDatReaderWriter.IdResolution(Portal, DBObjType.GfxObj) }
: Array.Empty<IDatReaderWriter.IdResolution>();
public bool TrySave<T>(T obj, int iteration = 0) where T : IDBObj =>
throw new NotSupportedException();
public bool TrySave<T>(uint regionId, T obj, int iteration = 0) where T : IDBObj =>
throw new NotSupportedException();
[return: MaybeNull]
public T Get<T>(uint fileId) where T : IDBObj =>
Portal.TryGet<T>(fileId, out var value) ? value : default;
public bool TryGet<T>(uint fileId, [MaybeNullWhen(false)] out T value) where T : IDBObj =>
Portal.TryGet(fileId, out value);
public void Dispose()
{
}
}
private sealed class FakeDatDatabase : IDatDatabase
{
private readonly Dictionary<uint, IDBObj> _objects;
public FakeDatDatabase(Dictionary<uint, IDBObj> objects) => _objects = objects;
// Never dereferenced by MeshExtractor's own code paths (only
// RetailPhysicsScriptLoader's ctor reads it, into a NULLABLE field
// it never touches unless a physics-script emitter is loaded, which
// these tests never trigger).
public DatDatabase Db => null!;
public int Iteration => 0;
public IEnumerable<uint> GetAllIdsOfType<T>() where T : IDBObj => Array.Empty<uint>();
public bool TryGet<T>(uint fileId, [MaybeNullWhen(false)] out T value) where T : IDBObj
{
if (_objects.TryGetValue(fileId, out IDBObj? obj) && obj is T typed)
{
value = typed;
return true;
}
value = default;
return false;
}
public bool TryGetFileBytes(uint fileId, [MaybeNullWhen(false)] out byte[] value)
{
value = null;
return false;
}
public bool TryGetFileBytes(uint fileId, ref byte[] bytes, out int bytesRead)
{
bytesRead = 0;
return false;
}
public bool TrySave<T>(T obj, int iteration = 0) where T : IDBObj =>
throw new NotSupportedException();
public void Dispose()
{
}
}
private sealed class EmptyDatDatabase : IDatDatabase
{
public static readonly EmptyDatDatabase Instance = new();
public DatDatabase Db => null!;
public int Iteration => 0;
public IEnumerable<uint> GetAllIdsOfType<T>() where T : IDBObj => Array.Empty<uint>();
public bool TryGet<T>(uint fileId, [MaybeNullWhen(false)] out T value) where T : IDBObj
{
value = default;
return false;
}
public bool TryGetFileBytes(uint fileId, [MaybeNullWhen(false)] out byte[] value)
{
value = null;
return false;
}
public bool TryGetFileBytes(uint fileId, ref byte[] bytes, out int bytesRead)
{
bytesRead = 0;
return false;
}
public bool TrySave<T>(T obj, int iteration = 0) where T : IDBObj =>
throw new NotSupportedException();
public void Dispose()
{
}
}
}

View file

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using AcDream.Core.Meshing;
using DatReaderWriter;
using DatReaderWriter.DBObjs;
using DatReaderWriter.Enums;
@ -22,6 +23,22 @@ namespace AcDream.Core.Tests.Conformance;
/// and replicates MeshExtractor.PrepareGfxObjMeshData's gates (moved from
/// ObjectMeshManager in MP1a)
/// so the zeroing gate reads directly off the output.
///
/// #426 (2026-08-23) UPDATE: the gate replica below now mirrors the FIXED
/// extraction rule — the positive side is added whenever PosSurface is a
/// valid index, regardless of Stippling.NoPos (NoPos means "no positive
/// UVs", not "no positive face"; see RetailUntexturedSurfacePolicy). Run
/// against the installed DAT, both of #119's original objects now gate
/// DRAWS on every single polygon (0x010002B4: 9/9 polys; 0x010008A8: 1/1
/// poly — both all-NoPos+Base1Solid, wouldAddPos == polygon count) — they
/// are NEITHER all-degenerate NOR all-invalid-surface-index; they were
/// dropped for being all-solid, and #426 now extracts that geometry. The
/// #119 filing's "retail never draws untextured subsets" conclusion was
/// simply wrong (see #426's ISSUES.md entry) — it never held for these two
/// objects specifically. Whether their solid faces end up VISIBLE on
/// screen (vs. skipped again at draw time by RetailUntexturedSubsetPolicy,
/// if either object turns out to be a building-shell part) is a separate,
/// unverified question this dump does not answer.
/// </summary>
[Trait("Lane", "InstalledDat")]
public sealed class Issue119UpNullGfxObjDumpTests
@ -57,7 +74,10 @@ public sealed class Issue119UpNullGfxObjDumpTests
}
// Replicate the extraction gates (PrepareGfxObjMeshData):
// pos added when !NoPos
// pos added whenever PosSurface is a valid index — #426
// (2026-08-23): NoPos means "no positive UVs", not "no positive
// face"; ordinary objects draw untextured (solid) subsets the same
// as textured ones (RetailUntexturedSurfacePolicy).
// neg added when Negative || Both || (!NoNeg && SidesType==Clockwise)
// surface index must be in [0, Surfaces.Count)
int wouldAddPos = 0, wouldAddNeg = 0, degenerate = 0;
@ -68,8 +88,7 @@ public sealed class Issue119UpNullGfxObjDumpTests
if (poly.VertexIds.Count < 3) { degenerate++; gate = "degenerate(<3 verts)"; }
else
{
bool pos = !poly.Stippling.HasFlag(StipplingType.NoPos)
&& poly.PosSurface >= 0 && poly.PosSurface < gfx.Surfaces.Count;
bool pos = poly.PosSurface >= 0 && poly.PosSurface < gfx.Surfaces.Count;
bool neg = (poly.Stippling.HasFlag(StipplingType.Negative)
|| poly.Stippling.HasFlag(StipplingType.Both)
|| (!poly.Stippling.HasFlag(StipplingType.NoNeg) && poly.SidesType == CullMode.Clockwise))
@ -96,6 +115,18 @@ public sealed class Issue119UpNullGfxObjDumpTests
/// are "regular shell polys" — render digest user axiom). A non-zero
/// "DROPPED but textured" count names the extraction as the stairs-miss
/// mechanism; zero exonerates the per-poly gates.
///
/// #426 (2026-08-23) UPDATE: post-fix, the POS side can only be dropped
/// when PosSurface itself is out of range — a textured pos-side surface
/// with a valid index is now ALWAYS emitted (that's the whole point of
/// #426). So this test's remaining bite is almost entirely the NEG-side
/// gate (unchanged by #426 — a textured NEG surface can still legitimately
/// be dropped when none of the three double-sided conditions hold). Kept
/// under its original name/assertion (zero textured drops) because that
/// invariant is still exactly what we want to hold; `SurfaceIsTextured`
/// now calls the shared RetailUntexturedSurfacePolicy predicate instead of
/// a bare Base1Solid check, so this test and the extraction it's checking
/// literally cannot drift on what "textured" means.
/// </summary>
[Theory]
[InlineData(0x010014C3u)]
@ -112,7 +143,7 @@ public sealed class Issue119UpNullGfxObjDumpTests
{
if (idx < 0 || idx >= gfx!.Surfaces.Count) return false;
if (!dats.Portal.TryGet<Surface>(gfx.Surfaces[idx], out var surf) || surf is null) return false;
return !surf.Type.HasFlag(SurfaceType.Base1Solid);
return !RetailUntexturedSurfacePolicy.IsUntextured(surf.Type);
}
int draws = 0;
@ -120,8 +151,7 @@ public sealed class Issue119UpNullGfxObjDumpTests
foreach (var (pid, poly) in gfx!.Polygons.OrderBy(kv => kv.Key))
{
if (poly.VertexIds.Count < 3) continue;
bool pos = !poly.Stippling.HasFlag(StipplingType.NoPos)
&& poly.PosSurface >= 0 && poly.PosSurface < gfx.Surfaces.Count;
bool pos = poly.PosSurface >= 0 && poly.PosSurface < gfx.Surfaces.Count;
bool neg = (poly.Stippling.HasFlag(StipplingType.Negative)
|| poly.Stippling.HasFlag(StipplingType.Both)
|| (!poly.Stippling.HasFlag(StipplingType.NoNeg) && poly.SidesType == CullMode.Clockwise))

View file

@ -247,4 +247,56 @@ public class GfxObjMeshTests
Assert.Empty(subs); // no valid polygons → no sub-meshes
}
/// <summary>
/// #426 (2026-08-23, Holtburg windmill axle 0x010010CE): a NoPos-flagged
/// polygon ("this side has no texture coordinates", acclient.h:7386) is
/// NOT "no positive face" — every solid-colour polygon carries NoPos.
/// Before the fix, <c>hasPos = !Stippling.NoPos</c> dropped this quad
/// entirely, producing zero vertices. GfxObjMesh.Build doesn't branch on
/// Surface.Type at all (that classification — "is this untextured" —
/// lives in RetailUntexturedSurfacePolicy and is consumed by
/// MeshExtractor, which is what actually decides solid-vs-textured
/// rendering), so a NoPos polygon over a "solid" surface and a NoPos
/// polygon over a "textured" surface are IDENTICAL from this method's
/// point of view — both are proven by this one case.
/// </summary>
[Fact]
public void Build_NoPosQuad_StillEmitsPositiveSideVerticesAndIndices()
{
var gfx = new GfxObj
{
Surfaces = { 0x08000000u },
VertexArray = new VertexArray
{
Vertices =
{
// No UVs at all — matches a real solid-colour polygon's
// vertices, which carry no UV entries because nothing
// ever samples them.
[0] = new SWVertex { Origin = new(0, 0, 0) },
[1] = new SWVertex { Origin = new(1, 0, 0) },
[2] = new SWVertex { Origin = new(1, 1, 0) },
[3] = new SWVertex { Origin = new(0, 1, 0) },
},
},
Polygons =
{
[0] = new Polygon
{
Stippling = StipplingType.NoPos,
PosSurface = 0,
NegSurface = -1,
VertexIds = { 0, 1, 2, 3 },
// No PosUVIndices — NoPos means there ARE none on the wire.
},
},
};
var sub = GfxObjMesh.Build(gfx).Single();
Assert.Equal(4, sub.Vertices.Length);
Assert.Equal(6, sub.Indices.Length); // fan-triangulated quad, 2 triangles
Assert.All(sub.Vertices, v => Assert.Equal(Vector2.Zero, v.TexCoord));
}
}

View file

@ -0,0 +1,42 @@
using AcDream.Core.Meshing;
using DatReaderWriter.Enums;
namespace AcDream.Core.Tests.Meshing;
/// <summary>
/// #426 (2026-08-23, the Holtburg windmill axle 0x010010CE): pins the two
/// predicates that replaced the buggy <c>isSolid = NoPos || Base1Solid</c>
/// extraction rule and the "retail never draws untextured subsets" #119
/// misconception. See RetailUntexturedSurfacePolicy.cs for the full retail
/// citations (D3DPolyRender::DrawMesh / DrawBuilding / DrawEnvCell).
/// </summary>
public sealed class RetailUntexturedSurfacePolicyTests
{
[Theory]
[InlineData(SurfaceType.Base1Solid, true)] // solid-colour — untextured
[InlineData((SurfaceType)0, true)] // neither bit set — untextured
[InlineData(SurfaceType.Base1Image, false)] // BASE1_IMAGE (0x2) — textured
[InlineData(SurfaceType.Base1ClipMap, false)] // BASE1_CLIPMAP (0x4) — textured
[InlineData(SurfaceType.Base1Image | SurfaceType.Base1Solid, false)] // both bits — retail's literal (type & 6) != 0 still calls this textured
[InlineData(SurfaceType.Base1Image | SurfaceType.Additive, false)] // unrelated flags alongside a textured bit stay textured
public void IsUntextured_MatchesRetailBitmask(SurfaceType type, bool expected)
{
Assert.Equal(expected, RetailUntexturedSurfacePolicy.IsUntextured(type));
}
[Theory]
// (isBuildingShell, isUntextured) -> draws
[InlineData(false, true, true)] // ordinary object, solid subset — retail draws it (#426's own bug)
[InlineData(true, true, false)] // building shell, solid subset — retail's DrawBuilding skips it
[InlineData(false, false, true)] // ordinary object, textured subset — always drawn
[InlineData(true, false, true)] // building shell, textured subset — the shell gate only touches untextured subsets
public void Draws_MatchesRetailBuildingShellGate(
bool isBuildingShell,
bool isUntextured,
bool expectedDraws)
{
Assert.Equal(
expectedDraws,
RetailUntexturedSubsetPolicy.Draws(isBuildingShell, isUntextured));
}
}

View file

@ -18,6 +18,23 @@ namespace AcDream.Core.Tests.Rendering.Wb;
/// If this test fails, either our port has drifted or the WB code has
/// changed upstream — investigate which, do not "fix" the test.
/// </para>
///
/// <para>
/// ONE DOCUMENTED EXCEPTION (#426, 2026-08-23):
/// <see cref="Build_NoPosFlag_EmitsBothPosAndNegSide"/> below intentionally
/// diverges from WorldBuilder's own upstream
/// <c>ObjectMeshManager.cs:959</c> (<c>if
/// (!poly.Stippling.HasFlag(StipplingType.NoPos))</c>), which has the exact
/// same bug our port faithfully carried over: gating the polygon's positive
/// side on <c>!NoPos</c>, silently dropping every solid-colour polygon.
/// Named-retail decomp (<c>D3DPolyRender::DrawMesh</c> @0x0059d4a0) proves
/// <c>NoPos</c> ("this side has no texture coordinates",
/// acclient.h:7380-7388) does not gate whether retail draws the positive
/// side at all — see #426 in docs/ISSUES.md for the full citation. This is
/// the one case in this file where the retail decomp — not WB — is the
/// oracle; see the acdream-wide rule in CLAUDE.md ("the decompiled code is
/// ground truth ... if they disagree, the decompiled code wins").
/// </para>
/// </summary>
public sealed class MeshExtractionConformanceTests
{
@ -66,8 +83,18 @@ public sealed class MeshExtractionConformanceTests
Assert.Equal(2, ours.Count);
}
/// <summary>
/// #426 (2026-08-23): renamed from <c>Build_NoPosFlag_OnlyEmitsNegSide</c>,
/// which asserted <c>Assert.Single(ours)</c> — the OLD bug's own
/// behavior (NoPos silently dropped the positive side). NoPos means "no
/// positive UVs" (acclient.h:7386), not "no positive face"; retail draws
/// an ordinary object's untextured positive side same as a textured one
/// (D3DPolyRender::DrawMesh @0x0059d4a0). See the class doc's "ONE
/// DOCUMENTED EXCEPTION" note for why this test intentionally diverges
/// from WorldBuilder's own (equally buggy) upstream algorithm.
/// </summary>
[Fact]
public void Build_NoPosFlag_OnlyEmitsNegSide()
public void Build_NoPosFlag_EmitsBothPosAndNegSide()
{
var gfxObj = MakeUnitQuadGfxObj();
var poly = gfxObj.Polygons[0];
@ -77,7 +104,7 @@ public sealed class MeshExtractionConformanceTests
var ours = GfxObjMesh.Build(gfxObj, dats: null);
Assert.Single(ours);
Assert.Equal(2, ours.Count);
}
/// <summary>

View file

@ -51,12 +51,12 @@ public sealed class LauncherInstallerTests : IDisposable
await File.WriteAllTextAsync(request.OutputPath, "complete prepared package");
long bytes = new FileInfo(request.OutputPath).Length;
output("acdream-bake human header\n{\"v\":1,\"e\":\"star");
output("ted\",\"bakeToolVersion\":4,\"outputPath\":\"pak\"}\n");
output($"ted\",\"bakeToolVersion\":{LauncherInstallRecordStore.CurrentBakeToolVersion},\"outputPath\":\"pak\"}}\n");
output("{\"v\":1,\"e\":\"progress\",\"phase\":\"mesh\","
+ "\"completed\":25,\"total\":100,\"failures\":0,"
+ "\"elapsedSeconds\":5,\"etaSeconds\":15}\n");
output("{\"v\":1,\"e\":\"newMetric\",\"value\":1}\n");
output($"{{\"v\":1,\"e\":\"completed\",\"bakeToolVersion\":4,"
output($"{{\"v\":1,\"e\":\"completed\",\"bakeToolVersion\":{LauncherInstallRecordStore.CurrentBakeToolVersion},"
+ $"\"outputBytes\":{bytes},\"failures\":0}}\n");
return new BakeProcessResult(0, string.Empty);
});
@ -153,7 +153,7 @@ public sealed class LauncherInstallerTests : IDisposable
async (request, output, _) =>
{
await File.WriteAllTextAsync(request.OutputPath, "partial replacement");
output("{\"v\":1,\"e\":\"started\",\"bakeToolVersion\":4}\n");
output($"{{\"v\":1,\"e\":\"started\",\"bakeToolVersion\":{LauncherInstallRecordStore.CurrentBakeToolVersion}}}\n");
output("{\"v\":1,\"e\":\"error\",\"message\":\"fixture failed\"}\n");
return new BakeProcessResult(9, "human failure detail");
},
@ -186,9 +186,9 @@ public sealed class LauncherInstallerTests : IDisposable
{
await File.WriteAllTextAsync(request.OutputPath, "contradictory output");
long bytes = new FileInfo(request.OutputPath).Length;
output("{\"v\":1,\"e\":\"started\",\"bakeToolVersion\":4}\n");
output($"{{\"v\":1,\"e\":\"started\",\"bakeToolVersion\":{LauncherInstallRecordStore.CurrentBakeToolVersion}}}\n");
output("{\"v\":1,\"e\":\"error\",\"message\":\"first failure\"}\n");
output($"{{\"v\":1,\"e\":\"completed\",\"bakeToolVersion\":4,"
output($"{{\"v\":1,\"e\":\"completed\",\"bakeToolVersion\":{LauncherInstallRecordStore.CurrentBakeToolVersion},"
+ $"\"outputBytes\":{bytes},\"failures\":0}}\n");
return new BakeProcessResult(0, string.Empty);
});
@ -275,8 +275,8 @@ public sealed class LauncherInstallerTests : IDisposable
Directory.CreateDirectory(Path.GetDirectoryName(request.OutputPath)!);
await File.WriteAllTextAsync(request.OutputPath, "complete but unverified");
long bytes = new FileInfo(request.OutputPath).Length;
output("{\"v\":1,\"e\":\"started\",\"bakeToolVersion\":4}\n");
output($"{{\"v\":1,\"e\":\"completed\",\"bakeToolVersion\":4,"
output($"{{\"v\":1,\"e\":\"started\",\"bakeToolVersion\":{LauncherInstallRecordStore.CurrentBakeToolVersion}}}\n");
output($"{{\"v\":1,\"e\":\"completed\",\"bakeToolVersion\":{LauncherInstallRecordStore.CurrentBakeToolVersion},"
+ $"\"outputBytes\":{bytes},\"failures\":0}}\n");
return new BakeProcessResult(0, string.Empty);
});