Skip to content

feat(layers): math.gl bitmap UV subdivision (2/3) - #10836

Merged
ibgreen merged 14 commits into
masterfrom
codex/math-bitmap-subdivision
Nov 8, 2026
Merged

ibgreen merged 14 commits into
masterfrom
codex/math-bitmap-subdivision

Conversation

@ibgreen

@ibgreen ibgreen commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Follow up of #10835

Background

Uniform bitmap grids spend vertices in areas with little distortion. Adaptive subdivision in UV space preserves bilinear quadrilateral bounds while refining projection curvature, including triangle interiors. This PR is independent of the converter adapter.

Change List

  • Add opt-in BitmapLayer._projectionTolerance in map meters
  • Refine existing meshes with math.gl subdivideTriangleMesh
  • Preserve bilinear bounds, altitude, UVs, and picking
  • Rebuild meshes when model matrices or coordinate systems change
  • Reuse projected positions without applying the converter twice
  • Documentation

Verified with yarn exec ocular-build layers and yarn lint. Passed 7 bitmap headless tests. Visual checks were not run.


Note

Low Risk
Adds an opt-in experimental property with fallback to existing behavior when unset. Existing layer workflows and rendering pipelines are unaffected.

Overview
Adds an experimental _projectionTolerance prop to BitmapLayer that enables adaptive triangle mesh subdivision in UV space using @math.gl/geometry's subdivideTriangleMesh. This allows bitmaps rendered in preprojecting viewports (such as CustomProjectionView) to adaptively refine projected curvature while preserving bilinear bounds, altitude, and picking UVs.

Refined meshes bypass duplicate projection transforms by assigning preprojected coordinates directly to the positions attribute. The layer rebuilds geometry when _projectionTolerance, modelMatrix, or coordinateOrigin change under preprojection, and validates that target projected coordinates have linear units.

Reviewed by Cursor Bugbot for commit da20b44. Bugbot is set up for automated code reviews on this repo. Configure here.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T12:00:09.039108Z 43409e7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no new actionable issues were found.

Summary

Adds opt-in adaptive refinement to BitmapLayer through _projectionTolerance.

  • BitmapLayer adds triangles where a preprojected image bends.

All six supplied previous threads are unnumbered, so no numbered classifications are recorded. Their concerns are addressed in the current code: regression tests exist, origin changes rebuild meshes, the viewport helper is valid, meter scales are applied, the helper is exported, and test callers supply scales.

No new actionable issues found. Tests and visual checks were not run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Bounds and resolution] --> B[Seed mesh and UVs]
  B --> C[Adaptive UV refinement]
  C --> D[Model transform and CRS conversion]
  D --> E[Measure error in map meters]
  E --> C
  C --> F[Projected positions and texture coordinates]
  F --> G[Bitmap drawing and pixel picking]
Loading

Reviews (10) · Last reviewed commit: "Merge commit '622fd9b9902d2421358f4cae97..." · Reviewed by Greptile

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@coveralls

coveralls commented Oct 10, 2026 •

Copy link
Copy Markdown

Coverage Status

No base build to compare — codex/math-bitmap-subdivision into master

@ibgreen
ibgreen requested a review from Pessimistress October 10, 2026 14:09
@charlieforward9

Copy link
Copy Markdown
Member

supercedes #10350 and closes #10011 ?

@ibgreen

ibgreen commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator Author

@charlieforward9 Thanks for connecting these. I compared the current diffs: this PR does not supersede #10350 or close #10011 by itself.

#10836 adds opt-in adaptive UV mesh subdivision for CPU preprojecting viewports (such as CustomProjectionView), using a sampled error tolerance in map meters. Its default is off, and the refinement path is not enabled for the current GlobeView.

#10350 addresses separate correctness issues: rebuilding bitmap geometry and coordinate-conversion uniforms when the viewport mesh resolution changes, plus remapping Mercator-spaced TerrainLayer rows for curved rendering. Neither fix is included here.

These changes can coexist. The reusable math.gl subdivision utility provides a useful foundation for future globe refinement, but the GlobeView lifecycle and terrain coordinate fixes still need their own validation. I would keep #10350 and #10011 open until that work lands and the low-zoom reproduction is verified.

@ibgreen
ibgreen force-pushed the codex/math-bitmap-subdivision branch from d81d0c5 to eb7bb77 Compare November 5, 2026 17:20

ibgreen commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

Refreshed this branch by rebasing it independently onto current master (12496f0a9e). I kept the existing BitmapLayer subdivision-step behavior and moved subdivideTriangleMesh to @math.gl/geometry, which is the package used by the current workspace. The refreshed head is eb7bb775; CI is running.

ibgreen commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

The first post-rebase CI build caught one API mismatch: Viewport no longer exposes preproject. I switched that invalidation check to the layer’s state.preproject, pushed as 3a72dab2. The new CI run is in progress; the earlier failure was on the superseded head.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

ibgreen commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator Author

Refreshed this branch by merging current master (bf303a11) independently, preserving the bitmap subdivision change. The refreshed head is 546d620, and CI is running.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2657046. Configure here.

@chrisgervang chrisgervang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 546d620; recommend approval. No P1s. With _projectionTolerance at 0 the bounds mesh is unchanged, and the 7 bitmap headless tests pass at this head. The open greptile thread on tolerance units still holds, and I added a probe there.

Labels: P1 settle before this is merged, P2 can follow, Non-blocking optional.

image: {type: 'image', value: null, async: true},
bounds: {type: 'array', value: [1, 0, 0, 1], compare: true},
_imageCoordinateSystem: 'default',
_projectionTolerance: {type: 'number', value: 0, min: 0},

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: With #11030 and #11031, a layer with positions, imageMapping or meshMaxEdgeLength takes the mesh path. That path skips _createMesh, so _projectionTolerance is ignored with no error. Both branches refine with subdivideTriangleMesh. This one uses projection error in UV space, and #11031 uses source edge length.

  • This head merges cleanly with fefe2dc. I read the merged tree and did not run it.

Should BitmapLayer have one refinement control for both paths? If both stay, should mesh mode refine or throw?

@ibgreen
ibgreen merged commit 128dc40 into master Nov 8, 2026
9 checks passed
@ibgreen
ibgreen deleted the codex/math-bitmap-subdivision branch November 8, 2026 18:59
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.

4 participants