@@ -38,7 +38,6 @@ use crate::front::ObjectId;
3838use crate :: parsing:: ast:: types:: TagNode ;
3939use crate :: std:: Args ;
4040use crate :: std:: CircularDirection ;
41- use crate :: std:: DEFAULT_TOLERANCE_MM ;
4241use crate :: std:: args:: FromKclValue ;
4342use crate :: std:: args:: TyF64 ;
4443use crate :: std:: sketch:: StraightLineParams ;
@@ -52,6 +51,8 @@ use crate::std::utils::untype_point;
5251use crate :: std:: utils:: untyped_point_to_mm;
5352use crate :: std_utils:: untyped_point_to_unit;
5453
54+ pub const SOLVER_CONVERGENCE_TOLERANCE : f64 = 1e-8 ;
55+
5556/// Create the Sketch and send to the engine. Return will be None if there are
5657/// no segments.
5758pub ( crate ) async fn create_segments_in_engine (
@@ -104,9 +105,9 @@ pub(crate) async fn create_segments_in_engine(
104105 let entry_point = match & segment. kind {
105106 SegmentKind :: Line { end, .. } | SegmentKind :: Arc { end, .. } => {
106107 let reverse_start_mm = point_to_mm ( end. clone ( ) ) ;
107- if distance ( forward_start_mm, current_pen_mm) <= DEFAULT_TOLERANCE_MM {
108+ if distance ( forward_start_mm, current_pen_mm) <= SOLVER_CONVERGENCE_TOLERANCE {
108109 forward_start. clone ( )
109- } else if distance ( reverse_start_mm, current_pen_mm) <= DEFAULT_TOLERANCE_MM {
110+ } else if distance ( reverse_start_mm, current_pen_mm) <= SOLVER_CONVERGENCE_TOLERANCE {
110111 traversal = SegmentTraversal :: Reverse ;
111112 end. clone ( )
112113 } else {
@@ -120,7 +121,7 @@ pub(crate) async fn create_segments_in_engine(
120121
121122 // If the next segment already starts where the pen is, preserve continuity by
122123 // skipping both the engine pen move and the synthetic bookkeeping jump.
123- if distance ( entry_point_mm, current_pen_mm) > DEFAULT_TOLERANCE_MM {
124+ if distance ( entry_point_mm, current_pen_mm) > SOLVER_CONVERGENCE_TOLERANCE {
124125 let id = exec_state. next_uuid ( ) ;
125126 if !exec_state. sketch_mode ( ) {
126127 exec_state
@@ -190,13 +191,10 @@ pub(crate) async fn create_segments_in_engine(
190191 debug_assert ! ( false , "Points should have been skipped earlier" ) ;
191192 continue ;
192193 }
193- SegmentKind :: Line { end, .. } => {
194+ SegmentKind :: Line { end, start , .. } => {
194195 let to = match traversal {
195196 SegmentTraversal :: Forward => end. clone ( ) ,
196- SegmentTraversal :: Reverse => match & segment. kind {
197- SegmentKind :: Line { start, .. } => start. clone ( ) ,
198- _ => unreachable ! ( "line traversal only used for line segments" ) ,
199- } ,
197+ SegmentTraversal :: Reverse => start. clone ( ) ,
200198 } ;
201199 let sketch = straight_line (
202200 segment. id ,
0 commit comments