diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-01-26 14:11:53 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-01-26 14:11:53 +0300 |
commit | 26d8b598649d25cf352adab03111e623adacea48 (patch) | |
tree | 34543e721140b5ec733e12eba80d2bf9ed69111e /source/blender/editors/sculpt_paint | |
parent | 5a1603374c768d7a9c7d9cb4b05ca4098ca32537 (diff) |
Assign automatic/envelope weights in weight paint mode is back,
accessible from W key and in new Weights menu in the header.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_ops.c | 7 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 56 |
3 files changed, 63 insertions, 2 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 6bb5f432b0d..bcbc0666782 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -64,6 +64,7 @@ void paint_cursor_start(struct bContext *C, int (*poll)(struct bContext *C)); /* paint_vertex.c */ int weight_paint_poll(struct bContext *C); +int weight_paint_mode_poll(struct bContext *C); int vertex_paint_poll(struct bContext *C); int vertex_paint_mode_poll(struct bContext *C); @@ -74,6 +75,7 @@ void PAINT_OT_weight_paint_toggle(struct wmOperatorType *ot); void PAINT_OT_weight_paint_radial_control(struct wmOperatorType *ot); void PAINT_OT_weight_paint(struct wmOperatorType *ot); void PAINT_OT_weight_set(struct wmOperatorType *ot); +void PAINT_OT_weight_from_bones(struct wmOperatorType *ot); void PAINT_OT_vertex_paint_radial_control(struct wmOperatorType *ot); void PAINT_OT_vertex_paint_toggle(struct wmOperatorType *ot); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index a901b27b38f..c00b6b56072 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -127,6 +127,7 @@ void ED_operatortypes_paint(void) WM_operatortype_append(PAINT_OT_weight_paint_radial_control); WM_operatortype_append(PAINT_OT_weight_paint); WM_operatortype_append(PAINT_OT_weight_set); + WM_operatortype_append(PAINT_OT_weight_from_bones); /* vertex */ WM_operatortype_append(PAINT_OT_vertex_paint_radial_control); @@ -263,7 +264,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) /* Vertex Paint mode */ keymap= WM_keymap_find(keyconf, "Vertex Paint", 0, 0); - keymap->poll= vertex_paint_poll; + keymap->poll= vertex_paint_mode_poll; RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_vertex_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_vertex_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); @@ -281,7 +282,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) /* Weight Paint mode */ keymap= WM_keymap_find(keyconf, "Weight Paint", 0, 0); - keymap->poll= weight_paint_poll; + keymap->poll= weight_paint_mode_poll; RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); @@ -297,6 +298,8 @@ void ED_keymap_paint(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */ RNA_string_set(kmi->ptr, "path", "weight_paint_object.data.use_paint_mask"); + WM_keymap_verify_item(keymap, "PAINT_OT_weight_from_bones", WKEY, KM_PRESS, 0, 0); + /* Image/Texture Paint mode */ keymap= WM_keymap_find(keyconf, "Image Paint", 0, 0); keymap->poll= image_texture_paint_poll; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 64dbe4e4c5c..debdf4a3118 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -88,6 +88,7 @@ #include "BIF_gl.h" #include "BIF_glutil.h" +#include "ED_armature.h" #include "ED_mesh.h" #include "ED_object.h" #include "ED_screen.h" @@ -135,6 +136,13 @@ int vertex_paint_poll(bContext *C) return 0; } +int weight_paint_mode_poll(bContext *C) +{ + Object *ob = CTX_data_active_object(C); + + return ob && ob->mode == OB_MODE_WEIGHT_PAINT; +} + int weight_paint_poll(bContext *C) { Object *ob = CTX_data_active_object(C); @@ -1980,3 +1988,51 @@ void PAINT_OT_vertex_paint(wmOperatorType *ot) RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); } +/* ********************** weight from bones operator ******************* */ + +static int weight_from_bones_poll(bContext *C) +{ + Object *ob= CTX_data_active_object(C); + + return (ob && (ob->mode & OB_MODE_WEIGHT_PAINT) && modifiers_isDeformedByArmature(ob)); +} + +static int weight_from_bones_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_active_object(C); + Object *armob= modifiers_isDeformedByArmature(ob); + Mesh *me= ob->data; + int type= RNA_enum_get(op->ptr, "type"); + + create_vgroups_from_armature(scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X)); + + DAG_id_flush_update(&me->id, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_GEOM|ND_DATA, me); + + return OPERATOR_FINISHED; +} + +void PAINT_OT_weight_from_bones(wmOperatorType *ot) +{ + static EnumPropertyItem type_items[]= { + {ARM_GROUPS_AUTO, "AUTOMATIC", 0, "Automatic", "Automatic weights froms bones."}, + {ARM_GROUPS_ENVELOPE, "ENVELOPES", 0, "From Envelopes", "Weights from envelopes with user defined radius."}, + {0, NULL, 0, NULL, NULL}}; + + /* identifiers */ + ot->name= "Weight from Bones"; + ot->idname= "PAINT_OT_weight_from_bones"; + + /* api callbacks */ + ot->exec= weight_from_bones_exec; + ot->invoke= WM_menu_invoke; + ot->poll= weight_from_bones_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + ot->prop= RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "Method to use for assigning weights."); +} + |