mirror of
https://github.com/storytold/cadcraft.git
synced 2026-10-14 14:26:45 -04:00
* Active viewport: redraw while panning and zooming inside it, without rebuilding the layout (#688) Inside an active MSPACE viewport, middle-drag, trackpad pan and wheel or pinch zoom change the viewport's view through set_view_quiet, which makes no new revision. The layout's display list, which draws model space through each viewport, was cached on (drawing, revision, zoom band), so it kept showing the old view until a command such as ZOOM rebuilt it: the viewport froze, or appeared to ignore the zoom. The active viewport's contents are now drawn apart from the layout's list, the way model space itself is drawn. They are built once for an area around the viewport (half its larger side of margin all round), then moved and scaled to the current view on the GPU and drawn under the layout's own objects. They are rebuilt when the drawing changes, when the zoom has moved 2x from the view they were built for, when the view leaves the built area, and once a zoom comes to rest, so dash lengths and curve detail follow the viewport's scale again. A pan step takes about 1 ms with 70,000 polylines, where rebuilding the layout takes about 140 ms per frame. Rectangular viewports are clipped with the scissor rectangle. A clipped viewport's outline is drawn into a stencil buffer as a triangle fan that flips a bit (even-odd, as the outline clips on the CPU), and its contents draw only where the bit is set; the native window now asks eframe for an 8-bit stencil buffer, and every canvas pipeline names its format. Where there is no stencil buffer (the CPU canvas, the web runner), a clipped viewport's contents stay in the layout's list, whose cache now follows the viewport's view. Render: Options::skip_viewport leaves a viewport's contents out of a layout, and viewport_content builds them for any area. Viewport contents are built on all cores, like model space (130 ms to 37 ms for 70,000 polylines). * Active viewport highlight: selection on the GPU, hover cached apart, kept inside a clipped outline Inside an active MSPACE viewport the selection highlight was drawn as dashed egui shapes on the CPU every frame, about 8-13 ms per frame with 7,000 polylines selected, and its geometry was cached together with the hover, so moving the cursor over objects tessellated the whole selection again. The selection and the hover are now cached apart, and the selection goes through the GPU highlight path model space already uses: about 0.1 ms per frame. In a clipped viewport it is kept inside the outline with the stencil mask its contents use; before, it was only cut to the outline's bounding rectangle.