diff options
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 32 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 9 |
2 files changed, 29 insertions, 12 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 326adefb4cc..0c0a5507594 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -3201,6 +3201,7 @@ static int paint_weight_gradient_modal(bContext *C, wmOperator *op, wmEvent *eve static int paint_weight_gradient_exec(bContext *C, wmOperator *op) { wmGesture *gesture = op->customdata; + DMGradient_vertStore *vert_cache; struct ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); @@ -3211,24 +3212,31 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) int y_end = RNA_int_get(op->ptr, "yend"); float sco_start[2] = {x_start, y_start}; float sco_end[2] = {x_end, y_end}; - + const bool is_interactive = (gesture != NULL); DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask); DMGradient_userData data = {0}; - if (gesture->userdata == NULL) { - VPaint *wp = scene->toolsettings->wpaint; + if (is_interactive) { + if (gesture->userdata == NULL) { + VPaint *wp = scene->toolsettings->wpaint; - gesture->userdata = MEM_mallocN(sizeof(DMGradient_vertStore) * me->totvert, __func__); - data.is_init = TRUE; + gesture->userdata = MEM_mallocN(sizeof(DMGradient_vertStore) * me->totvert, __func__); + data.is_init = true; - copy_wpaint_prev(wp, me->dvert, me->totvert); + copy_wpaint_prev(wp, me->dvert, me->totvert); - /* on init only, convert face -> vert sel */ - if (me->editflag & ME_EDIT_PAINT_FACE_SEL) { - BKE_mesh_flush_select_from_polys(me); + /* on init only, convert face -> vert sel */ + if (me->editflag & ME_EDIT_PAINT_FACE_SEL) { + BKE_mesh_flush_select_from_polys(me); + } } + vert_cache = gesture->userdata; + } + else { + data.is_init = true; + vert_cache = MEM_mallocN(sizeof(DMGradient_vertStore) * me->totvert, __func__); } data.ar = ar; @@ -3239,7 +3247,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) data.sco_line_div = 1.0f / len_v2v2(sco_start, sco_end); data.def_nr = ob->actdef - 1; data.use_select = (me->editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)); - data.vert_cache = gesture->userdata; + data.vert_cache = vert_cache; data.type = RNA_enum_get(op->ptr, "type"); { @@ -3255,6 +3263,10 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + if (is_interactive == false) { + MEM_freeN(vert_cache); + } + return OPERATOR_FINISHED; } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 1172f66fb1b..a720d61f9d0 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1204,8 +1204,13 @@ void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor) RNA_def_int(ot->srna, "ystart", 0, INT_MIN, INT_MAX, "Y Start", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "yend", 0, INT_MIN, INT_MAX, "Y End", "", INT_MIN, INT_MAX); - if (cursor) - RNA_def_int(ot->srna, "cursor", cursor, 0, INT_MAX, "Cursor", "Mouse cursor style to use during the modal operator", 0, INT_MAX); + if (cursor) { + PropertyRNA *prop; + + prop = RNA_def_int(ot->srna, "cursor", cursor, 0, INT_MAX, + "Cursor", "Mouse cursor style to use during the modal operator", 0, INT_MAX); + RNA_def_property_flag(prop, PROP_HIDDEN); + } } |