diff options
author | Gaia Clary <gaia.clary@machinimatrix.org> | 2013-07-05 01:49:48 +0400 |
---|---|---|
committer | Gaia Clary <gaia.clary@machinimatrix.org> | 2013-07-05 01:49:48 +0400 |
commit | a07a72d93dd0dfd25c03e1deed2c65c3d35cca7e (patch) | |
tree | 215a3b27ac89858edab0c7f37d4d61dea9e15c94 /source/blender/editors | |
parent | db9f21ddd31dc373bb056ec5b5e7bb8f39582fd4 (diff) |
Added generic function to Sync pose bone with active vgroup. For use in Weight Paint and Vertex Paint
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_mesh.h | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 26 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 11 |
3 files changed, 26 insertions, 12 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 807d94b56b0..51d5d42394c 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -233,6 +233,7 @@ void ED_mesh_mirrtopo_free(MirrTopoStore_t *mesh_topo_store); #define WEIGHT_ADD 2 #define WEIGHT_SUBTRACT 3 +bool ED_vgroup_sync_from_pose(struct Object *ob); struct bDeformGroup *ED_vgroup_add(struct Object *ob); struct bDeformGroup *ED_vgroup_add_name(struct Object *ob, const char *name); void ED_vgroup_delete(struct Object *ob, struct bDeformGroup *defgroup); diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 03200e56f32..a60d48fa260 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -109,6 +109,22 @@ static Lattice *vgroup_edit_lattice(Object *ob) return (lt->editlatt) ? lt->editlatt->latt : lt; } +bool ED_vgroup_sync_from_pose(Object *ob) +{ + Object *armobj = BKE_object_pose_armature_get(ob); + if (armobj && (armobj->mode & OB_MODE_POSE)) { + struct bArmature *arm = armobj->data; + if (arm->act_bone) { + int def_num = defgroup_name_index(ob, arm->act_bone->name); + if (def_num != -1) { + ob->actdef = def_num + 1; + return true; + } + } + } + return false; +} + bool ED_vgroup_object_is_edit_mode(Object *ob) { if (ob->type == OB_MESH) @@ -3800,8 +3816,11 @@ static int vertex_group_transfer_weight_exec(bContext *C, wmOperator *op) continue; } else if (ob_src->type != OB_MESH) { - BKE_reportf(op->reports, RPT_WARNING, - "Skipping object '%s' only copying from meshes is supported", ob_src->id.name + 2); + /* armatures can be in pose mode so ignore them */ + if (ob_src->type != OB_ARMATURE) { + BKE_reportf(op->reports, RPT_WARNING, + "Skipping object '%s' only copying from meshes is supported", ob_src->id.name + 2); + } continue; } @@ -3854,6 +3873,9 @@ static int vertex_group_transfer_weight_exec(bContext *C, wmOperator *op) if (dg_act) { ED_vgroup_select_by_name(ob_act, dg_act_name); } + else { + ED_vgroup_sync_from_pose(ob_act); + } /* Event notifiers for correct display of data.*/ diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index a891524b5c6..b7bd061d14a 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -2047,8 +2047,6 @@ static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */ DAG_id_tag_update(&me->id, 0); if (ob->mode & OB_MODE_WEIGHT_PAINT) { - Object *par; - if (wp == NULL) wp = scene->toolsettings->wpaint = new_vpaint(1); @@ -2057,14 +2055,7 @@ static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */ mesh_octree_table(ob, NULL, NULL, 's'); - /* verify if active weight group is also active bone */ - par = modifiers_isDeformedByArmature(ob); - if (par && (par->mode & OB_MODE_POSE)) { - bArmature *arm = par->data; - - if (arm->act_bone) - ED_vgroup_select_by_name(ob, arm->act_bone->name); - } + ED_vgroup_sync_from_pose(ob); } else { mesh_octree_table(NULL, NULL, NULL, 'e'); |