diff --git a/docs/ISSUES.md b/docs/ISSUES.md index aa939074..120229f6 100644 --- a/docs/ISSUES.md +++ b/docs/ISSUES.md @@ -4021,12 +4021,30 @@ in the render digest) and shows a water barrel that retail doesn't. **Lead (from the T5 launch log):** exactly two `[up-null] upload returned null for 0x00010002B4 / 0x00010008A8 — caching -EMPTY render data (permanently invisible)` lines at startup. Identify -which models those are (likely GfxObjs 0x010002B4 / 0x010008A8 — plausibly -the stair parts) and why `ObjectMeshManager`'s upload returned null; the -"permanently invisible" cache makes any transient failure sticky. The -barrel is a separate static-inclusion question (which cell owns it, and -is it admitted by a view it shouldn't be). +EMPTY render data (permanently invisible)` lines at startup. + +**Narrowed 2026-06-11 (the [up-null] lead is EXONERATED, dat-proven):** +`Issue119UpNullGfxObjDumpTests` — both GfxObjs are legitimately no-draw +models: 0x010002B4 = 9 polys, ALL `NoPos`, all surfaces `Base1Solid`; +0x010008A8 = 1 poly, `NoPos`, `Base1Solid|Translucent`. Retail's +skipNoTexture never draws them either (the BR-1 equivalence) — the empty +cache is the CORRECT terminal state, and the alarming log line was the +only defect (reworded; it stays as a tripwire for the real-failure shape). +Second fact, same test: on the hall/tower shell 0x010014C3, ZERO textured +polys are dropped by the extraction gates (137/149 draw; the 12 dropped +are the known #113 no-draw orphans) — the per-poly extraction is +exonerated for building shells, pinned by +`ShellModel_NoTexturedPolyIsDropped`. + +**Remaining hypothesis space (needs the re-gate to identify the exact +tower):** the missing stair parts draw from somewhere other than the +shell GfxObj's per-poly extraction — most plausibly interior stair-CELL +shells whose visibility depends on the flood admitting those cells from +the outside view, or a different building model than assumed. At the +re-gate: have the user point at the tower (one sentence / approx +location) — then the cell set + flood can be replayed headlessly like +#118. The extraneous water barrel remains a separate static-inclusion +question (which cell owns it; is it admitted by a view it shouldn't be). --- diff --git a/src/AcDream.App/Rendering/Wb/ObjectMeshManager.cs b/src/AcDream.App/Rendering/Wb/ObjectMeshManager.cs index 7817fa75..d717a934 100644 --- a/src/AcDream.App/Rendering/Wb/ObjectMeshManager.cs +++ b/src/AcDream.App/Rendering/Wb/ObjectMeshManager.cs @@ -715,9 +715,16 @@ namespace AcDream.App.Rendering.Wb { var renderData = UploadGfxObjMeshData(meshData); if (renderData == null) { - // TEMP diagnostic #105 (strip with fix): the empty substitute is cached in - // _renderData forever -> the object exists but never draws (invisible walls). - Console.WriteLine($"[up-null] upload returned null for 0x{meshData.ObjectId:X10} — caching EMPTY render data (permanently invisible)"); + // 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)"); renderData = new ObjectRenderData(); } diff --git a/tests/AcDream.Core.Tests/Conformance/Issue119UpNullGfxObjDumpTests.cs b/tests/AcDream.Core.Tests/Conformance/Issue119UpNullGfxObjDumpTests.cs new file mode 100644 index 00000000..be5e4413 --- /dev/null +++ b/tests/AcDream.Core.Tests/Conformance/Issue119UpNullGfxObjDumpTests.cs @@ -0,0 +1,139 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using DatReaderWriter; +using DatReaderWriter.DBObjs; +using DatReaderWriter.Enums; +using DatReaderWriter.Options; +using Xunit; +using Xunit.Abstractions; + +namespace AcDream.Core.Tests.Conformance; + +/// +/// #119 diagnostic dump (2026-06-11): GfxObjs 0x010002B4 and 0x010008A8 hit +/// `[up-null] upload returned null — caching EMPTY render data (permanently +/// invisible)` at startup (t5-gate-launch.log:33-34); the old tower shows +/// missing stair parts (visible in retail — user axiom). UploadGfxObjMeshData +/// returns null only when the PREPARE phase produced ZERO vertices +/// (ObjectMeshManager.cs:1780), so the upload is innocent — some extraction +/// gate dropped every polygon. This dump prints the raw dat facts per polygon +/// and replicates PrepareGfxObjMeshData's gates (ObjectMeshManager.cs:1040-1058) +/// so the zeroing gate reads directly off the output. +/// +public sealed class Issue119UpNullGfxObjDumpTests +{ + private readonly ITestOutputHelper _out; + public Issue119UpNullGfxObjDumpTests(ITestOutputHelper output) => _out = output; + + public static readonly TheoryData UpNullIds = new() { 0x010002B4u, 0x010008A8u }; + + [Theory] + [MemberData(nameof(UpNullIds))] + public void DumpUpNullGfxObj(uint id) + { + var datDir = ConformanceDats.ResolveDatDir(); + if (datDir is null) { _out.WriteLine("dats unavailable — skipped"); return; } + using var dats = new DatCollection(datDir, DatAccessType.Read); + + Assert.True(dats.Portal.TryGet(id, out var gfx) && gfx is not null, + $"GfxObj 0x{id:X8} not in portal dat"); + + _out.WriteLine($"=== GfxObj 0x{id:X8} ==="); + _out.WriteLine($"Flags={gfx!.Flags} Polygons={gfx.Polygons.Count} Vertices={gfx.VertexArray.Vertices.Count} Surfaces={gfx.Surfaces.Count}"); + _out.WriteLine($"DrawingBSP={(gfx.DrawingBSP?.Root is null ? "NONE" : "present")} PhysicsBSP={(gfx.PhysicsBSP?.Root is null ? "NONE" : "present")}"); + + for (int i = 0; i < gfx.Surfaces.Count; i++) + { + uint sid = gfx.Surfaces[i]; + string stype = dats.Portal.TryGet(sid, out var surf) && surf is not null + ? surf.Type.ToString() + : "MISSING"; + _out.WriteLine($" surface[{i}] = 0x{sid:X8} type={stype}"); + } + + // Replicate the extraction gates (PrepareGfxObjMeshData): + // pos added when !NoPos + // neg added when Negative || Both || (!NoNeg && SidesType==Clockwise) + // surface index must be in [0, Surfaces.Count) + int wouldAddPos = 0, wouldAddNeg = 0, degenerate = 0; + var gateHistogram = new Dictionary(); + foreach (var (pid, poly) in gfx.Polygons.OrderBy(kv => kv.Key)) + { + string gate; + 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 neg = (poly.Stippling.HasFlag(StipplingType.Negative) + || poly.Stippling.HasFlag(StipplingType.Both) + || (!poly.Stippling.HasFlag(StipplingType.NoNeg) && poly.SidesType == CullMode.Clockwise)) + && poly.NegSurface >= 0 && poly.NegSurface < gfx.Surfaces.Count; + if (pos) wouldAddPos++; + if (neg) wouldAddNeg++; + gate = pos || neg ? "DRAWS" : $"DROPPED stip={poly.Stippling} sides={poly.SidesType} posSurf={poly.PosSurface} negSurf={poly.NegSurface}"; + } + gateHistogram.TryGetValue(gate, out int c); + gateHistogram[gate] = c + 1; + _out.WriteLine(FormattableString.Invariant( + $" poly[{pid}] verts={poly.VertexIds.Count} stip={poly.Stippling} sides={poly.SidesType} posSurf={poly.PosSurface} negSurf={poly.NegSurface} gate={gate}")); + } + + _out.WriteLine($"--- summary: wouldAddPos={wouldAddPos} wouldAddNeg={wouldAddNeg} degenerate={degenerate} of {gfx.Polygons.Count} polys ---"); + foreach (var (gate, count) in gateHistogram.OrderByDescending(kv => kv.Value)) + _out.WriteLine($" {count,3} × {gate}"); + } + + /// + /// #119 second fact: does the extraction drop any polys that retail WOULD + /// draw (textured, non-solid surface) on a building-shell model? Run on the + /// Holtburg meeting-hall shell 0x010014C3 (the #113-saga tower whose stairs + /// 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. + /// + [Theory] + [InlineData(0x010014C3u)] + public void ShellModel_NoTexturedPolyIsDropped(uint id) + { + var datDir = ConformanceDats.ResolveDatDir(); + if (datDir is null) { _out.WriteLine("dats unavailable — skipped"); return; } + using var dats = new DatCollection(datDir, DatAccessType.Read); + + Assert.True(dats.Portal.TryGet(id, out var gfx) && gfx is not null, + $"GfxObj 0x{id:X8} not in portal dat"); + + bool SurfaceIsTextured(short idx) + { + if (idx < 0 || idx >= gfx!.Surfaces.Count) return false; + if (!dats.Portal.TryGet(gfx.Surfaces[idx], out var surf) || surf is null) return false; + return !surf.Type.HasFlag(SurfaceType.Base1Solid); + } + + int draws = 0; + var droppedTextured = new List(); + 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 neg = (poly.Stippling.HasFlag(StipplingType.Negative) + || poly.Stippling.HasFlag(StipplingType.Both) + || (!poly.Stippling.HasFlag(StipplingType.NoNeg) && poly.SidesType == CullMode.Clockwise)) + && poly.NegSurface >= 0 && poly.NegSurface < gfx.Surfaces.Count; + if (pos || neg) { draws++; continue; } + + // dropped by the gates — would retail have drawn a textured side? + if (SurfaceIsTextured(poly.PosSurface) || SurfaceIsTextured(poly.NegSurface)) + droppedTextured.Add(FormattableString.Invariant( + $"poly[{pid}] stip={poly.Stippling} sides={poly.SidesType} posSurf={poly.PosSurface} negSurf={poly.NegSurface}")); + } + + _out.WriteLine($"GfxObj 0x{id:X8}: polys={gfx.Polygons.Count} drawnByGates={draws} droppedTextured={droppedTextured.Count}"); + foreach (var line in droppedTextured) + _out.WriteLine($" {line}"); + Assert.True(droppedTextured.Count == 0, + $"{droppedTextured.Count} textured polys are dropped by the extraction gates on 0x{id:X8} — see output"); + } +}