[Bf-blender-cvs] [4beddbb] wiggly-widgets: Add option to only draw face map of bone

Julian Eisel noreply at git.blender.org
Sun Nov 15 21:33:15 CET 2015


Commit: 4beddbb9ed5044ab8b6f8672678374c8974d8ea1
Author: Julian Eisel
Date:   Sun Nov 15 21:03:19 2015 +0100
Branches: wiggly-widgets
https://developer.blender.org/rB4beddbb9ed5044ab8b6f8672678374c8974d8ea1

Add option to only draw face map of bone

Option 'Face Map Only' is added to bone 'Display' panel. If enabled, the bone (or the custom shape for it) is not drawn in pose mode. Only its face map is drawn (which again is drawn on mouse hover only).

===================================================================

M	release/scripts/startup/bl_ui/properties_data_bone.py
M	source/blender/editors/space_view3d/drawarmature.c
M	source/blender/makesdna/DNA_armature_types.h
M	source/blender/makesrna/intern/rna_armature.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_data_bone.py b/release/scripts/startup/bl_ui/properties_data_bone.py
index 724e495..cd0c6d9 100644
--- a/release/scripts/startup/bl_ui/properties_data_bone.py
+++ b/release/scripts/startup/bl_ui/properties_data_bone.py
@@ -247,6 +247,9 @@ class BONE_PT_display(BoneButtonsPanel, Panel):
             col = split.column()
             col.prop(bone, "hide", text="Hide")
             sub = col.column()
+            sub.active = bool(pchan and pchan.facemap)
+            sub.prop(bone, "fmap_only")
+            sub = col.column()
             sub.active = bool(pchan and pchan.custom_shape)
             sub.prop(bone, "show_wire", text="Wireframe")
 
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index 02a5352..6d54b52 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -1651,6 +1651,13 @@ static void bone_matrix_translate_y(float mat[4][4], float y)
 	add_v3_v3(mat[3], trans);
 }
 
+BLI_INLINE bool pchan_is_draw_fmap_only(const Scene *scene, const bPoseChannel *pchan)
+{
+	return ((scene->basact->object->mode & OB_MODE_POSE) &&
+	        (pchan->fmap != NULL) &&
+	        (pchan->bone->flag & BONE_DRAW_FMAP_ONLY));
+}
+
 /* assumes object is Armature with pose */
 static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
                             const short dt, const unsigned char ob_wire_col[4],
@@ -1733,8 +1740,11 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
 			bone = pchan->bone;
 			arm->layer_used |= bone->layer;
 			
-			/* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194] */
+			/* 1) bone must be visible
+			 * 2) drawing is not limited to face maps only
+			 * 3) for OpenGL select-drawing cannot have unselectable [#27194] */
 			if (((bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0) &&
+			    (!pchan_is_draw_fmap_only(scene, pchan)) &&
 			    ((G.f & G_PICKSEL) == 0 || (bone->flag & BONE_UNSELECTABLE) == 0))
 			{
 				if (bone->layer & arm->layer) {
@@ -1835,8 +1845,11 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
 		for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
 			bone = pchan->bone;
 			
-			/* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194] */
+			/* 1) bone must be visible
+			 * 2) drawing is not limited to face maps only
+			 * 3) for OpenGL select-drawing cannot have unselectable [#27194] */
 			if (((bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0) &&
+			    (!pchan_is_draw_fmap_only(scene, pchan)) &&
 			    ((G.f & G_PICKSEL) == 0 || (bone->flag & BONE_UNSELECTABLE) == 0) )
 			{
 				if (bone->layer & arm->layer) {
@@ -1916,8 +1929,11 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
 			bone = pchan->bone;
 			arm->layer_used |= bone->layer;
 			
-			/* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194] */
+			/* 1) bone must be visible
+			 * 2) drawing is not limited to face maps only
+			 * 3) for OpenGL select-drawing cannot have unselectable [#27194] */
 			if (((bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0) &&
+			    (!pchan_is_draw_fmap_only(scene, pchan)) &&
 			    ((G.f & G_PICKSEL) == 0 || (bone->flag & BONE_UNSELECTABLE) == 0))
 			{
 				if (bone->layer & arm->layer) {
@@ -2054,7 +2070,11 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
 			if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
 			
 			for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
-				if ((pchan->bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0) {
+				/* 1) bone must be visible
+				 * 2) drawing is not limited to face maps only */
+				if ((pchan->bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0 &&
+				    (!pchan_is_draw_fmap_only(scene, pchan)))
+				{
 					if (pchan->bone->layer & arm->layer) {
 						if (arm->flag & (ARM_EDITMODE | ARM_POSEMODE)) {
 							bone = pchan->bone;
diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h
index 18b6bdf..1c1a531 100644
--- a/source/blender/makesdna/DNA_armature_types.h
+++ b/source/blender/makesdna/DNA_armature_types.h
@@ -205,8 +205,8 @@ typedef enum eBone_Flag {
 	BONE_TRANSFORM_CHILD        = (1 << 20),  /* Indicates that a parent is also being transformed */
 	BONE_UNSELECTABLE           = (1 << 21),  /* bone cannot be selected */
 	BONE_NO_LOCAL_LOCATION      = (1 << 22),  /* bone location is in armature space */
-	BONE_RELATIVE_PARENTING     = (1 << 23)   /* object child will use relative transform (like deform) */
-	
+	BONE_RELATIVE_PARENTING     = (1 << 23),  /* object child will use relative transform (like deform) */
+	BONE_DRAW_FMAP_ONLY         = (1 << 24),  /* don't draw bone itself in pose mode, only its facemap */
 } eBone_Flag;
 
 #define MAXBONENAME 64
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index a8ef466..5116f7d 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -662,6 +662,12 @@ static void rna_def_bone(BlenderRNA *brna)
 	                         "Bone is not visible when it is not in Edit Mode (i.e. in Object or Pose Modes)");
 	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
 
+	prop = RNA_def_property(srna, "fmap_only", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_DRAW_FMAP_ONLY);
+	RNA_def_property_ui_text(prop, "Face Map Only", "Draw only the facemap of the bone in Pose Mode "
+	                         "(Face Map needs to be assigned)");
+	RNA_def_property_update(prop, 0, "rna_Armature_redraw_data");
+
 	prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_SELECTED);
 	RNA_def_property_ui_text(prop, "Select", "");




More information about the Bf-blender-cvs mailing list