fix(viewport): align picks in oblique views
Project cursor rays directly onto the active drawing plane so previews and committed points remain under the pointer. Refs #429 Refs #452
This commit is contained in:
parent
429d2eb06b
commit
b744d4bf2d
1 changed files with 13 additions and 10 deletions
|
|
@ -225,18 +225,21 @@ impl OpenCADStudio {
|
||||||
p: iced::Point,
|
p: iced::Point,
|
||||||
bounds: iced::Rectangle,
|
bounds: iced::Rectangle,
|
||||||
) -> glam::DVec3 {
|
) -> glam::DVec3 {
|
||||||
// Constrain to the UCS plane only where the UCS applies (model space or
|
// Model-space input always belongs to a drawing plane. With no active
|
||||||
// inside a viewport); plain paper space uses the target plane.
|
// UCS that plane is world XY; using the camera target plane and only
|
||||||
let plane = self.tabs[i]
|
// clearing Z afterwards shifts the picked point on screen in an
|
||||||
.active_ucs
|
// oblique view. Plain paper space still uses the camera target plane.
|
||||||
.as_ref()
|
let plane = if self.tabs[i].editing_model_space() {
|
||||||
.filter(|_| self.tabs[i].editing_model_space())
|
Some(match self.tabs[i].active_ucs.as_ref() {
|
||||||
.map(|ucs| {
|
Some(ucs) => (
|
||||||
(
|
|
||||||
ucs_z_axis(ucs),
|
ucs_z_axis(ucs),
|
||||||
glam::DVec3::new(ucs.origin.x, ucs.origin.y, ucs.origin.z),
|
glam::DVec3::new(ucs.origin.x, ucs.origin.y, ucs.origin.z),
|
||||||
)
|
),
|
||||||
});
|
None => (glam::DVec3::Z, glam::DVec3::ZERO),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
let pick = |cam: &crate::scene::view::camera::Camera| match plane {
|
let pick = |cam: &crate::scene::view::camera::Camera| match plane {
|
||||||
Some((normal, origin)) => cam.pick_on_plane(p, bounds, normal.as_vec3(), origin),
|
Some((normal, origin)) => cam.pick_on_plane(p, bounds, normal.as_vec3(), origin),
|
||||||
None => cam.pick_on_target_plane(p, bounds),
|
None => cam.pick_on_target_plane(p, bounds),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue