Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_curve.c
| Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | |||||
| #define SEL_F3 (1 << 2) | #define SEL_F3 (1 << 2) | ||||
| /* returns 0, 1, or 2 in point according to handle 1, pivot or handle 2 */ | /* returns 0, 1, or 2 in point according to handle 1, pivot or handle 2 */ | ||||
| static PaintCurvePoint *paintcurve_point_get_closest( | static PaintCurvePoint *paintcurve_point_get_closest( | ||||
| PaintCurve *pc, const float pos[2], bool ignore_pivot, const float threshold, char *point) | PaintCurve *pc, const float pos[2], bool ignore_pivot, const float threshold, char *point) | ||||
| { | { | ||||
| PaintCurvePoint *pcp, *closest = NULL; | PaintCurvePoint *pcp, *closest = NULL; | ||||
| int i; | int i; | ||||
| float dist, closest_dist = FLT_MAX; | float closest_dist = threshold; | ||||
| for (i = 0, pcp = pc->points; i < pc->tot_points; i++, pcp++) { | for (i = 0, pcp = pc->points; i < pc->tot_points; i++, pcp++) { | ||||
| dist = len_manhattan_v2v2(pos, pcp->bez.vec[0]); | float dist[3]; | ||||
| if (dist < threshold) { | char point_sel = 0; | ||||
| if (dist < closest_dist) { | |||||
| closest = pcp; | dist[0] = len_manhattan_v2v2(pos, pcp->bez.vec[0]); | ||||
| closest_dist = dist; | dist[1] = len_manhattan_v2v2(pos, pcp->bez.vec[1]); | ||||
| if (point) { | dist[2] = len_manhattan_v2v2(pos, pcp->bez.vec[2]); | ||||
| *point = SEL_F1; | |||||
| } | if (dist[1] < closest_dist) { | ||||
| } | closest_dist = dist[1]; | ||||
| } | point_sel = SEL_F2; | ||||
| if (!ignore_pivot) { | } | ||||
| dist = len_manhattan_v2v2(pos, pcp->bez.vec[1]); | if (dist[0] < closest_dist) { | ||||
| if (dist < threshold) { | closest_dist = dist[0]; | ||||
| if (dist < closest_dist) { | point_sel = SEL_F1; | ||||
| closest = pcp; | } | ||||
| closest_dist = dist; | if (dist[2] < closest_dist) { | ||||
| if (point) { | closest_dist = dist[2]; | ||||
| *point = SEL_F2; | point_sel = SEL_F3; | ||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| dist = len_manhattan_v2v2(pos, pcp->bez.vec[2]); | if (point_sel) { | ||||
| if (dist < threshold) { | |||||
| if (dist < closest_dist) { | |||||
| closest = pcp; | closest = pcp; | ||||
| closest_dist = dist; | |||||
| if (point) { | if (point) { | ||||
| *point = SEL_F3; | if (ignore_pivot && point_sel == SEL_F2) { | ||||
| point_sel = (dist[0] < dist[2]) ? SEL_F1 : SEL_F3; | |||||
| } | } | ||||
| *point = point_sel; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return closest; | return closest; | ||||
| } | } | ||||
| static int paintcurve_point_co_index(char sel) | static int paintcurve_point_co_index(char sel) | ||||
| ▲ Show 20 Lines • Show All 639 Lines • Show Last 20 Lines | |||||