fix(snap): object snap takes precedence over ortho/polar
When drawing with Ortho (or Polar) on, a point that snapped to an object (e.g. an Endpoint) was still pulled onto the ortho axis, so you couldn't close a shape exactly on an existing vertex. Skip the ortho/polar constraint while an object snap is locked, in both the preview and commit paths. Grid snap is positional rather than an object snap, so it still combines with ortho/polar. (#132) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
7f2aa6178a
commit
2be26e9e2e
1 changed files with 39 additions and 24 deletions
|
|
@ -2760,6 +2760,14 @@ impl OpenCADStudio {
|
|||
.snap_result
|
||||
.map(|s| self.tabs[i].scene.paper_to_model(s.world))
|
||||
.unwrap_or(cursor_world);
|
||||
// Object snap wins over ortho/polar: a snapped point
|
||||
// is taken as-is so it isn't pulled onto the ortho
|
||||
// axis. Grid snap is positional, not an object snap,
|
||||
// so it still combines with ortho/polar. (#132)
|
||||
let osnap_locked = self.tabs[i]
|
||||
.snap_result
|
||||
.is_some_and(|s| s.snap_type != crate::snap::SnapType::Grid);
|
||||
if !osnap_locked {
|
||||
if let Some(base) = self.last_point {
|
||||
if self.ortho_mode {
|
||||
pt = ortho_constrain(pt, base);
|
||||
|
|
@ -2774,6 +2782,7 @@ impl OpenCADStudio {
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
pt
|
||||
};
|
||||
// Clamp to world XY only when no UCS is active; with a
|
||||
|
|
@ -3360,7 +3369,12 @@ impl OpenCADStudio {
|
|||
if self.tabs[i].active_ucs.is_none() {
|
||||
pt.z = 0.0;
|
||||
}
|
||||
} else if let Some(base) = self.last_point {
|
||||
} else if !snap_hit
|
||||
.is_some_and(|s| s.snap_type != crate::snap::SnapType::Grid)
|
||||
{
|
||||
// Object snap wins over ortho/polar — a snapped point
|
||||
// commits as-is. Grid snap still combines. (#132)
|
||||
if let Some(base) = self.last_point {
|
||||
if self.ortho_mode {
|
||||
pt = ortho_constrain(pt, base);
|
||||
} else if self.polar_mode {
|
||||
|
|
@ -3374,6 +3388,7 @@ impl OpenCADStudio {
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
pt
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue