[Bf-blender-cvs] [0bb57c5accd] master: Make B-Bone deformation code more robust with bad cached segment data.

Alexander Gavrilov noreply at git.blender.org
Tue Mar 12 10:42:29 CET 2019


Commit: 0bb57c5accd491dfad424fbe39dbb224cc2698a8
Author: Alexander Gavrilov
Date:   Tue Mar 12 12:38:19 2019 +0300
Branches: master
https://developer.blender.org/rB0bb57c5accd491dfad424fbe39dbb224cc2698a8

Make B-Bone deformation code more robust with bad cached segment data.

Various dependency graph problems can cause obsolete data to reach the
armature modifier, so add checks to reduce the chance of crashing.

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

M	source/blender/blenkernel/intern/armature.c
M	source/blender/blenkernel/intern/armature_update.c

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

diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index cf7b9981b72..1a13c8d50a0 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1070,7 +1070,7 @@ static void pchan_bone_deform(bPoseChannel *pchan, const bPoseChanDeform *pdef_i
 	copy_v3_v3(cop, co);
 
 	if (vec) {
-		if (pchan->bone->segments > 1)
+		if (pchan->bone->segments > 1 && pdef_info->b_bone_mats != NULL)
 			/* applies on cop and bbonemat */
 			b_bone_deform(pdef_info, pchan->bone, cop, NULL, (mat) ? bbonemat : NULL);
 		else
@@ -1084,7 +1084,7 @@ static void pchan_bone_deform(bPoseChannel *pchan, const bPoseChanDeform *pdef_i
 			pchan_deform_mat_add(pchan, weight, bbonemat, mat);
 	}
 	else {
-		if (pchan->bone->segments > 1) {
+		if (pchan->bone->segments > 1 && pdef_info->b_bone_mats != NULL) {
 			b_bone_deform(pdef_info, pchan->bone, cop, &bbonedq, NULL);
 			add_weighted_dq_dq(dq, &bbonedq, weight);
 		}
@@ -1110,11 +1110,17 @@ static void armature_bbone_defmats_cb(void *userdata, Link *iter, int index)
 		bPoseChanDeform *pdef_info = &data->pdef_info_array[index];
 		const bool use_quaternion = data->use_quaternion;
 
-		if (pchan->bone->segments > 1) {
-			BLI_assert(pchan->runtime.bbone_segments == pchan->bone->segments);
+		pdef_info->b_bone_mats = NULL;
+		pdef_info->b_bone_dual_quats = NULL;
 
-			pdef_info->b_bone_mats = pchan->runtime.bbone_deform_mats;
-			pdef_info->b_bone_dual_quats = pchan->runtime.bbone_dual_quats;
+		if (pchan->bone->segments > 1) {
+			if (pchan->runtime.bbone_segments == pchan->bone->segments) {
+				pdef_info->b_bone_mats = pchan->runtime.bbone_deform_mats;
+				pdef_info->b_bone_dual_quats = pchan->runtime.bbone_dual_quats;
+			}
+			else {
+				BLI_assert(!"invalid B-Bone shape data");
+			}
 		}
 
 		if (use_quaternion) {
diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c
index 12f3f5c7354..5cd82803fae 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -704,7 +704,9 @@ void BKE_pose_bone_done(struct Depsgraph *depsgraph,
 	}
 	bPoseChannel *pchan = pose_pchan_get_indexed(object, pchan_index);
 	float imat[4][4];
-	DEG_debug_print_eval(depsgraph, __func__, pchan->name, pchan);
+	DEG_debug_print_eval_subdata(
+	        depsgraph, __func__, object->id.name, object,
+	        "pchan", pchan->name, pchan);
 	if (pchan->bone) {
 		invert_m4_m4(imat, pchan->bone->arm_mat);
 		mul_m4_m4m4(pchan->chan_mat, pchan->pose_mat, imat);
@@ -731,7 +733,9 @@ void BKE_pose_eval_bbone_segments(struct Depsgraph *depsgraph,
 		return;
 	}
 	bPoseChannel *pchan = pose_pchan_get_indexed(object, pchan_index);
-	DEG_debug_print_eval(depsgraph, __func__, pchan->name, pchan);
+	DEG_debug_print_eval_subdata(
+	        depsgraph, __func__, object->id.name, object,
+	        "pchan", pchan->name, pchan);
 	if (pchan->bone != NULL && pchan->bone->segments > 1) {
 		BKE_pchan_bbone_segments_cache_compute(pchan);
 		if (DEG_is_active(depsgraph)) {
@@ -862,8 +866,10 @@ void BKE_pose_eval_proxy_copy_bone(
 		return;
 	}
 	BLI_assert(ID_IS_LINKED(object) && object->proxy_from != NULL);
-	DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
 	bPoseChannel *pchan = pose_pchan_get_indexed(object, pchan_index);
+	DEG_debug_print_eval_subdata(
+	        depsgraph, __func__, object->id.name, object,
+	        "pchan", pchan->name, pchan);
 	/* TODO(sergey): Use indexec lookup, once it's guaranteed to be kept
 	 * around for the time while proxies are evaluating.
 	 */



More information about the Bf-blender-cvs mailing list