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:
parent
51a5fe99ef
commit
517d17b4b3
18 changed files with 755 additions and 40 deletions
|
|
@ -41,7 +41,19 @@ public static class CellMesh
|
|||
if (poly.VertexIds.Count < 3)
|
||||
continue; // degenerate polygon
|
||||
|
||||
// Skip if NoPos stippling is set (polygon has no positive surface geometry).
|
||||
// Retail's RenderDeviceD3D::DrawEnvCell (@0x0059f170) calls
|
||||
// D3DPolyRender::DrawMesh with arg4=1, which skips every
|
||||
// UNTEXTURED subset inside an EnvCell interior — unlike ordinary
|
||||
// objects, which draw them (see RetailUntexturedSurfacePolicy /
|
||||
// RetailUntexturedSubsetPolicy, #426). We approximate
|
||||
// "untextured" here with the polygon's own NoPos stippling flag
|
||||
// rather than resolving the Surface's own Type
|
||||
// (Base1Image/Base1ClipMap) before this per-polygon decision —
|
||||
// see docs/architecture/retail-divergence-register.md AP-234. Do
|
||||
// NOT remove this gate the way #426 removed the matching gate in
|
||||
// GfxObjMesh.Build/MeshExtractor.PrepareGfxObjMeshData — retail
|
||||
// genuinely skips untextured cell geometry, unlike ordinary
|
||||
// objects.
|
||||
if (poly.Stippling.HasFlag(DatReaderWriter.Enums.StipplingType.NoPos))
|
||||
continue;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,16 @@ public static class GfxObjMesh
|
|||
/// The rule for emitting a polygon side:
|
||||
/// </para>
|
||||
/// <list type="bullet">
|
||||
/// <item><b>Pos side:</b> emit whenever <c>!Stippling.NoPos</c> and
|
||||
/// <c>PosSurface</c> is a valid index.</item>
|
||||
/// <item><b>Pos side:</b> emit whenever <c>PosSurface</c> is a valid
|
||||
/// index, REGARDLESS of <c>Stippling.NoPos</c>. #426
|
||||
/// (2026-08-23): NoPos ("NO_POS_UVS", acclient.h:7386) means
|
||||
/// "this side has no texture coordinates" — every solid-colour
|
||||
/// polygon carries it, since it has no UVs to carry — not "there
|
||||
/// is no positive face". Retail's <c>D3DPolyRender::DrawMesh</c>
|
||||
/// draws untextured (solid) subsets on ordinary objects the same
|
||||
/// as textured ones (see <see cref="RetailUntexturedSurfacePolicy"/>);
|
||||
/// a NoPos polygon with no UVs to read falls back to UV index 0 /
|
||||
/// zero texcoords below.</item>
|
||||
/// <item><b>Neg side:</b> emit when
|
||||
/// <c>Stippling.Negative</c>, <c>Stippling.Both</c>, or
|
||||
/// <c>(!Stippling.NoNeg && SidesType == CullMode.Clockwise)</c>.
|
||||
|
|
@ -69,9 +77,10 @@ public static class GfxObjMesh
|
|||
continue; // degenerate — can't form a triangle
|
||||
|
||||
// --- Positive side ---
|
||||
bool hasPos = !poly.Stippling.HasFlag(StipplingType.NoPos);
|
||||
if (hasPos)
|
||||
EmitSide(poly, poly.PosSurface, isNeg: false);
|
||||
// #426: always emit — NoPos only means "no positive UVs", not
|
||||
// "no positive face" (see the class doc). EmitSide's own
|
||||
// surfaceIdx-validity guard is the only real gate.
|
||||
EmitSide(poly, poly.PosSurface, isNeg: false);
|
||||
|
||||
// --- Negative side ---
|
||||
// Three ways AC flags a polygon as double-sided:
|
||||
|
|
|
|||
76
src/AcDream.Core/Meshing/RetailUntexturedSurfacePolicy.cs
Normal file
76
src/AcDream.Core/Meshing/RetailUntexturedSurfacePolicy.cs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
using DatReaderWriter.Enums;
|
||||
|
||||
namespace AcDream.Core.Meshing;
|
||||
|
||||
/// <summary>
|
||||
/// Retail's textured-vs-untextured surface classification, ported from
|
||||
/// <c>D3DPolyRender::DrawMesh</c> @0x0059d4a0 (named-retail decomp,
|
||||
/// docs/research/named-retail/acclient_2013_pseudo_c.txt ~line 426048): a
|
||||
/// surface subset is TEXTURED — and therefore never subject to either of
|
||||
/// retail's "skip untextured" gates (see
|
||||
/// <see cref="RetailUntexturedSubsetPolicy"/>) — when
|
||||
/// <c>(surface->type & 6) != 0</c>, i.e. when
|
||||
/// <see cref="SurfaceType.Base1Image"/> (<c>BASE1_IMAGE</c>, 0x2) or
|
||||
/// <see cref="SurfaceType.Base1ClipMap"/> (<c>BASE1_CLIPMAP</c>, 0x4) is set
|
||||
/// (docs/research/named-retail/acclient.h:5822-5824). Every other surface —
|
||||
/// including <see cref="SurfaceType.Base1Solid"/> and any surface whose type
|
||||
/// carries neither bit — is UNTEXTURED: a flat-colour ("solid") subset filled
|
||||
/// from <c>Surface.ColorValue</c> rather than a decoded texture.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// #426 (2026-08-23, the Holtburg windmill axle 0x010010CE): the polygon-side
|
||||
/// <c>StipplingType.NoPos</c> flag ("this side has no texture coordinates",
|
||||
/// acclient.h:7386) is NOT the same fact as "this surface is untextured" —
|
||||
/// every solid-colour polygon carries NoPos (it has no UVs to carry), but
|
||||
/// NoPos says nothing about whether the surface itself is textured. The old
|
||||
/// extraction conflated the two (<c>isSolid = NoPos || Base1Solid</c>) and,
|
||||
/// worse, used NoPos to decide whether to emit the polygon's positive side AT
|
||||
/// ALL — dropping every solid-colour polygon on every object. This type is
|
||||
/// the ONE place that answers "is this surface textured", built from the
|
||||
/// Surface's own Type flags so extraction (isSolid / TextureKey.IsSolid) and
|
||||
/// draw-time skip policy agree by construction.
|
||||
/// </remarks>
|
||||
public static class RetailUntexturedSurfacePolicy
|
||||
{
|
||||
public static bool IsUntextured(SurfaceType type) =>
|
||||
(type & (SurfaceType.Base1Image | SurfaceType.Base1ClipMap)) == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retail's draw-time policy for an UNTEXTURED (solid-colour) mesh subset on
|
||||
/// an ordinary <see cref="AcDream.Core.World.WorldEntity"/>, ported from the
|
||||
/// same <c>D3DPolyRender::DrawMesh</c> untextured branch: the subset draws
|
||||
/// unless <c>skipNoTexture != 0 &&
|
||||
/// RenderDeviceD3D::ObjBuildingOrBuildingPart != 0</c>. <c>skipNoTexture</c>
|
||||
/// @0x00820e30 is a global initialised to 1 and never cleared, so in
|
||||
/// practice the gate reduces to
|
||||
/// <c>RenderDeviceD3D::ObjBuildingOrBuildingPart == 0</c>.
|
||||
/// <c>RenderDeviceD3D::DrawBuilding</c> (@0x0059f2a0) sets that flag around
|
||||
/// the building-shell draw, so a building shell's own untextured subsets are
|
||||
/// the ONE case where an ordinary WorldEntity skips them — statics, scenery,
|
||||
/// creatures, and items (<c>DrawMeshInternal</c> @0x0059f360 →
|
||||
/// <c>DrawMesh(gfxobj, mesh, arg4: 0)</c>) always draw their untextured
|
||||
/// subsets.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// EnvCell interiors are retail's OTHER "skip untextured" case
|
||||
/// (<c>RenderDeviceD3D::DrawEnvCell</c> @0x0059f170 calls
|
||||
/// <c>DrawMesh(..., arg4: 1)</c>), but EnvCell/CellStruct geometry never
|
||||
/// reaches this predicate — it draws through <c>EnvCellRenderer</c> /
|
||||
/// <c>MeshExtractor.PrepareCellStructMeshData</c>, which keeps its own
|
||||
/// NoPos-based approximation of the same rule (see
|
||||
/// <c>docs/architecture/retail-divergence-register.md</c> AP-234 and
|
||||
/// <c>CellMesh.cs</c>'s matching gate).
|
||||
/// <para>
|
||||
/// ONE shared predicate for <c>WbDrawDispatcher</c>'s classic classifier
|
||||
/// (<c>ClassifyBatches</c>), packed classifier (<c>ClassifyPackedBatches</c>),
|
||||
/// and the directional-shadow caster walk (<c>AddDirectionalShadowBatches</c>)
|
||||
/// — Campaign VM VM6 showed that two hand-maintained classifiers computing
|
||||
/// the "same" fact independently drift apart.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public static class RetailUntexturedSubsetPolicy
|
||||
{
|
||||
public static bool Draws(bool isBuildingShell, bool isUntextured) =>
|
||||
!isUntextured || !isBuildingShell;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue