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.
This commit is contained in:
parent
5582452567
commit
0bb57c5acc
|
@ -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) {
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue