Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2019-03-12 12:38:19 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-03-12 12:38:31 +0300
commit0bb57c5accd491dfad424fbe39dbb224cc2698a8 (patch)
tree4b7053a4ac330bac7c6f85a7032b764f4efc2359 /source/blender/blenkernel/intern/armature.c
parent55824525670e068b503aa1f094ca3b5f23ab7257 (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/blender/blenkernel/intern/armature.c')
-rw-r--r--source/blender/blenkernel/intern/armature.c18
1 files changed, 12 insertions, 6 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) {