Skip to content

Pick under the cursor in milliseconds on a city-sized map. - #129

Merged
turbo-devv merged 3 commits into
openOMSI-org:mainfrom
benchan0527:fix/pick-stall-on-large-maps
Nov 20, 2026
Merged

turbo-devv merged 3 commits into
openOMSI-org:mainfrom
benchan0527:fix/pick-stall-on-large-maps

Conversation

@benchan0527

Copy link
Copy Markdown
Contributor

What was wrong

On a large map, moving the mouse over the 3D view froze the view for about two seconds. The profile put it in the editor section, and measuring inside the pick showed where:

pick 1013 ms: objects 2 (near 705), rows/attached 2 (index 1), copies 1011, splines 0, ground 39 m

pick_into walks every [splineAttachement] record near the cursor, and for each one it called selection::attachment_copies, which builds the whole map's MapIndex (every spline's length, links and chain offset, over all 485 tiles) — once per record. A tile with a few hundred records therefore rebuilt the index a few hundred times per mouse move.

Measured on NT_merged_v2 (485 tiles, 65,727 splines, 45,636 objects):

  • before: 1,013–1,946 ms per pick, eight consecutive ~1.75 s frames
  • after: 4–6 ms per pick, ~215 fps while moving the mouse

The change

  • The row index is built once per pick and passed into place::row_objects, instead of being rebuilt for every record. selection::attachment_copies remains for tests, where there is no index to hand.
  • Records, objects and splines are rejected from their own boxes before a model is read or a curve is built (spline_off_ray, a 400 m object sphere). A city has tens of thousands of both.
  • pick_into and surface_hit only look at the tiles the ray crosses (ray_meets_tile, with a margin for a spline that runs past the tile it starts in).
  • While the camera is moving the cursor follows the ground only, and the full pick runs once when the view settles. Moving the view no longer asks for a pick on every frame.
  • A pick that still takes over 150 ms logs where its time went, so a big map can be measured without OPENMAPPER_PROFILE.

The pick result is otherwise unchanged: the same nearest-first stack, the same object-over-spline tie-break.

Tests

cargo test --release --bin openmapper pick — 16 passed.

editor::tests::every_copy_of_a_record_on_a_real_map_is_picked_as_that_record fails both before and after this change on my install: it reads the models of the OMSI content that happens to be installed, and reports 7 copies as the road under them and 1 as nothing on main (left: (7, 1)) versus 6 and 4 here — it is not a regression, and the run is 40× faster (1,056 s → 27 s), which is the fix itself.

Ben Chan and others added 3 commits November 19, 2026 23:10
The pick rebuilt the whole map's row index for every record it looked at, so a map of 485 tiles and 65,000 splines spent about 1.7 s on each move of the view; on NT_merged_v2 that was a visible freeze, eight frames long, every time the mouse moved over the map.

The index is now built once per pick and passed down. Records, objects and splines are rejected from their own boxes before a model is read or a curve is built, and only the tiles the ray actually crosses are searched. While the camera is moving the cursor follows the ground and the full pick waits for the view to settle, which it then does once.

A pick that still takes over 150 ms says where its time went, so a large map can be measured without the profile.
…k after the view moved takes what is under it

- the look past objects the ray cannot reach puts an object at the ground's height plus its
  own (as it is drawn), not at its own height alone: on ground hundreds of metres up nothing
  could be picked
- the tiles a ray is looked for on reach as far as what stands on them does (a long straight
  road runs hundreds of metres past its tile), not a fixed 160 m
- a spline's bound takes its climb from its gradients and Δh, an arc's too
- while the camera eases only the ground was followed: a click (or a right click's menu) in
  those frames took what was under the cursor before the view moved. It looks again first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@turbo-devv
turbo-devv merged commit d766c66 into openOMSI-org:main Nov 20, 2026
4 checks passed
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