Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
| Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| return (ob && (ob->mode & OB_MODE_WEIGHT_PAINT) && modifiers_isDeformedByArmature(ob)); | return (ob && (ob->mode & OB_MODE_WEIGHT_PAINT) && modifiers_isDeformedByArmature(ob)); | ||||
| } | } | ||||
| static int weight_from_bones_exec(bContext *C, wmOperator *op) | static int weight_from_bones_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| Object *armob = modifiers_isDeformedByArmature(ob); | Object *armob = modifiers_isDeformedByArmature(ob); | ||||
| Mesh *me = ob->data; | Mesh *me = ob->data; | ||||
| int type = RNA_enum_get(op->ptr, "type"); | int type = RNA_enum_get(op->ptr, "type"); | ||||
| ED_object_vgroup_calc_from_armature( | ED_object_vgroup_calc_from_armature( | ||||
| op->reports, depsgraph, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X)); | op->reports, depsgraph, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X)); | ||||
| Show All 25 Lines | ot->description = | ||||
| "using the distance between the vertices and the bones"); | "using the distance between the vertices and the bones"); | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = weight_from_bones_exec; | ot->exec = weight_from_bones_exec; | ||||
| ot->invoke = WM_menu_invoke; | ot->invoke = WM_menu_invoke; | ||||
| ot->poll = weight_from_bones_poll; | ot->poll = weight_from_bones_poll; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| /* properties */ | /* properties */ | ||||
| ot->prop = RNA_def_enum( | ot->prop = RNA_def_enum( | ||||
| ot->srna, "type", type_items, 0, "Type", "Method to use for assigning weights"); | ot->srna, "type", type_items, 0, "Type", "Method to use for assigning weights"); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| ▲ Show 20 Lines • Show All 568 Lines • ▼ Show 20 Lines | static int paint_weight_gradient_exec(bContext *C, wmOperator *op) | ||||
| int x_start = RNA_int_get(op->ptr, "xstart"); | int x_start = RNA_int_get(op->ptr, "xstart"); | ||||
| int y_start = RNA_int_get(op->ptr, "ystart"); | int y_start = RNA_int_get(op->ptr, "ystart"); | ||||
| int x_end = RNA_int_get(op->ptr, "xend"); | int x_end = RNA_int_get(op->ptr, "xend"); | ||||
| int y_end = RNA_int_get(op->ptr, "yend"); | int y_end = RNA_int_get(op->ptr, "yend"); | ||||
| float sco_start[2] = {x_start, y_start}; | float sco_start[2] = {x_start, y_start}; | ||||
| float sco_end[2] = {x_end, y_end}; | float sco_end[2] = {x_end, y_end}; | ||||
| const bool is_interactive = (gesture != NULL); | const bool is_interactive = (gesture != NULL); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| WPGradient_userData data = {NULL}; | WPGradient_userData data = {NULL}; | ||||
| if (is_interactive) { | if (is_interactive) { | ||||
| if (gesture->user_data.data == NULL) { | if (gesture->user_data.data == NULL) { | ||||
| gesture->user_data.data = MEM_mallocN(sizeof(WPGradient_vertStoreBase) + | gesture->user_data.data = MEM_mallocN(sizeof(WPGradient_vertStoreBase) + | ||||
| (sizeof(WPGradient_vertStore) * me->totvert), | (sizeof(WPGradient_vertStore) * me->totvert), | ||||
| __func__); | __func__); | ||||
| ▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | void PAINT_OT_weight_gradient(wmOperatorType *ot) | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->invoke = paint_weight_gradient_invoke; | ot->invoke = paint_weight_gradient_invoke; | ||||
| ot->modal = paint_weight_gradient_modal; | ot->modal = paint_weight_gradient_modal; | ||||
| ot->exec = paint_weight_gradient_exec; | ot->exec = paint_weight_gradient_exec; | ||||
| ot->poll = weight_paint_poll_ignore_tool; | ot->poll = weight_paint_poll_ignore_tool; | ||||
| ot->cancel = WM_gesture_straightline_cancel; | ot->cancel = WM_gesture_straightline_cancel; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| prop = RNA_def_enum(ot->srna, "type", gradient_types, 0, "Type", ""); | prop = RNA_def_enum(ot->srna, "type", gradient_types, 0, "Type", ""); | ||||
| RNA_def_property_flag(prop, PROP_SKIP_SAVE); | RNA_def_property_flag(prop, PROP_SKIP_SAVE); | ||||
| WM_operator_properties_gesture_straightline(ot, CURSOR_EDIT); | WM_operator_properties_gesture_straightline(ot, CURSOR_EDIT); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||