diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-03-12 12:38:19 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-03-12 12:38:31 +0300 |
commit | 0bb57c5accd491dfad424fbe39dbb224cc2698a8 (patch) | |
tree | 4b7053a4ac330bac7c6f85a7032b764f4efc2359 /source | |
parent | 55824525670e068b503aa1f094ca3b5f23ab7257 (diff) |
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.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 18 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/armature_update.c | 12 |
2 files changed, 21 insertions, 9 deletions
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. */ |