forked from 1b-agent/opencadstudio-upstream
feat: render active MSPACE viewport as a true 3D widget in paper space
When a paper-space viewport is activated (double-click / MSPACE command), it is now rendered through its own dedicated PaperViewportPipeline rather than the CPU-projection approach used for inactive viewports. Architecture: - PaperSheet widget (full-canvas): renders paper entities + CPU-projected content of all viewports *except* the active one. - PaperViewportPane widget (Fixed w×h, positioned at viewport screen rect): renders the active viewport with a true 3D camera derived from the viewport's view_direction/view_target/view_height. PaperViewportPipeline is a newtype of Pipeline. Having a distinct type gives it its own Iced storage entry (keyed by TypeId), preventing the shared prepare() overwrite that broke the earlier per-viewport approach. Changes: - render.rs: PaperViewportPipeline, PaperViewportPrimitive newtypes; build_active_viewport_primitive(); build_paper_sheet_primitive() now excludes active_viewport from CPU projection. - viewport_pane.rs: PaperViewportPane<'a> with shader::Program impl. - mod.rs: viewport_content_wires() gains exclude_vp parameter; viewport_screen_rect() is no longer dead code. - view.rs: paper_canvas_view() overlays PaperViewportPane when MSPACE is active. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
d1d4bb3d02
commit
97dbd80c93
4 files changed
+171
-21
No files matched your search
@@ -1,4 +1,4 @@
|
||||
use super::render::{CameraState, Primitive};
|
||||
use super::render::{CameraState, PaperViewportPrimitive, Primitive};
|
||||
use super::Scene;
|
||||
use acadrust::Handle;
|
||||
use iced::widget::shader;
|
||||
@@ -48,7 +48,59 @@ impl<'a> ViewportPane<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
// ── shader::Program impl ──────────────────────────────────────────────────
|
||||
// ── PaperViewportPane ─────────────────────────────────────────────────────
|
||||
//
|
||||
// A shader widget for the MSPACE active viewport. Uses PaperViewportPrimitive
|
||||
// (and therefore PaperViewportPipeline) so it gets its own Iced storage entry,
|
||||
// separate from the ViewportPane/PaperSheet pipeline.
|
||||
|
||||
pub struct PaperViewportPane<'a> {
|
||||
pub scene: &'a Scene,
|
||||
pub handle: Handle,
|
||||
}
|
||||
|
||||
impl<'a> PaperViewportPane<'a> {
|
||||
pub fn new(scene: &'a Scene, handle: Handle) -> Self {
|
||||
Self { scene, handle }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Msg: std::fmt::Debug + Clone> shader::Program<Msg> for PaperViewportPane<'a> {
|
||||
type State = CameraState;
|
||||
type Primitive = PaperViewportPrimitive;
|
||||
|
||||
fn draw(
|
||||
&self,
|
||||
state: &Self::State,
|
||||
_cursor: mouse::Cursor,
|
||||
bounds: Rectangle,
|
||||
) -> Self::Primitive {
|
||||
self.scene.build_active_viewport_primitive(self.handle, state.hover_region, bounds)
|
||||
}
|
||||
|
||||
fn update(
|
||||
&self,
|
||||
state: &mut Self::State,
|
||||
event: &Event,
|
||||
bounds: Rectangle,
|
||||
cursor: mouse::Cursor,
|
||||
) -> Option<iced::widget::Action<Msg>> {
|
||||
self.scene.update_viewcube_state(state, bounds, cursor);
|
||||
let _ = event;
|
||||
None
|
||||
}
|
||||
|
||||
fn mouse_interaction(
|
||||
&self,
|
||||
state: &Self::State,
|
||||
_b: Rectangle,
|
||||
_c: mouse::Cursor,
|
||||
) -> mouse::Interaction {
|
||||
self.scene.viewcube_mouse_interaction(state)
|
||||
}
|
||||
}
|
||||
|
||||
// ── ViewportPane shader::Program impl ────────────────────────────────────
|
||||
|
||||
impl<'a, Msg: std::fmt::Debug + Clone> shader::Program<Msg> for ViewportPane<'a> {
|
||||
type State = CameraState;
|
||||
|
||||
Reference in new issue
Block a user