forked from bartvdbraak/blender
Fix adding to paint-curves from the first point
- add_index now works when selecting the first point. - sliding now selects the correct handle.
This commit is contained in:
parent
176ed5bfe2
commit
890e533c76
@ -120,6 +120,7 @@ void BKE_paint_brush_set(struct Paint *paint, struct Brush *br);
|
||||
struct Palette *BKE_paint_palette(struct Paint *paint);
|
||||
void BKE_paint_palette_set(struct Paint *p, struct Palette *palette);
|
||||
void BKE_paint_curve_set(struct Brush *br, struct PaintCurve *pc);
|
||||
void BKE_paint_curve_clamp_endpoint_add_index(struct PaintCurve *pc, const int add_index);
|
||||
|
||||
void BKE_paint_data_warning(struct ReportList *reports, bool uvs, bool mat, bool tex, bool stencil);
|
||||
bool BKE_paint_proj_mesh_data_check(struct Scene *scene, struct Object *ob, bool *uvs, bool *mat, bool *tex, bool *stencil);
|
||||
|
@ -313,6 +313,11 @@ void BKE_paint_curve_set(Brush *br, PaintCurve *pc)
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_paint_curve_clamp_endpoint_add_index(PaintCurve *pc, const int add_index)
|
||||
{
|
||||
pc->add_index = (add_index || pc->tot_points == 1) ? (add_index + 1) : 0;
|
||||
}
|
||||
|
||||
/* remove colour from palette. Must be certain color is inside the palette! */
|
||||
void BKE_palette_color_remove(Palette *palette, PaletteColor *color)
|
||||
{
|
||||
|
@ -222,6 +222,28 @@ static int paintcurve_point_co_index(char sel)
|
||||
return i;
|
||||
}
|
||||
|
||||
static char paintcurve_point_side_index(const BezTriple *bezt, const bool is_first, const char fallback)
|
||||
{
|
||||
/* when matching, guess based on endpoint side */
|
||||
if (BEZSELECTED(bezt)) {
|
||||
if ((bezt->f1 & SELECT) == (bezt->f3 & SELECT)) {
|
||||
return is_first ? SEL_F1 : SEL_F3;
|
||||
}
|
||||
else if (bezt->f1 & SELECT) {
|
||||
return SEL_F1;
|
||||
}
|
||||
else if (bezt->f3 & SELECT) {
|
||||
return SEL_F3;
|
||||
}
|
||||
else {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/******************* Operators *********************************/
|
||||
|
||||
static int paintcurve_new_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
@ -295,10 +317,17 @@ static void paintcurve_point_add(bContext *C, wmOperator *op, const int loc[2])
|
||||
for (i = 0; i < pc->tot_points; i++) {
|
||||
pcp[i].bez.f1 = pcp[i].bez.f2 = pcp[i].bez.f3 = 0;
|
||||
}
|
||||
|
||||
BKE_paint_curve_clamp_endpoint_add_index(pc, add_index);
|
||||
|
||||
if (pc->add_index != 0) {
|
||||
pcp[add_index].bez.f3 = SELECT;
|
||||
pcp[add_index].bez.h2 = HD_ALIGN;
|
||||
|
||||
pc->add_index = add_index + 1;
|
||||
}
|
||||
else {
|
||||
pcp[add_index].bez.f1 = SELECT;
|
||||
pcp[add_index].bez.h1 = HD_ALIGN;
|
||||
}
|
||||
|
||||
WM_paint_cursor_tag_redraw(window, ar);
|
||||
}
|
||||
@ -384,7 +413,7 @@ static int paintcurve_delete_point_exec(bContext *C, wmOperator *op)
|
||||
points_new[j] = pc->points[i];
|
||||
|
||||
if ((i + 1) == pc->add_index) {
|
||||
pc->add_index = j + 1;
|
||||
BKE_paint_curve_clamp_endpoint_add_index(pc, j);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
@ -469,7 +498,7 @@ static bool paintcurve_point_select(bContext *C, wmOperator *op, const int loc[2
|
||||
pcp = paintcurve_point_get_closest(pc, loc_fl, false, PAINT_CURVE_SELECT_THRESHOLD, &selflag);
|
||||
|
||||
if (pcp) {
|
||||
pc->add_index = (pcp - pc->points) + 1;
|
||||
BKE_paint_curve_clamp_endpoint_add_index(pc, pcp - pc->points);
|
||||
|
||||
if (selflag == SEL_F2) {
|
||||
if (extend)
|
||||
@ -599,9 +628,8 @@ static int paintcurve_slide_invoke(bContext *C, wmOperator *op, const wmEvent *e
|
||||
pcp = NULL;
|
||||
/* just find first selected point */
|
||||
for (i = 0; i < pc->tot_points; i++) {
|
||||
if (pc->points[i].bez.f1 || pc->points[i].bez.f2 || pc->points[i].bez.f3) {
|
||||
if ((select = paintcurve_point_side_index(&pc->points[i].bez, i == 0, SEL_F3))) {
|
||||
pcp = &pc->points[i];
|
||||
select = SEL_F3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -631,7 +659,7 @@ static int paintcurve_slide_invoke(bContext *C, wmOperator *op, const wmEvent *e
|
||||
|
||||
/* only select the active point */
|
||||
PAINT_CURVE_POINT_SELECT(pcp, psd->select);
|
||||
pc->add_index = (pcp - pc->points) + 1;
|
||||
BKE_paint_curve_clamp_endpoint_add_index(pc, pcp - pc->points);
|
||||
|
||||
WM_event_add_modal_handler(C, op);
|
||||
WM_paint_cursor_tag_redraw(window, ar);
|
||||
|
Loading…
Reference in New Issue
Block a user