//if distanceMin is used, we need to add additional point
            protected bool AddLastPointIfNeeded(List <Vector3> positions, BGCurveBaseMath.SectionInfo section,
                                                BGCurveBaseMath.SectionPointInfo currentPoint, BGCurveBaseMath.SectionPointInfo previousPoint, List <BGCcSplitterPolyline.PolylinePoint> points)
            {
                var currentPointDistance = currentPoint.DistanceToSectionStart + section.DistanceFromStartToOrigin;

                if (!(currentPointDistance > DistanceMax))
                {
                    return(false);
                }

                //there are 2 options: 1) prev point is in the list 2) prevpoint=previousPoint
                //we can determine it by sqrMagnitude
                var lastPointInTheListMagnitude = Vector3.SqrMagnitude(positions[positions.Count - 1] - currentPoint.Position);
                var prevPointMagnitude          = Vector3.SqrMagnitude(previousPoint.Position - currentPoint.Position);

                if (lastPointInTheListMagnitude > prevPointMagnitude)
                {
                    var distanceToAdd = currentPointDistance - DistanceMax;
                    LastPointAdded = true;
                    var ratio = distanceToAdd / (currentPoint.DistanceToSectionStart - previousPoint.DistanceToSectionStart);
                    Add(section, positions, points, previousPoint, currentPoint, ratio);
//                    positions.Add(Vector3.Lerp(previousPoint.Position, currentPoint.Position, ratio));
                }
                else
                {
                    var distanceToLastPoint = Mathf.Sqrt(lastPointInTheListMagnitude);
                    var distanceToMaxPoint  = currentPointDistance - DistanceMax;
                    var ratio = 1 - distanceToMaxPoint / distanceToLastPoint;
                    Add(section, positions, points, points[positions.Count - 1], currentPoint, ratio);
//                    positions.Add(Vector3.Lerp(positions[positions.Count - 1], currentPoint.Position, ratio));
                }

                return(true);
            }
            //add position and point
            private void Add(BGCurveBaseMath.SectionInfo section, List <Vector3> positions, List <BGCcSplitterPolyline.PolylinePoint> points, BGCurveBaseMath.SectionPointInfo previousPoint,
                             BGCurveBaseMath.SectionPointInfo nextPoint, float ratio)
            {
                var pos = Vector3.Lerp(previousPoint.Position, nextPoint.Position, ratio);

                positions.Add(pos);
                points.Add(new BGCcSplitterPolyline.PolylinePoint(
                               pos,
                               section.DistanceFromStartToOrigin + Mathf.Lerp(previousPoint.DistanceToSectionStart, nextPoint.DistanceToSectionStart, ratio),
                               calculatingTangents ? Vector3.Lerp(previousPoint.Tangent, nextPoint.Tangent, ratio) : Vector3.zero
                               ));
            }
            //if distanceMin is used, we need to add additional point
            protected void AddFirstPointIfNeeded(List <Vector3> positions, BGCurveBaseMath.SectionInfo section,
                                                 BGCurveBaseMath.SectionPointInfo firstPointInRange, BGCurveBaseMath.SectionPointInfo previousPoint, List <BGCcSplitterPolyline.PolylinePoint> points)
            {
                var firstPointDistance = firstPointInRange.DistanceToSectionStart + section.DistanceFromStartToOrigin;
                var distanceToAdd      = firstPointDistance - DistanceMin;

                if (!(distanceToAdd > BGCurve.Epsilon))
                {
                    return;
                }

                var ratio = 1 - distanceToAdd / (firstPointInRange.DistanceToSectionStart - previousPoint.DistanceToSectionStart);

                Add(section, positions, points, previousPoint, firstPointInRange, ratio);
            }
            //if distanceMin is used, we need to add additional point
            protected void AddFirstPointIfNeeded(List <Vector3> positions, BGCurveBaseMath.SectionInfo section,
                                                 BGCurveBaseMath.SectionPointInfo firstPointInRange, BGCurveBaseMath.SectionPointInfo previousPoint)
            {
                var firstPointDistance = firstPointInRange.DistanceToSectionStart + section.DistanceFromStartToOrigin;
                var distanceToAdd      = firstPointDistance - DistanceMin;

                if (!(distanceToAdd > BGCurve.Epsilon))
                {
                    return;
                }

                var ratio = 1 - distanceToAdd / (firstPointInRange.DistanceToSectionStart - previousPoint.DistanceToSectionStart);

                positions.Add(Vector3.Lerp(previousPoint.Position, firstPointInRange.Position, ratio));
            }