perf(wire): move LWDISPLAY toggle from CPU rebake to wire shader uniform

LWDISPLAY (Show Lineweight) flipping the toggle no longer triggers a full
retessellate. `render_style_for` always bakes the entity's resolved (layer-
inherited) lineweight, and the wire shader reads `Uniforms.lwdisplay_enable`
to either honour the per-vertex half_width or collapse the quad to a 1 px line.

Side effect: PDF export now uses the real lineweight regardless of LWDISPLAY,
matching AutoCAD's plot semantics (LWDISPLAY only affects screen render).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Hakan 2026-05-23 09:45:24 +03:00
commit e9488f99dd
5 changed files with 38 additions and 33 deletions

View file

@ -11,11 +11,13 @@ pub struct Uniforms {
/// hatch shader to substitute solid fill when pattern line spacing
/// falls below ~2 px (Phase 3.3 LOD).
pub world_per_pixel: f32,
pub _pad: f32,
/// LWDISPLAY toggle (1.0 = show lineweights, 0.0 = force 1 px).
/// Read by the wire shader so the toggle does not require a retessellate.
pub lwdisplay_enable: f32,
}
impl Uniforms {
pub fn new(camera: &Camera, bounds: Rectangle) -> Self {
pub fn new(camera: &Camera, bounds: Rectangle, lwdisplay_enable: bool) -> Self {
let half_h = camera.ortho_size();
let world_per_pixel = if bounds.height > 0.0 {
(2.0 * half_h) / bounds.height
@ -27,7 +29,7 @@ impl Uniforms {
camera_pos: camera.position_vec4(),
viewport_size: [bounds.width, bounds.height],
world_per_pixel,
_pad: 0.0,
lwdisplay_enable: if lwdisplay_enable { 1.0 } else { 0.0 },
}
}
}