Skip to content

Fix vertex loss in transformation for all-letter-ending node groups#189

Draft
webdevred wants to merge 3 commits intomasterfrom
fix-omap1-vertex-loss
Draft

Fix vertex loss in transformation for all-letter-ending node groups#189
webdevred wants to merge 3 commits intomasterfrom
fix-omap1-vertex-loss

Conversation

@webdevred
Copy link
Copy Markdown
Owner

@webdevred webdevred commented Apr 9, 2026

Summary

  • insertTreeInMap (VertexExtraction) replaced OMap1 entries via OMap1.snoc when the key matched, silently dropping all but the last vertex group for vehicles where most node names end in letters (e.g. burnside_frame where nodes have suffixes r, l, rr, ll, all classified as SupportKey).
  • addVertexTreeToForest used M.insert which replaced the supportForest entry when processing remaining SupportTree vertices, dropping any vertices that had been moved there by moveSupportVertices.

Both issues are now fixed:

  1. insertTreeInMap checks if the key exists and merges with (<>) on NonEmpty instead of replacing.
  2. addVertexTreeToForest uses M.insertWith mergeOMap1Trees to append OMap1 entries rather than overwrite.

Tested against burnside_frame (all 76 nodes now present, was 21 before) and bolide_chassis (stale beam references resolved as a consequence). All existing tests pass.

Missing test fixtures

@gittarrgy01 The transformation test suite has no coverage for vehicles where most structural nodes end in letters (r, l, rr, ll), these take a different code path through insertTreeInMap and addVertexTreeToForest. The bugs fixed here had no test coverage and were only caught by running against real BeamNG files.

Could you add a JBeam example file in examples/jbeam/ that exercises this pattern? The test infrastructure will pick it up from there automatically.

Two bugs caused vertices to be silently dropped when most node names
end in letters (like burnside_frame where all structural nodes have
suffixes r, l, rr, ll).

Bug 1: insertTreeInMap in VertexExtraction used OMap1.snoc which
replaces the first element when the key matches. For letter-ending
nodes, every group gets SupportKey, so only the last group was kept.
Fixed: check if key exists and merge vertices with (<>) on NonEmpty.

Bug 2: addVertexTreeToForest used M.insert which replaced the
supportForest entry when processing SupportTree vertices. Vertices
moved to supportForest by moveSupportVertices (typically digit-ending
nodes classified as support via high connectivity) were lost when the
remaining SupportTree vertices were processed by addVertexTreeToForest.
Fixed: use M.insertWith mergeOMap1Trees to merge OMap1 entries.
The threshold controls when Y-coordinate differences (front/back) are
significant enough to sort by, falling back to Z (height) within a band.
The old name was a holdover from when the code sorted on Z instead of Y.

Breaking change: existing .jbeam-edit.yaml configs using
z-sorting-threshold must rename the key to y-sorting-threshold.

Also renames the Haskell field zSortingThreshold to ySortingThreshold
and the local variable zDiff to yDiff in compareAV.
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.

1 participant