Commit Graph
76 Commits
Author SHA1 Message Date
Hakan SevenandClaude Opus 5.5 c964e365c3 fix(snap): parallel snap keeps its reference, base and lock in f64
The reference direction, base point and locked point went through f32,
so the drawn line drifted off true parallel.

Fixes #1387

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 18:32:50 +03:00
Hakan SevenandClaude Opus 5.5 19c434fc5d fix(snap): perpendicular onto circles/arcs/ellipses uses the exact curve, not tessellation chords
Fixes #1495

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 17:56:01 +03:00
yztink 92fa661065 feat(draw): add fluid tangent arc, circle, and line construction with ellipse support 2026-09-28 01:56:03 -07:00
Hakan SevenandClaude Opus 5.5 f537aff75c feat: node graph overlay; move to opencadcodec/opencadkernel/opencadgraph
The codec and kernel repositories and crates are renamed opencadcodec and
opencadkernel. Inside OCS they are depended on under short keys, so code
reads `codec::`, `kernel::` and the new `graph::` (opencadgraph, the node
graph engine). File-format and protocol spellings stay as they were: the
ACIS product id `acadrust`, the ACADRUST_* switches and the plugin
version keys `acadrust_version` / `acadrust_source`.

A button left of MCP on the command line opens a translucent node graph
over the viewport, with a palette of object, input, math, logic, list,
text and geometry nodes added by click or drag. An object node owns
drawing entities and its rows are the Properties panel's own rows for
them: the single-object page is extracted from refresh_properties as
entity_property_sections, values use the control protocol's
property_json, and writes go through set_property_value with a property
target override, so the panel, MCP and the graph share one read/write
path. A list reaching an object row makes one entity per element. Each
graph action is one undo step; the canvas pans and zooms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 07:34:23 +03:00
copilot-swe-agent[bot] 5d4b707214 fix review feedback for OTRACK projection and OtrackHit API
Co-authored-by: dichhead <330471626+dichhead@users.noreply.github.com>
(cherry picked from commit 97f94a2bfe)
2026-09-20 21:29:15 +03:00
Claude 033319a4e3 feat(otrack): draw both vectors of an intersection lock
An OTRACK crossing is the meeting of two tracking vectors, but
`OtrackHit` carried only the one a typed distance is measured along, so
the overlay had a single guide to draw. Snapping to the crossing of two
vectors worked and looked like an unexplained point on one line.

Carry the crossed ray out of `otrack_snap` as `OtrackHit::cross`, keep it
on the app beside `otrack_active`, and let the overlay take a list of
guides rather than one. `otrack_active` still drives typed-distance
entry on its own, so distance entry is unchanged.

Fixes HakanSeven12/OpenCADStudio#1313

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TQzYZsXBwPZ5HwBaGitEUV
(cherry picked from commit 2f6caacece)
2026-09-20 21:29:15 +03:00
Hakan Seven 10827283ee Merge pull request #1339 from mechpanos/snap/line-endpoint-lookup
fix(snap): keep the key-vertex lookup linear and pin the vertex layouts
2026-09-19 22:59:36 +03:00
dichhead bec382a99b Merge branch 'HakanSeven12:main' into main 2026-09-17 17:56:03 +02:00
PanosandClaude Opus 5 5ed26c858d fix(snap): keep the key-vertex lookup linear and pin the vertex layouts
`tangent_line_endpoints` (c5eec2a5) resolves a Line geom's f32 endpoints
to the wire's f64 key vertices by scanning for a matching consecutive
pair. Starting every scan at slot 0 makes a dense polyline quadratic, and
the pairwise intersection loop runs it against every curved wire in the
aperture on each cursor move. Carry a cursor across the wire's geoms: the
pairs arrive in vertex order, so the next match sits at or just after the
previous one and the scan is amortised linear.

Add regression tests for the vertex layouts the by-value lookup exists
for — a center mark (two vertices per segment plus the centre), a merged
block entry (per-entity vertex runs), and the closing segment of a closed
polyline at UTM scale — plus one that checks the cursor walks the wire
once.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-17 18:32:38 +03:00
Matus Mastena a570f4ac16 Turn object snap on by default
The running snap set was already seeded with endpoint, midpoint,
centre, node, quadrant, intersection and nearest, but the master
suppress bit was set, so none of them did anything until the user
found the status-bar pill. Snapping is what makes a drawing close
rather than nearly close; it should be live from the first click.

Only fresh configs change. A stored settings.json keeps whatever
osmode it already holds, and a legacy file carrying its own $OSMODE
still overrides on open.
2026-09-17 16:50:46 +02:00
Hakan Seven c5eec2a507 fix: preserve exact mixed polyline intersections 2026-09-17 16:56:52 +03:00
Hakan Seven fa6bf5e7e4 Merge pull request #1326 from yztink/fix-polyline-intersection-snap 2026-09-17 16:52:27 +03:00
PanosandClaude Opus 5 02cd98e790 feat(ui): feature-parity context menu — Snap Overrides, transparent Pan/Zoom, ARC keyword flow
The command menu now follows the commercial solutions' layout row for row: Enter, Cancel,
Recent Input ▸, the command's keywords, Snap Overrides ▸ (every object snap
with its glyph, Mid Between 2 Points, None, Osnap Settings…), then Pan and
Zoom. Pan / Zoom run transparently while a command is active ('PAN,
'ZOOM …): navigation modes leave the command untouched and an interactive
ZOOM Window parks it and resumes it afterwards. Rows carry an icon gutter
so labels align; the Enter row shows a default value ("<0.5000>") as its
hint instead of a second finish row.

ARC gets the commercial solutions' prompt flow with all keywords: start [Center], second
point [Center/End], end; after Center: end [Angle/chord Length]; after
End: center [Angle/Direction/Radius]; Enter continues tangent. The
previous default (Center/Start/End with method codes) stays as ARC_CSE.

Object snaps gain a one-shot "None" override. New strings in all locales.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-17 12:05:15 +03:00
Ryan 395256c296 Fix analytical intersection snapping for multi-segment polylines 2026-09-17 00:00:03 -07:00
Karim Jerbi ca0ee37d26 feat(snap): independent 3D object-snap system with six modes
Grid snap locks to SNAPUNIT instead of magnetizing; snapped 3D points keep elevation instead of flattening to z=0. New SnapTypes Vertex/EdgeMidpoint/FaceCenter/Knot/FacePerpendicular/NearestFace with their own F4 master toggle and mode set, tiers, and markers, fully independent of the 2D master. Solid B-rep corners/edge-midpoints/face-centers from mesh edges and kernel faces, spline knot points, and live perpendicular/nearest-to-face on mesh triangles merged priority-aware in move/click paths. Drafting Settings 3D Object Snap tab is fully live (was dead placeholders); Nearest-to-face off by default. TDD: behavioral LINE-to-solid tests plus engine/scene unit tests.
2026-09-16 16:43:37 +01:00
Karim Jerbi 624fe53382 feat(snap): editable Snap X/Y spacing with Equal lock, grid snap locks
Drafting Settings dialog gets text inputs for Snap X/Y spacing plus a working Equal X and Y checkbox (mirrored inputs, Y follows X on apply). Snapper gains fixed snap_spacing_x/y (persisted in UserSettings, default 10) decoupled from the adaptive visible-grid step. Grid snap no longer aperture-gated: with Snap On it rounds every point to the grid, object snaps still override by tier. Adds parse/lock regression tests.
2026-09-16 11:39:38 +01:00
Christopher Overbeck 4816652c1f Remove comments that repeat association operations 2026-09-15 16:03:17 -05:00
Christopher Overbeck 5424a19482 Track mixed paper and viewport dimension references 2026-09-15 16:00:11 -05:00
Christopher Overbeck 7f018ab0f1 Merge viewport creation fixes and current upstream into associations 2026-09-15 14:14:33 -05:00
Christopher Overbeck 2ee3782850 Fix viewport dimension acquisition and preserve measurement scaling 2026-09-15 14:13:19 -05:00
Christopher OverbeckandClaude Fable 5.1 be7ba3d68e Record viewport associations for new dimensions
Removes PR3's `viewport_frame` seam in `viewport_ref.rs`; the frame is
PR1's camera-derived one everywhere.

The five dimension commands (DIMLINEAR / DIMALIGNED / DIMRADIUS /
DIMDIAMETER / DIMANGULAR) now record a real association when they
measure through a viewport. The commit path's one association gate
(`dimension_association_allowed`, added when PR2 was stacked) gains an
else-branch: where PR2 committed the dimension unassociated and PR1's
inference guard returned an empty source list, `Scene::attach_viewport_
dimension_association` now stores the whole chain — dimension ->
viewport -> block path -> entity -> feature — from the AcceptedSnaps PR1
captured, in definition-point slot order.

* `Scene::dimension_association_slot_points` names that order, including
  the radial dimensions `dimension_reference_points` does not cover.
* `OpenCADStudio::viewport_dimension_snaps` builds the slot array. A snap
  whose paper point is no longer the definition point it fills has its
  model point recomputed from that definition point through the frame:
  the object pick records one click for both extension origins, and a
  rotated DIMLINEAR projects its origins onto the measuring axis.
* Radial dimensions take their own path inside
  `attach_viewport_dimension_association`. Their single reference is an
  osnap type 10 carrying the radial marker (which circle / which polyline
  arc segment) and the angle around it; `source_reference` would hand
  back the generic curve-parameter marker -2, which
  `radial_source_for_marker` cannot find.

One measurement rule, documented in `viewport_ref::measurement_rule`:
`actual_measurement` is always the RAW measurement in the dimension's own
space (paper, for a viewport dimension), and the viewport compensation
lives only in the magnitude of the negative DIMLFAC override, applied
once by the formatter. PR2's persistence already followed it; PR3's
refresh did not — it substituted the model distance times
`model_factor()`, which made a refreshed dimension read `user_lfac` times
too much versus an identical freshly-created one. Refresh now writes the
paper measurement (a debug assert pins resolved paper points to the model
points through the frame), and `axis_distance` goes with it.

Block sub-entity snaps: verified that `block_cache` stamps the top-level
INSERT's handle onto every expanded and clipped sub-wire, so
`wire_source` can only ever report the INSERT — nested inserts included.
`OpenCADStudio::resolve_source_block_path` now descends from that INSERT
at accept time (using the object-pick path's existing
`resolve_measurable_entity`, so arbitrary depth, not just one level) and
fills `SnapSourceRef.block_path` with the real inner entity. Where the
descent cannot identify one — a non-planar-pickable type such as text,
hatch, spline or solid, or nesting past eight levels — the source stays
the INSERT with an empty path, which is coarser but never wrong. Both the
limitation and where it bites are documented on
`Scene::resolve_block_snap_source` and `SnapResult::source`.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-15 12:52:00 -05:00
Christopher OverbeckandClaude Fable 5.1 6def465ba5 feat(snap): snap paper space through layout viewports
Paper-space commands could not pick model geometry displayed by a layout
viewport: `hit_test_wires` deliberately excludes viewport content in PSPACE,
and that has to stay true for selection. This adds the capability as a separate
query rather than by changing those semantics.

`OpenCADStudio::paper_viewport_snap` walks the current layout's displayed
content viewports top-most first, skips those whose display is off or whose
clip boundary excludes the cursor, and for each one runs the EXISTING snap
engine against that viewport's model wires using the viewport's own camera and
screen rectangle (`viewport_edit_frame_for`). The accepted model point is
mapped back onto the sheet with `ViewportFrame::model_to_paper`, so everything
downstream keeps working in paper coordinates — LINE still draws at the
projected paper point. Grid snap and the paper-space rubber-band origin are
suppressed for that pass; results outside the clip are rejected so no snap
lands on a clip cut. Locked viewports snap like unlocked ones.

No projected geometry is rebuilt per pointer event: the wire set is the
renderer's resident per-viewport Arc (`model_wires_for_viewport_arc`) and the
broad phase reuses the shared interaction index over it.

The result is merged with the ordinary paper-sheet snap by `snap::merge_snap`,
which applies the engine's own priority-then-distance rule, in both the
cursor-move and the click paths.

`SnapResult` gains Copy fields `viewport: Option<Handle>` and
`source: Option<DimensionAssociationSource>`; the engine fills `source` from
the owning wire wherever it knows it. `AcceptedSnap::from_snap` converts a
result plus frame into the shared PR2/PR3 contract type.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-15 12:27:25 -05:00
Karim Jerbi ddeddeca31 perf(snap): optimize OSNAP cursor tracking broadphase and tangent gating (22.7x speedup)
- Implement zero-allocation InRangeWires stack buffer (up to 16 wires) to eliminate repetitive linear full-scene passes in Snapper::snap
- Add early-exit when cursor hovers whitespace (<1 µs latency)
- Add wire_in_range AABB guard to Tangent snap, cutting ~10,000 redundant 3D-to-screen matrix projections per query
- Add pairwise count guards (>= 2) to Intersection and ApparentIntersection, eliminating 120 KB of heap allocations per query in ApparentIntersection
- Add comprehensive regression tests in snap::ext_tests
- Benchmark gains:
  * Quick mode (1,000 entities): 33.98 µs -> 1.50 µs (22.7x faster, +2,024% throughput)
  * Full mode (5,000 entities): ~165.0 µs -> 7.46 µs (22.1x faster, +2,133% throughput)
2026-09-14 16:12:35 +01:00
ramox81 11057cc5e9 Fix extrusion surface properties and snapping 2026-09-10 16:07:05 +03:00
Hakan Seven 9b112e3ac0 fix: finalize reviewed drawing and interaction paths
Reset stale geometry when automation replaces a drawing and resolve material paths from its directory. Cover precise indexed snapping, large-coordinate line intersections, leader ordering, invalid image buffers and browser clipboard fallback. Preserve Options dialog resizing.

Validation: cargo test --workspace --all-features (866 passed); wasm32 application check; Node clipboard regression check; Python binding tests (3 passed).
2026-09-09 13:33:14 +03:00
Hakan Seven 973af87d58 fix: keep exact snapping, source drawing data and adaptive options layout
Resolve curve intersections through cadkernel, retain empty exact results, gather analytic candidates independently of tessellation, and bound material uploads. Preserve large MINSERT data while limiting rendering work; remove obsolete review narratives.
2026-09-09 13:17:30 +03:00
Felix RiestraandClaude Sonnet 5 78259c7aed Fix OSNAP Intersection snap using tessellated approximation
github.com/HakanSeven12/OpenCADStudio discussion #1052: constructing a
3-4-5 right triangle by drawing two circles (radius 3 and 4, centers 5
apart) and using OSNAP Intersection to find their crossing points gave
measured side lengths that didn't match the entered radii.

OSNAP's Intersection snap found candidate points by sweeping line
segments from each wire's *tessellated* polyline approximation, never
the entity's real geometry. Circles feeding the resident wire set
always tessellate at a fixed 48 segments (Scene::resident_wires_for
passes wpp=None deliberately, to avoid re-tessellating on every camera
pan/zoom) regardless of radius or zoom — so every circle/arc/ellipse
intersection snap was already off by construction, not just at extreme
zoom levels. Arcs, ellipses, and splines have the same problem via
their own fixed-angle tessellation.

Added an exact intersection path that bypasses tessellation entirely,
used by both call sites in the Intersection-snap code (the indexed/
local fast path and the brute-force wire-pair fallback), falling back
to the original tessellated sweep for anything it can't resolve:

- exact_circle_intersections: closed-form circle/circle intersection
  for any pair of Circle/Arc entities (frame-independent — each side's
  own arc sweep is checked against its own native axis, so two arcs in
  differently rotated coordinate frames still resolve correctly).
- exact_curve_intersections: a more general path for anything
  involving a line or an ellipse — embeds both entities into a shared
  working plane and dispatches to cadkernel::geom2d::intersect (an
  exact/tolerance-converged solver already vendored in this repo's own
  dependency but previously unused for this purpose). Handles a
  reflection hazard the naive version would miss: when an entity's own
  normal is anti-parallel to the shared embedding frame's normal, the
  mapping mirrors the parametrization and reverses which physical arc
  a [start, end] range refers to — both the Arc and PlanarEllipse
  branches detect this and swap start/end to compensate.

The only remaining case still going through the tessellated sweep is a
compound polyline chain with a bulge segment (not a single recognized
curve — it would need its own per-segment bookkeeping this pass
doesn't add).

12 new tests, including the reported 3-4-5 case verified against the
exact expected crossing points, arcs in differently rotated frames,
and the anti-parallel-normal reflection case for both Arc and Ellipse
(independently verified via a Python script for exact precision).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-09 10:13:30 +02:00
Karim Jerbi 0425f979f9 feat(render): GPU analytical rendering for circles, arcs, and ellipses
- Render planar circles, circular arcs, ellipses, and elliptical arcs analytically via GPU-instanced screen-space quads and WGSL shaders.
- Implement exact arc sweep clamping with round end caps matching the CAD wire shader.
- Implement robust Newton-Raphson closest-point solver for ellipses with isotropic screen-space derivative anti-aliasing.
- Integrate into wire pipeline and PersistentWireArena upload paths.
- Remove unused mesh_volume_centroid function in doc_api.
2026-09-07 13:50:12 +01:00
gianlucafiore 96b0587a83 fix(grips): restore tracking references during grip edits 2026-09-02 20:19:23 -03:00
Hakan Seven 853e830126 fix(grips): prevent phantom snapping
Keep hidden pre-drag geometry out of snap candidates and avoid empty
scene invalidations. Require stable OTRACK dwell observations and cache
planar-solid visibility during live previews.

Refs #930
2026-08-30 22:26:47 +03:00
Hakan Seven d9aead3fbc Merge pull request #856 from ramox81/codex/align-circle-behavior 2026-08-21 23:29:57 +03:00
Hakan Seven a87ca09fa4 Merge pull request #854 from ramox81/codex/align-arc-behavior 2026-08-21 21:41:24 +03:00
ramox81 390d42a63a Support planar circle tangent snapping 2026-08-21 16:49:49 +03:00
ramox81 5f9d8a9e0e Align arc creation and editing behavior 2026-08-21 14:03:58 +03:00
gianlucafiore 02e0960138 fix(snap): improve OTRACK and extension snapping 2026-08-20 18:46:44 -03:00
Hakan Seven 8016b79ddf fix(snap): align extension tracking
Require OTRACK crossings to include the active Extension ray and resolve Shift constraints consistently across preview, grips, and clicks.\n\nRefs #716
2026-08-09 23:55:06 +03:00
gianlucafiore af7613f1d8 Merge remote-tracking branch 'upstream/main' into fix/716-perpendicular-tracking 2026-08-09 11:43:08 -03:00
gianlucafiore 080a82306e Fix perpendicular and OTRACK snap interactions 2026-08-09 11:37:21 -03:00
Hakan Seven f57c258ada fix(snap): correct active intersection snapping 2026-08-09 13:27:51 +03:00
Hakan Seven 6a39b82a68 Merge pull request #712 from gianlucafiore/fix/704-active-intersection-snap
Fix active intersection snapping
2026-08-09 13:17:31 +03:00
gianlucafiore a8c9e3dd0c Merge branch 'feature/tracking-reference-tooltip' 2026-08-08 23:23:06 -03:00
gianlucafiore a06e8a7a69 Show active tracking reference tooltip 2026-08-08 23:09:06 -03:00
gianlucafiore 17b4eafa3b Merge upstream/main into fix/704-active-intersection-snap 2026-08-08 22:13:54 -03:00
gianlucafiore 15727bbffe Fix active intersection snapping 2026-08-08 21:20:40 -03:00
Hakan SevenandClaude Opus 5 b36e85e46e refactor(snap): take an entity's snap points from its curve
Each entity built its own, and what they offered had drifted apart from
what the geometry actually has:

- An arc offered no quadrants at all. It now offers the ones its sweep
  covers, and no more.
- A spline offered its control points as endpoints. For a control-point
  spline those are not on the curve, so the cursor landed in empty space
  beside the geometry. It now offers its two real ends and its midpoint,
  with the fit points — which are on the curve — still on offer.
- An elliptical arc had no midpoint and no ends.

A new SnapHint::Endpoint carries an end that cannot go in key_vertices.
Consecutive entries there are taken to be joined by a straight segment
and their midpoint offered, which is right for a line or a polyline and
wrong for anything curved: an arc's two ends would also produce a snap
out on the chord. Splines lose their key_vertices for the same reason —
the chord between two fit points of a curvy spline does not run along
it.

A polyline's midpoints and arc-segment centres stay out of snap_pts
deliberately. The engine already derives a chain's midpoints from its
vertices, and a wire carrying a centre is treated as round elsewhere,
which a polyline with one bulge in it is not.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-09 00:43:44 +03:00
Hakan Seven 1738f9a79b feat(cursor): add crosshair options
Add persistent cursor sizing, pick aperture, color, pointer mode, isometric drafting planes, and SNAPANG-aligned grid behavior.\n\nRefs #413
2026-08-08 21:32:44 +03:00
Hakan SevenandClaude Opus 5 1a753e821c refactor(snap): find both tracking directions in one pass
Perpendicular tracking arrived as a second full scan of the drawing's
segments, run next to the edge-direction scan on every acquisition. The
two ask different questions of the same segments — does this one end
here, does this one pass through here — and the scan is the expensive
part, so they now ask together and the drawing is walked once.

Two things fall out of sharing the walk. The perpendicular path picks up
the non-finite guard the edge path already had, so a NaN vertex can no
longer reach the projection. And a perpendicular is now skipped when the
edge rays already cover its direction: at a square corner one segment's
perpendicular is the other segment's own ray, and two rays down the same
line are two identical-looking things for the cursor to choose between.

Behaviour is otherwise unchanged — same tolerance, same near-parallel
dedup, same cap of six each, same skipping of round wires.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-08 00:23:53 +03:00
gianlucafiore b59fa03b53 Add perpendicular object snap tracking 2026-08-07 15:14:02 -03:00
Hakan SevenandClaude Opus 5 0af6b470ed refactor(snap): measure typed distance along the guide that is drawn
Extension answered "which acquired ray is this snap on?" twice, from two
different tests: the overlay picked its guide by off-ray distance in
screen pixels, while typed-distance entry re-searched the tracking set in
world space. Two tests can disagree, and the ways they disagree are both
bad -- a guide on screen that typing ignores, or a distance running off
along a ray the user cannot see. The second search could also come up
empty on its own, since only four acquisitions are kept and the oldest is
dropped as new ones arrive.

Ask once. The search that draws the guide now also reports the endpoint it
drew from, the snap carries it, and typed distance reads the ray straight
off that -- the direction is just the way from the endpoint to the snap,
which sits beyond it by construction. The screen-space test stays the only
one, which is what the guide wanted anyway: it stays scale-independent
where a world test would not.

Also correct the tracking-point doc: it claims XZ with Y=0, but
`edge_dirs_at` builds every direction from X/Y with Z zeroed and the rays
follow it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-07 11:29:15 +03:00
Hakan SevenandClaude Opus 5 b8f9727a27 fix(grip): stop double-offsetting the UCS grip snap marker
The extension anchors needed the same pane-to-canvas lift the snap
marker already got, but the block that added it was placed next to the
one that was already there rather than merged into it, so `screen` took
the tile origin twice. A single full-canvas tile has no origin to add, so
it only shows once the viewport is split. Fold the anchors into the
existing block.

Also require the ray to pass through the snapped point before offering it
as a distance reference. Only four acquisitions are kept and the oldest is
dropped as new ones arrive, so the ray that produced a snap can be gone by
the time a distance is typed; picking the nearest survivor unconditionally
sent the point off along an unrelated ray instead of falling back to plain
point input. `extension_snap` projects onto the ray in exact f64, so the
tolerance only has to clear rounding, scaled with the coordinate to hold at
UTM magnitudes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-07 11:22:04 +03:00