Improve EC_CONVERGING behaviour when lines are almost collinear.
(somewhat)
This commit is contained in:
parent
98e635869f
commit
fc6279a2ea
|
@ -148,9 +148,15 @@ EC_CONVERGING::EC_CONVERGING( EDIT_LINE& aLine, EDIT_POINTS& aPoints ) :
|
|||
SEG endSide( end.GetPosition(), nextEnd.GetPosition() );
|
||||
SEG dragged( origin.GetPosition(), end.GetPosition() );
|
||||
|
||||
if( dragged.Collinear( originSide ) )
|
||||
// Used to align lines that are almost collinear
|
||||
const int alignAngle = 10;
|
||||
|
||||
m_originCollinear = dragged.Angle( originSide ).AsDegrees() < alignAngle;
|
||||
m_endCollinear = dragged.Angle( endSide ).AsDegrees() < alignAngle;
|
||||
|
||||
if( m_originCollinear )
|
||||
m_colinearConstraint = m_originSideConstraint;
|
||||
else if( dragged.Collinear( endSide ) )
|
||||
else if( m_endCollinear )
|
||||
m_colinearConstraint = m_endSideConstraint;
|
||||
}
|
||||
|
||||
|
@ -175,6 +181,9 @@ void EC_CONVERGING::Apply( EDIT_LINE& aHandle, const GRID_HELPER& aGrid )
|
|||
m_colinearConstraint->Apply( end, aGrid );
|
||||
}
|
||||
|
||||
if( m_originCollinear && m_endCollinear )
|
||||
return;
|
||||
|
||||
// The dragged segment
|
||||
SEG dragged( origin.GetPosition(), origin.GetPosition() + m_draggedVector );
|
||||
|
||||
|
|
|
@ -236,6 +236,10 @@ private:
|
|||
|
||||
///< Vector that represents the initial direction of the dragged segment.
|
||||
VECTOR2I m_draggedVector;
|
||||
|
||||
///< Flags to indicate when dragged and neighbouring lines are (almost) collinear.
|
||||
bool m_originCollinear;
|
||||
bool m_endCollinear;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue