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/object/object_vgroup.c | |
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/object/object_vgroup.c')
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 26 |
1 files changed, 24 insertions, 2 deletions
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.*/ |