wgpu: overlay points (sprite-style, quad-expanded with stroke halo)

Ports GL OverlayRenderer's setOverlayPoints API to WgpuOverlayRenderer.
Each point becomes a 6-vertex screen-space quad sized to inner_diameter
+ 2*stroke_extra; the fragment reads its per-vertex corner varying
instead of gl_PointCoord (WebGPU has no sized-point primitive). Sharp
inner/stroke transition + AA on the outer edge only, matching GL.

Single uniform slot per set — colors are global to the call, not per
point. Vertex buffer regrows 1.5× on demand so steady-state sets don't
re-allocate.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Dion Moult
2026-05-31 08:23:51 +10:00
parent 1d26e5fb92
commit 716dba2244
4 changed files with 326 additions and 1 deletions
+17
View File
@@ -2837,6 +2837,18 @@ void WgpuViewportWindow::setOverlayLines(
if (isExposed()) requestUpdate();
}
void WgpuViewportWindow::setOverlayPoints(const std::vector<float>& world_xyz,
float r, float g, float b, float a,
float pixel_size,
float stroke_r, float stroke_g,
float stroke_b, float stroke_a,
float stroke_extra) {
overlays_.setOverlayPoints(world_xyz, r, g, b, a, pixel_size,
stroke_r, stroke_g, stroke_b, stroke_a,
stroke_extra);
if (isExposed()) requestUpdate();
}
// Project a world point to LOGICAL pixel coords (Qt's mouse-event units).
// Returns false if behind the camera.
static bool projectWorldToLogicalScreen(const QMatrix4x4& vp,
@@ -3954,6 +3966,11 @@ void WgpuViewportWindow::render() {
// them on the resolved surface afterwards.
overlays_.encodeOverlayLines(pass, overlay_frame);
// Overlay point sprites (measurement endpoints, snap candidates).
// Drawn after lines so the sprite halo correctly covers any line
// ends at the same world position.
overlays_.encodeOverlayPoints(pass, overlay_frame);
wgpuRenderPassEncoderEnd(pass);
wgpuRenderPassEncoderRelease(pass);