Repository navigation
Center snap: hovering a circle, arc or ellipse offers its center, however far - #1114
marcoarnulfo wants to merge 1 commit into
Conversation
FredApps
left a comment
There was a problem hiding this comment.
ReviewerA — source-read COMMENT (not an approval)
I read the diff: Center snap offers the centre of a hovered circle, arc or ellipse however far it is. A new last step in the snap search, active when the centre mode is enabled (osmode & mode::CEN != 0), takes hovered_center(near_prims, cursor, aperture) and returns it if it is visible, because "on a large curve [the centre] lies far outside the aperture (as AutoCAD does)", and it comes last, "so the snaps under the cursor (and a deferred tangent on the curve) keep winning there". AutoCAD's centre snap does work by hovering the curve, so this is in line with its oracle, and putting it last keeps every other snap's priority. The if ... && let Some(..) chain needs the 2024 edition (let chains are stable from Rust 1.88 in that edition). The visible filter prevents snapping to a point off the screen, which is good. hovered_center should be bounded for a huge arc (a centre at 1e300) and must not make a snap marker appear at infinity; the visible check covers it. I have not run it, and no exact-head CI result exists for this head. Nothing was run.
I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.
Status: waiting_author.
austin62jake
left a comment
There was a problem hiding this comment.
Approving. I merged it onto current main with ten other small PRs (#1273, #1266, #1265, #1263, #1254, #1247, #1233, #1196, #1114, #1445, #1591). The whole suite passes (3170 tests), and so do fmt and the web build. Clippy stops only on #1254's test.
Offering the center of a hovered circle, arc or ellipse, even when the center is far outside the aperture, is AutoCAD's CEN behaviour. It's tried last, so snaps under the cursor and a deferred tangent keep winning there.
Fixes #1112.
The Center snap only looked for a center within the aperture of the cursor, so on an open arc or a large circle it was practically unreachable: you had to aim at a point you can't see. Now, with CEN on, hovering the curve of a circle, an arc (polyline arcs included) or an ellipse offers its center: the center marker appears there and a click picks it, which is how AutoCAD finds centers from the circumference. It is the last resort in
finish(): any snap under the cursor (Endpoint, Midpoint, Quadrant, Intersection, a deferred Tangent on the first point of a line, Nearest) still wins, so existing priorities don't change. One consequence is that with Nearest on, Nearest keeps winning on the curve; I kept that conservative, but happy to switch to the issue's "marker only, not a snap" variant, or to rank the center above Nearest, if you prefer.Validation:
snap::tests::center_snaps_from_the_curve_far_from_it(arc with its center 80 units from the cursor; CEN off, off the curve and past the arc's end give nothing; Midpoint under the cursor still wins): fails on main (osnapreturnsNoneon the arc), passes here, also alonesnap_*,snaps_more,measure_distance_snapping) and--lib snap::greencargo clippy -p cadcraft-engine --all-targets -- -D warnings,cargo fmt --all -- --check