Skip to content

ASSET-522: Preserve GLB strip and fan topology - #6199

Open
Hiiva wants to merge 1 commit into
ItsNotRexed:mainfrom
Hiiva:fix/ped-glb-topology
Open

Hiiva wants to merge 1 commit into
ItsNotRexed:mainfrom
Hiiva:fix/ped-glb-topology

Conversation

@Hiiva

@Hiiva Hiiva commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

ASSET-522: preserve GLB triangle-strip and triangle-fan topology

Claim: #6089 (comment)

Problem

The ped GLB importer ignored each primitive's mode and grouped every three indices into a triangle. A six-vertex strip or fan therefore imported as two disconnected triangles instead of four. The actual assembly CLI exited successfully with the incomplete geometry. Four-vertex strips and fans failed with the triangle-list length error.

Change

Expand indexed and non-indexed triangle strips and fans into explicit triangle lists before the existing assembly path. The helper keeps primitive order, strip parity across degenerate triangles, and vertex attributes. An omitted mode and explicit TRIANGLES keep the existing path. Point and line modes now report an unsupported-mode error before output publication.

The winding and fan center follow Khronos' Topology and Connectivity rules. Whole-number JSON modes such as 5.0 remain accepted, as allowed by the same revision's JSON Encoding rules. JSON and OBJ triangle-list normalization is unchanged.

Validation

Windows, Python 3.14.6, current main 561b65a832218fbb9e6d2effd392a8eef093a3f8. Synthetic writer fixtures only; no game files or GPU.

  • Eight new methods pass. The identical final tests against unchanged main produce 36 failed and four error subcases.
  • Literal triangle-list controls cover indexed and non-indexed three/four/six-vertex primitives, reordered indices, degenerate-strip parity, mixed primitive order, skin bindings, normals, UVs, colors and materials.
  • Eight actual CLI comparisons produce byte-identical GLBs for strip/fan input and independently triangulated controls. Inputs remain unchanged.
  • Default and whole-number modes preserve the expected behavior. Unsupported modes fail with exit 2 while retaining an existing output file.
  • Existing ped assembly suite: 14 passed. CI registration: 14 passed. Text line endings: three passed. Compileall, both help commands and diff checks pass.
  • Independent peer review read the full change and reran all eight new methods successfully.

Exact integration

The topology delta applies cleanly to the combination of:

PR Exact head
#5824, embedded images ffc26593d7e09285c602332ac3fbe9db6686883d
#6119, scoped import mapping, including #5824 0c78397849daae849733468acf9521b48530bf71
#6037, static node transforms 0afc791474f4be8ab2fe72e5dde877b6b3f0173b
#5764, CLI guards f9e2ff3ebec61a632a7aed51b57413fa368f196d
#5999, document diagnostics 7f17f7f6eeb9b45ce9f3f90603687e51a65bf83a

All 51 combined test methods pass. Every published test file matches its exact head byte for byte. The combination retains the previously documented #5999/#6119 parser resolution, including the full precheck and JSON diagnostic wrapper.

Six additional actual CLI controls combine strip/fan input with a 90-degree parent matrix and positive or mirrored child scale. Every result matches an independently constructed triangle-list GLB with literal world coordinates and winding. These checks exercise static transform integration, not GPU rendering.

AI-assisted: yes

@kapitche

Copy link
Copy Markdown
Contributor

Tested 82d19e3 merged with main 916a2e8 on Linux/Python 3.12.16: pass

Merge was clean (tools/ped_assemble.py, new tests/test_ped_glb_topology.py). The test file is new, so the control is the tool restored from main.

  • python -I tests/test_ped_glb_topology.py: Ran 8 tests, OK.
  • Negative control (tools/ped_assemble.py restored from upstream/main, new test kept): Ran 8 tests, FAILED (failures=36, errors=4) across every test in the file: strips and fans mis-read as plain triangle lists, non-surface modes accepted, and incomplete strips and fans dropped. PR version restored afterwards.

Diff read: read_glb_parts now expands the primitive by its mode through _glb_triangles: 4 as before, 5 (strip) with alternating index order, 6 (fan) as (i+1, i+2, 0), a whole-number float mode accepted as the integer, and any other mode (points, lines, bool, string, fractional, out of range) or fewer than three vertices a PedAssembleError (exit 2 from the CLI with the output file left alone). The expected triangle lists in the tests are written out literally, and I checked the strip parity and fan rule in the code against the glTF 2.0 topology rules the test cites (odd strip triangles swap their last two indices).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants