fix(core): UCG Stage 1 — ResolvePortalPolygon all-or-nothing (match BuildLoadedCell)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-06-02 09:15:37 +02:00
parent 5bc72d5cd1
commit 03f08f00c1
2 changed files with 41 additions and 5 deletions

View file

@ -76,11 +76,15 @@ public sealed class EnvCell : ObjCell
private static IReadOnlyList<Vector3> ResolvePortalPolygon(CellStruct cellStruct, ushort polygonId)
{
if (!cellStruct.Polygons.TryGetValue(polygonId, out var poly)) return Array.Empty<Vector3>();
var verts = new List<Vector3>(poly.VertexIds.Count);
foreach (var vid in poly.VertexIds)
if (cellStruct.VertexArray.Vertices.TryGetValue((ushort)vid, out var v))
verts.Add(new Vector3(v.Origin.X, v.Origin.Y, v.Origin.Z));
if (!cellStruct.Polygons.TryGetValue(polygonId, out var poly) || poly.VertexIds.Count < 3)
return Array.Empty<Vector3>();
var verts = new Vector3[poly.VertexIds.Count];
for (int i = 0; i < poly.VertexIds.Count; i++)
{
if (!cellStruct.VertexArray.Vertices.TryGetValue((ushort)poly.VertexIds[i], out var v))
return Array.Empty<Vector3>(); // any miss -> empty (matches BuildLoadedCell:5686-5691)
verts[i] = new Vector3(v.Origin.X, v.Origin.Y, v.Origin.Z);
}
return verts;
}
}