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

@ -1661,16 +1661,36 @@ namespace AcDream.App.Rendering.Wb
var renderData = UploadGfxObjMeshData(meshData);
if (renderData == null)
{
// 0-vertex mesh: every polygon was gated out at extraction. #119
// (2026-06-11) dat-verified this is LEGITIMATE for all-no-draw
// models (all polys NoPos + Base1Solid surfaces — retail's
// skipNoTexture never draws them either; 0x010002B4/0x010008A8
// are this class, Issue119UpNullGfxObjDumpTests). The empty
// cache is the correct terminal state for those. The line stays
// as a tripwire for the OTHER way to get here (extraction
// dropped textured polys — a real defect; dat-verify with the
// dump test before treating as one).
Console.WriteLine($"[up-null] 0x{meshData.ObjectId:X10} produced a 0-vertex mesh — caching empty render data (legitimate for all-no-draw models; dat-verify via Issue119UpNullGfxObjDumpTests)");
// 0-vertex mesh: every polygon was gated out at extraction.
// #119 (2026-06-11) ORIGINALLY reasoned this is LEGITIMATE
// for every all-NoPos+Base1Solid ("all-no-draw") model,
// claiming retail's skipNoTexture never draws untextured
// subsets at all. #426 (2026-08-23, the Holtburg windmill
// axle 0x010010CE) corrected that: retail's skipNoTexture
// only suppresses untextured subsets on a BUILDING SHELL
// (RenderDeviceD3D::DrawBuilding @0x0059f2a0 sets
// ObjBuildingOrBuildingPart=1) or inside an EnvCell
// interior (DrawEnvCell @0x0059f170, arg4=1) — an
// ORDINARY object's untextured (solid-colour) polygons DO
// draw (D3DPolyRender::DrawMesh(..., arg4=0)). Extraction
// now emits the positive side for every polygon with a
// valid PosSurface regardless of NoPos, so a 0-vertex
// mesh here is legitimate ONLY for a model whose every
// polygon is degenerate (fewer than 3 vertices) or
// references no valid Surface index at all.
// Issue119UpNullGfxObjDumpTests' own dump against the
// installed DAT confirms #119's original two objects
// (0x010002B4, 9 polys; 0x010008A8, 1 poly — both
// all-NoPos+Base1Solid) now gate DRAWS on every polygon
// and are NOT examples of the legitimate 0-vertex case
// any more; they were never actually all-degenerate or
// all-invalid-surface, they were all-solid, which #426
// now extracts. The line stays as a tripwire for the
// OTHER way to get here (extraction dropped textured
// polys — a real defect;
// dat-verify with the dump test before treating a hit as
// legitimate).
Console.WriteLine($"[up-null] 0x{meshData.ObjectId:X10} produced a 0-vertex mesh — caching empty render data (legitimate only for degenerate/no-valid-surface models post-#426; dat-verify via Issue119UpNullGfxObjDumpTests)");
renderData = new ObjectRenderData();
}

View file

@ -1183,6 +1183,15 @@ public sealed partial class WbDrawDispatcher
batchIndex++)
{
ObjectRenderBatch batch = renderData.Batches[batchIndex];
// #426: a batch retail never draws for this entity casts no
// shadow either — same gate as ClassifyBatches/
// ClassifyPackedBatches (RetailUntexturedSubsetPolicy), so the
// caster and receiver agree by construction (mirrors the
// FoliageWindClassification comment below).
if (!RetailUntexturedSubsetPolicy.Draws(candidate.IsBuildingShell, batch.Key.IsSolid))
continue;
sourceBatches++;
if (!DirectionalShadowPreparedDraws.TryClassifyMaterial(
batch.Translucency,

View file

@ -631,6 +631,14 @@ public sealed unsafe partial class WbDrawDispatcher
{
ObjectRenderBatch batch =
renderData.Batches[batchIndex];
// #426: mirrors the classic ClassifyBatches gate exactly — see
// RetailUntexturedSubsetPolicy for the retail citation. ONE
// shared predicate so the classic and packed classifiers cannot
// drift (Campaign VM VM6).
if (!RetailUntexturedSubsetPolicy.Draws(entity.IsBuildingShell, batch.Key.IsSolid))
continue;
TranslucencyKind translucency = batch.Translucency;
if (opacity < 1f && IsOpaque(translucency))
translucency = TranslucencyKind.AlphaBlend;

View file

@ -3421,6 +3421,15 @@ public sealed partial class WbDrawDispatcher : IDisposable
{
var batch = renderData.Batches[batchIdx];
// #426: retail's D3DPolyRender::DrawMesh skips an UNTEXTURED
// (solid-colour) subset only on a BUILDING SHELL
// (RenderDeviceD3D::DrawBuilding sets ObjBuildingOrBuildingPart);
// ordinary statics/scenery/creatures/items draw it same as any
// textured subset. ONE shared predicate with ClassifyPackedBatches
// and AddDirectionalShadowBatches — see RetailUntexturedSubsetPolicy.
if (!RetailUntexturedSubsetPolicy.Draws(entity.IsBuildingShell, batch.Key.IsSolid))
continue;
TranslucencyKind translucency = batch.Translucency;
// #188: a mid-fade instance whose surface is otherwise Opaque/ClipMap