X and the toolbar's Construction no longer start a pick tool (Fusion has none): with a selection they convert it, with nothing selected they switch construction mode, outside a sketch they say so. Center Rectangle draws both diagonals as construction, the centre at their crossing, with only the first carrying the midpoint constraint (the second is implied), so a fresh one stays at 4 DOF. Scenarios s30 (pattern a hole) and s32 (cut in the active component) enabled now that b36b332 is on main
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AS5Tn3xieewUSg3uxrMVdL
This commit is contained in:
1 parent
90873e51bb
commit
1e8fc25976
6 files changed
+33
-11
No files matched your search
@@ -552,10 +552,16 @@ fn rect_center(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let (out, info) = edit(s, p, cmd, false, |sk, _| {
|
||||
let (l, pts) = polygon_lines(sk, &[c - h, Vec2::new(c.x + h.x, c.y - h.y), c + h, Vec2::new(c.x - h.x, c.y + h.y)])?;
|
||||
let mut cons = rect_constraints(sk, &l)?;
|
||||
if let (Some(p0), Some(p2)) = (pts.first(), pts.get(2)) {
|
||||
// Both diagonals (construction), the centre at their crossing. Only the first carries
|
||||
// the midpoint constraint: diagonals of a parallelogram bisect each other, so a second
|
||||
// one would be redundant (over-constrained).
|
||||
if let (Some(p0), Some(p1), Some(p2), Some(p3)) = (pts.first(), pts.get(1), pts.get(2), pts.get(3)) {
|
||||
let diag = sk.add_line_pts(*p0, *p2, None)?;
|
||||
if let Some(cu) = sk.curves.get_mut(diag) {
|
||||
cu.construction = true;
|
||||
let diag2 = sk.add_line_pts(*p1, *p3, None)?;
|
||||
for d in [diag, diag2] {
|
||||
if let Some(cu) = sk.curves.get_mut(d) {
|
||||
cu.construction = true;
|
||||
}
|
||||
}
|
||||
let cp = sk.add_point(c, None)?;
|
||||
cons.push(add_c(sk, ConstraintKind::Midpoint { p: cp, l: diag })?);
|
||||
|
||||
@@ -101,3 +101,19 @@ fn dragging_corners_never_collapses_a_side() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn center_rectangle_draws_both_diagonals_like_fusion() {
|
||||
let (mut s, _) = rect("center");
|
||||
let si = run(&mut s, "sketch.inspect", json!({}));
|
||||
let curves = si["curves"].as_array().cloned().unwrap_or_default();
|
||||
// Four sides plus two construction diagonals; the other rectangles have no diagonals.
|
||||
assert_eq!(curves.len(), 6, "{si}");
|
||||
assert_eq!(curves.iter().filter(|c| c["construction"] == true).count(), 2, "{si}");
|
||||
assert_eq!(healthy(&mut s, "center diagonals"), 4);
|
||||
for k in ["two", "three"] {
|
||||
let (mut s, _) = rect(k);
|
||||
let si = run(&mut s, "sketch.inspect", json!({}));
|
||||
assert_eq!(si["curves"].as_array().map(Vec::len), Some(4), "{k}: {si}");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user