[Bf-blender-cvs] [61a24c799b2] blender2.8: Move B-Bone custom handle settings to Edit mode.

Alexander Gavrilov noreply at git.blender.org
Thu Oct 4 18:55:59 CEST 2018


Commit: 61a24c799b2882c22a43591138a113d7f09be0ed
Author: Alexander Gavrilov
Date:   Sun Aug 5 18:48:05 2018 +0300
Branches: blender2.8
https://developer.blender.org/rB61a24c799b2882c22a43591138a113d7f09be0ed

Move B-Bone custom handle settings to Edit mode.

Custom handle settings actually affect the B-Bone rest shape,
so they should be changed in Edit mode rather than Pose mode.
This is necessary to be able to display the correct rest shape
of the bone in Edit Mode.

Also, instead of flags, introduce an enum to specify the handle
operation modes, so that new ones could be added later.

Differential Revision: https://developer.blender.org/D3588

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

M	release/scripts/startup/bl_ui/properties_data_bone.py
M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenkernel/intern/action.c
M	source/blender/blenkernel/intern/armature.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/editors/armature/armature_add.c
M	source/blender/editors/armature/armature_intern.h
M	source/blender/editors/armature/armature_utils.c
M	source/blender/editors/armature/editarmature_retarget.c
M	source/blender/editors/include/ED_armature.h
M	source/blender/makesdna/DNA_action_types.h
M	source/blender/makesdna/DNA_armature_types.h
M	source/blender/makesrna/intern/rna_armature.c
M	source/blender/makesrna/intern/rna_pose.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_bone.py b/release/scripts/startup/bl_ui/properties_data_bone.py
index 3fc0c66b0b4..bdee55666fd 100644
--- a/release/scripts/startup/bl_ui/properties_data_bone.py
+++ b/release/scripts/startup/bl_ui/properties_data_bone.py
@@ -130,6 +130,7 @@ class BONE_PT_curved(BoneButtonsPanel, Panel):
         bone = context.bone
         # arm = context.armature
         pchan = None
+        edit = False
 
         if ob and bone:
             pchan = ob.pose.bones[bone.name]
@@ -137,6 +138,7 @@ class BONE_PT_curved(BoneButtonsPanel, Panel):
         elif bone is None:
             bone = context.edit_bone
             bbone = bone
+            edit = True
         else:
             bbone = bone
 
@@ -169,24 +171,27 @@ class BONE_PT_curved(BoneButtonsPanel, Panel):
         col.prop(bbone, "bbone_easein", text="Ease In")
         col.prop(bbone, "bbone_easeout", text="Out")
 
-        if pchan:
-            topcol.separator()
-
-            col = topcol.column()
-            col.use_property_split = False
-            col.prop(pchan, "use_bbone_custom_handles")
+        col = topcol.column(align=True)
+        col.prop(bone, "bbone_handle_type_start", text="Start Handle")
 
-            col = topcol.column(align=True)
-            col.active = pchan.use_bbone_custom_handles
-            col.use_property_split = True
+        col = col.column(align=True)
+        col.active = (bone.bbone_handle_type_start != "AUTO")
+        if edit:
+            col.prop_search(bone, "bbone_custom_handle_start", ob.data, "edit_bones", text="Custom")
+        else:
+            # read-only
+            col.prop(bbone, "bbone_custom_handle_start", text="Custom")
 
-            sub = col.column()
-            sub.prop_search(pchan, "bbone_custom_handle_start", ob.pose, "bones", text="Custom Handle Start")
-            sub.prop_search(pchan, "bbone_custom_handle_end", ob.pose, "bones", text="End")
+        col = topcol.column(align=True)
+        col.prop(bone, "bbone_handle_type_end", text="End Handle")
 
-            sub = col.column(align=True)
-            sub.prop(pchan, "use_bbone_relative_start_handle", text="Relative Handle Start")
-            sub.prop(pchan, "use_bbone_relative_end_handle", text="End")
+        col = col.column(align=True)
+        col.active = (bone.bbone_handle_type_end != "AUTO")
+        if edit:
+            col.prop_search(bone, "bbone_custom_handle_end", ob.data, "edit_bones", text="Custom")
+        else:
+            # read-only
+            col.prop(bbone, "bbone_custom_handle_end", text="Custom")
 
 
 class BONE_PT_relations(BoneButtonsPanel, Panel):
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 7ac59d6c9d4..84451fe31d4 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -28,7 +28,7 @@
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         280
-#define BLENDER_SUBVERSION      24
+#define BLENDER_SUBVERSION      25
 /* Several breakages with 280, e.g. collections vs layers */
 #define BLENDER_MINVERSION      280
 #define BLENDER_MINSUBVERSION   0
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 9c407d27c29..68029ea72f6 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -887,7 +887,6 @@ void BKE_pose_channel_copy_data(bPoseChannel *pchan, const bPoseChannel *pchan_f
 	pchan->iklinweight = pchan_from->iklinweight;
 
 	/* bbone settings (typically not animated) */
-	pchan->bboneflag = pchan_from->bboneflag;
 	pchan->bbone_next = pchan_from->bbone_next;
 	pchan->bbone_prev = pchan_from->bbone_prev;
 
@@ -1356,7 +1355,6 @@ void BKE_pose_copyesult_pchan_result(bPoseChannel *pchanto, const bPoseChannel *
 	pchanto->rotmode = pchanfrom->rotmode;
 	pchanto->flag = pchanfrom->flag;
 	pchanto->protectflag = pchanfrom->protectflag;
-	pchanto->bboneflag = pchanfrom->bboneflag;
 }
 
 /* both poses should be in sync */
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index e2a41f46e69..61472068399 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -433,23 +433,31 @@ void equalize_bbone_bezier(float *data, int desired)
 	copy_qt_qt(fp, temp[MAX_BBONE_SUBDIV]);
 }
 
-/* get "next" and "prev" bones - these are used for handle calculations */
+/* Get "next" and "prev" bones - these are used for handle calculations. */
 void BKE_pchan_get_bbone_handles(bPoseChannel *pchan, bPoseChannel **r_prev, bPoseChannel **r_next)
 {
-	if (pchan->bboneflag & PCHAN_BBONE_CUSTOM_HANDLES) {
-		/* use the provided bones as the next/prev - leave blank to eliminate this effect altogether */
-		*r_prev = pchan->bbone_prev;
-		*r_next = pchan->bbone_next;
-	}
-	else {
-		/* evaluate next and prev bones */
-		if (pchan->bone->flag & BONE_CONNECTED)
+	if (pchan->bone->bbone_prev_type == BBONE_HANDLE_AUTO) {
+		/* Use connected parent. */
+		if (pchan->bone->flag & BONE_CONNECTED) {
 			*r_prev = pchan->parent;
-		else
+		}
+		else {
 			*r_prev = NULL;
+		}
+	}
+	else {
+		/* Use the provided bone as prev - leave blank to eliminate this effect altogether. */
+		*r_prev = pchan->bbone_prev;
+	}
 
+	if (pchan->bone->bbone_next_type == BBONE_HANDLE_AUTO) {
+		/* Use connected child. */
 		*r_next = pchan->child;
 	}
+	else {
+		/* Use the provided bone as next - leave blank to eliminate this effect altogether. */
+		*r_next = pchan->bbone_next;
+	}
 }
 
 /* returns pointer to static array, filled with desired amount of bone->segments elements */
@@ -499,8 +507,7 @@ void b_bone_spline_setup(bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BB
 		float difmat[4][4], result[3][3], imat3[3][3];
 
 		/* transform previous point inside this bone space */
-		if ((pchan->bboneflag & PCHAN_BBONE_CUSTOM_HANDLES) &&
-		    (pchan->bboneflag & PCHAN_BBONE_CUSTOM_START_REL))
+		if (bone->bbone_prev_type == BBONE_HANDLE_RELATIVE)
 		{
 			/* Use delta movement (from restpose), and apply this relative to the current bone's head */
 			if (rest) {
@@ -555,8 +562,7 @@ void b_bone_spline_setup(bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BB
 		float difmat[4][4], result[3][3], imat3[3][3];
 
 		/* transform next point inside this bone space */
-		if ((pchan->bboneflag & PCHAN_BBONE_CUSTOM_HANDLES) &&
-		    (pchan->bboneflag & PCHAN_BBONE_CUSTOM_END_REL))
+		if (bone->bbone_next_type == BBONE_HANDLE_RELATIVE)
 		{
 			/* Use delta movement (from restpose), and apply this relative to the current bone's tail */
 			if (rest) {
@@ -2019,6 +2025,22 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_
 			BKE_pose_channels_hash_free(pose);
 			BLI_freelinkN(&pose->chanbase, pchan);
 		}
+		else {
+			/* Find the custom B-Bone handles. */
+			if (pchan->bone->bbone_prev) {
+				pchan->bbone_prev = BKE_pose_channel_find_name(pose, pchan->bone->bbone_prev->name);
+			}
+			else {
+				pchan->bbone_prev = NULL;
+			}
+
+			if (pchan->bone->bbone_next) {
+				pchan->bbone_next = BKE_pose_channel_find_name(pose, pchan->bone->bbone_next->name);
+			}
+			else {
+				pchan->bbone_next = NULL;
+			}
+		}
 	}
 	/* printf("rebuild pose %s, %d bones\n", ob->id.name, counter); */
 
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 005e2c62b85..275d14dbca3 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3546,7 +3546,7 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose)
 	bool rebuild = false;
 
 	if (fd->memfile == NULL) {
-		if (ob->proxy || (ob->id.lib==NULL && arm->id.lib)) {
+		if (ob->proxy || ob->id.lib != arm->id.lib) {
 			rebuild = true;
 		}
 	}
@@ -3628,6 +3628,9 @@ static void direct_link_bones(FileData *fd, Bone *bone)
 	bone->prop = newdataadr(fd, bone->prop);
 	IDP_DirectLinkGroup_OrFree(&bone->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
 
+	bone->bbone_next = newdataadr(fd, bone->bbone_next);
+	bone->bbone_prev = newdataadr(fd, bone->bbone_prev);
+
 	bone->flag &= ~BONE_DRAW_ACTIVE;
 
 	link_list(fd, &bone->childbase);
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 1e2ae48ccb1..5392e1dd4e8 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -60,7 +60,9 @@
 #include "DNA_workspace_types.h"
 #include "DNA_key_types.h"
 #include "DNA_curve_types.h"
+#include "DNA_armature_types.h"
 
+#include "BKE_action.h"
 #include "BKE_collection.h"
 #include "BKE_constraint.h"
 #include "BKE_customdata.h"
@@ -87,6 +89,8 @@
 #include "BKE_key.h"
 #include "BKE_unit.h"
 
+#include "DEG_depsgraph.h"
+
 #include "BLT_translation.h"
 
 #include "BLO_readfile.h"
@@ -860,6 +864,51 @@ void do_versions_after_linking_280(Main *bmain)
 			}
 		}
 	}
+
+	/* Move B-Bone custom handle settings from bPoseChannel to Bone. */
+	if (!MAIN_VERSION_ATLEAST(bmain, 280, 25)) {
+		for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
+			bArmature *arm = ob->data;
+
+			/* If it is an armature from the same file. */
+			if (ob->pose && arm && arm->id.lib == ob->id.lib) {
+				bool rebuild = false;
+
+				for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+					/* If the 2.7 flag is enabled, processing is needed. */
+					if (pchan->bone && (pchan->bboneflag & PCHAN_BBONE_CUSTOM_HANDLES)) {
+						/* If the settings in the Bone are not set, copy. */
+						if (pchan->bone->bbone_prev_type == BBONE_HANDLE_AUTO &&
+						    pchan->bone->bbone_next_type == BBONE_HANDLE_AUTO &&
+						    pchan->bone->bbone_prev == NULL && pchan->bone->bbone_next == NULL)
+						{
+							pchan->bone->bbone_prev_type = (pchan->bboneflag & PCHAN_BBONE_CUSTOM_START_REL) ? BBONE_HANDLE_RELATIVE : BBONE_HANDLE_ABSOLUTE;
+							pchan->bone->bbone_next_type = (pchan->bboneflag & PCHAN_BBONE_CUSTOM_END_REL) ? 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list