feat(paper): render the whole sheet via the shader, drop PaperCanvas

Paper space now renders entirely through the unified GPU shader, exactly
like model space — there is no separate 2-D canvas. The full-canvas
top-locked "sheet" viewport draws the layout's entities, hatches,
wipeouts and images; the desk is the container background and the white
printable area is a synthetic solid hatch.

- The white sheet fill uses draw_depth -2.0 (entity fills/wires are in
  the signed (-1, 1) range) so it is always strictly behind every object,
  with a negligible z offset (BIAS 0.001) — no far-plane clipping.
- Delete src/scene/paper_canvas.rs (the PaperCanvas widget) and its dead
  helpers (paper_canvas_wires / paper_sheet_wires / paper_canvas_cache).
  paper_canvas_hatches / _wipeouts remain — still used by paper hit-test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-06-02 20:25:50 +03:00
commit 206ad1a4aa
4 changed files with 52 additions and 247 deletions

View file

@ -4,12 +4,11 @@ use super::history::history_dropdown_labels;
use super::document::{DynComponent, DynFieldEntry};
use super::{Message, OpenCADStudio};
use crate::scene::grip::{grips_to_screen, grips_to_screen_paper};
use crate::scene::paper_canvas::PaperCanvas;
use crate::scene::viewport_pane::ViewportPane;
use crate::scene::{VIEWCUBE_DRAW_PX, VIEWCUBE_PAD};
use crate::ui::overlay;
use iced::widget::{
button, canvas, column, container, mouse_area, pick_list, row, shader, stack, text, text_input,
button, column, container, mouse_area, pick_list, row, shader, stack, text, text_input,
Row, Space,
};
use iced::window;
@ -470,15 +469,19 @@ impl OpenCADStudio {
.width(Fill)
.height(Fill)
} else if is_paper {
// Paper layout: 2-D sheet + paper entities + viewport borders
// underneath, unified GPU shader on top (only paints inside
// each content viewport's scissor rect so the sheet shows
// through outside them).
let paper_sheet: Element<'_, Message> =
canvas(PaperCanvas::new(&tab.scene)).width(Fill).height(Fill).into();
// Paper layout: the GPU shader renders everything — the desk is the
// container background, the white sheet + paper entities + borders
// come from the full-canvas top-locked "sheet" viewport, and the
// floating content viewports overlay it (same path as model space).
const DESK: Color = Color { r: 0.22, g: 0.24, b: 0.28, a: 1.0 };
stack![
paper_sheet,
container(viewport_3d).width(Fill).height(Fill),
container(viewport_3d)
.style(move |_: &Theme| container::Style {
background: Some(Background::Color(DESK)),
..Default::default()
})
.width(Fill)
.height(Fill),
selection_overlay,
viewport_mouse,
]