Commit graph

1 commit

Author SHA1 Message Date
Chris McGee
e81826d50d
improve: 2D mapper rendering speed on single-Z-level areas (#9209)
#### Brief overview of PR changes/additions
Add TAreaZLevelIndex and TAreaGridIndex - spatial indices maintained
alongside TArea::rooms that allow the renderer to query only rooms on
the current Z level or within the visible viewport rectangle, instead of
iterating all rooms in the area on every paint event.

Key changes:
- TAreaZLevelIndex: Z -> set<roomId> index, O(1) getRoomsForZ()
- TAreaGridIndex: Z -> X -> Y -> set<roomId> viewport index for grid
mode
- T2DMap::drawGridModeRooms: new batch renderer for grid mode using the
spatial index; includes LOD fast-path for sub-pixel zoom levels that
writes directly to QImage scanlines (~700x speedup vs QPainterPath)
- T2DMap::scheduleRender: throttled repaint via QTimer (~60fps cap) for
continuous input events (pan drag, scroll-wheel zoom)
- paintEvent: uses getRoomsForZ() for upper/lower level shadows and
exits, eliminating per-frame O(N-total) scans
- dlgMapper: fix setPen before boundingRect to prevent invisible info
box
- TMap::setRoomCoordinates: keeps both indices consistent on room moves

#### Motivation for adding to Mudlet
As grid mode maps scale, interacting with the map (specifically zooming
and panning) becomes sluggish to unusable in the extreme.

#### Other info (issues closed, discussion etc)
2026-04-23 06:18:21 +02:00