[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58008] trunk/blender/source/blender/ editors: Added generic function to Sync pose bone with active vgroup.

Gaia Clary gaia.clary at machinimatrix.org
Thu Jul 4 23:49:48 CEST 2013


Revision: 58008
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58008
Author:   gaiaclary
Date:     2013-07-04 21:49:48 +0000 (Thu, 04 Jul 2013)
Log Message:
-----------
Added generic function to Sync pose bone with active vgroup. For use in Weight Paint and Vertex Paint

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/ED_mesh.h
    trunk/blender/source/blender/editors/object/object_vgroup.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c

Modified: trunk/blender/source/blender/editors/include/ED_mesh.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_mesh.h	2013-07-04 20:33:52 UTC (rev 58007)
+++ trunk/blender/source/blender/editors/include/ED_mesh.h	2013-07-04 21:49:48 UTC (rev 58008)
@@ -233,6 +233,7 @@
 #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);

Modified: trunk/blender/source/blender/editors/object/object_vgroup.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_vgroup.c	2013-07-04 20:33:52 UTC (rev 58007)
+++ trunk/blender/source/blender/editors/object/object_vgroup.c	2013-07-04 21:49:48 UTC (rev 58008)
@@ -109,6 +109,22 @@
 	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 @@
 				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 @@
 		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.*/
 

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c	2013-07-04 20:33:52 UTC (rev 58007)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c	2013-07-04 21:49:48 UTC (rev 58008)
@@ -2047,8 +2047,6 @@
 	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 @@
 		
 		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');




More information about the Bf-blender-cvs mailing list