forked from 1b-agent/opencadstudio-upstream
feat(draw): LINE deferred tangent — a line tangent to two circles
A line whose FIRST point is a Tangent snap on a circle can't be fixed until its direction is known, and a line tangent to TWO circles is their common tangent — neither is resolvable at a single pick. A plain LINE dropped the tangent object, so it drew a wrong line (TAN-TAN between two circles). Add an opt-in on_point_with_tangent hook (default ignores the tangent, so every other command is byte-for-byte unchanged) and route the running Tangent object through the point commit. LINE defers a first-point circle tangent and resolves it on the next pick: against a second circle tangent it picks the common tangent of the two circles (up to four — chosen by the two cursor hits, so hovering selects inner/outer + side); against a plain point it draws the tangent from that point to the circle. last_point syncs to the resolved anchor. Common-tangent and point-tangent math is f64 with perpendicularity unit tests. Refs #274 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
2da21146c4
commit
e366e47b05
3 files changed
+223
-4
No files matched your search
@@ -692,6 +692,29 @@ pub trait CadCommand: Send {
|
||||
self.on_point(hit)
|
||||
}
|
||||
|
||||
/// Commit a picked point that may carry a running Tangent-snap reference
|
||||
/// (the object under the cursor when Tangent won). The default ignores the
|
||||
/// tangent, so only commands that opt in see it — LINE uses it to resolve a
|
||||
/// deferred tangent-to-tangent line between two circles, which needs both
|
||||
/// objects and so can't be computed at a single pick. Returning `None`
|
||||
/// means "not handled — fall back to `on_point`". (#274)
|
||||
fn on_point_with_tangent(
|
||||
&mut self,
|
||||
_pt: DVec3,
|
||||
_tangent: Option<TangentObject>,
|
||||
) -> Option<CmdResult> {
|
||||
None
|
||||
}
|
||||
|
||||
/// The command's current anchor (rubber-band origin) after a commit, so the
|
||||
/// host can sync `last_point` when the command replaced the picked
|
||||
/// coordinate — e.g. LINE resolving a deferred tangent to the true tangent
|
||||
/// point. `None` keeps the picked point. Only consulted after
|
||||
/// `on_point_with_tangent` handled the pick. (#274)
|
||||
fn resolved_anchor(&self) -> Option<DVec3> {
|
||||
None
|
||||
}
|
||||
|
||||
/// When true, `update.rs` injects the picked entity before calling
|
||||
/// `on_entity_pick` (required when the pick handler reads injected state).
|
||||
fn inject_before_entity_pick(&self) -> bool {
|
||||
|
||||
Reference in new issue
Block a user