From aa00019de01a175e8c583c801dcf04b9e1c78d89 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Thu, 4 Apr 2019 11:18:40 +0300 Subject: Cleanup: remove B-Bone shape pointers from bPoseChanDeform. They are pointless copies from pchan->runtime by now. --- source/blender/blenkernel/intern/armature.c | 39 ++++++++++------------------- 1 file changed, 13 insertions(+), 26 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 1a13c8d50a0..6e0767836d7 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -823,9 +823,7 @@ int BKE_pchan_bbone_spline_compute(BBoneSplineParameters *param, Mat4 result_arr /* ************ Armature Deform ******************* */ typedef struct bPoseChanDeform { - Mat4 *b_bone_mats; DualQuat *dual_quat; - DualQuat *b_bone_dual_quats; } bPoseChanDeform; /* Definition of cached object bbone deformations. */ @@ -915,9 +913,10 @@ void BKE_pchan_bbone_segments_cache_copy(bPoseChannel *pchan, bPoseChannel *pcha } } -static void b_bone_deform(const bPoseChanDeform *pdef_info, Bone *bone, float co[3], DualQuat *dq, float defmat[3][3]) +static void b_bone_deform(const bPoseChannel *pchan, float co[3], DualQuat *dq, float defmat[3][3]) { - const Mat4 *b_bone = pdef_info->b_bone_mats; + Bone *bone = pchan->bone; + const Mat4 *b_bone = pchan->runtime.bbone_deform_mats; const float (*mat)[4] = b_bone[0].mat; float segment, y; int a; @@ -934,7 +933,7 @@ static void b_bone_deform(const bPoseChanDeform *pdef_info, Bone *bone, float co CLAMP(a, 0, bone->segments - 1); if (dq) { - copy_dq_dq(dq, &(pdef_info->b_bone_dual_quats)[a]); + copy_dq_dq(dq, &(pchan->runtime.bbone_dual_quats)[a]); } else { mul_m4_v3(b_bone[a + 1].mat, co); @@ -1030,9 +1029,9 @@ static float dist_bone_deform(bPoseChannel *pchan, const bPoseChanDeform *pdef_i contrib = fac; if (contrib > 0.0f) { if (vec) { - if (bone->segments > 1 && pdef_info->b_bone_mats != NULL) + if (bone->segments > 1 && pchan->runtime.bbone_segments == bone->segments) /* applies on cop and bbonemat */ - b_bone_deform(pdef_info, bone, cop, NULL, (mat) ? bbonemat : NULL); + b_bone_deform(pchan, cop, NULL, (mat) ? bbonemat : NULL); else mul_m4_v3(pchan->chan_mat, cop); @@ -1044,8 +1043,8 @@ static float dist_bone_deform(bPoseChannel *pchan, const bPoseChanDeform *pdef_i pchan_deform_mat_add(pchan, fac, bbonemat, mat); } else { - if (bone->segments > 1 && pdef_info->b_bone_mats != NULL) { - b_bone_deform(pdef_info, bone, cop, &bbonedq, NULL); + if (bone->segments > 1 && pchan->runtime.bbone_segments == bone->segments) { + b_bone_deform(pchan, cop, &bbonedq, NULL); add_weighted_dq_dq(dq, &bbonedq, fac); } else @@ -1061,6 +1060,7 @@ static void pchan_bone_deform(bPoseChannel *pchan, const bPoseChanDeform *pdef_i float weight, float vec[3], DualQuat *dq, float mat[3][3], const float co[3], float *contrib) { + Bone *bone = pchan->bone; float cop[3], bbonemat[3][3]; DualQuat bbonedq; @@ -1070,9 +1070,9 @@ static void pchan_bone_deform(bPoseChannel *pchan, const bPoseChanDeform *pdef_i copy_v3_v3(cop, co); if (vec) { - if (pchan->bone->segments > 1 && pdef_info->b_bone_mats != NULL) + if (bone->segments > 1 && bone->segments == pchan->runtime.bbone_segments) /* applies on cop and bbonemat */ - b_bone_deform(pdef_info, pchan->bone, cop, NULL, (mat) ? bbonemat : NULL); + b_bone_deform(pchan, cop, NULL, (mat) ? bbonemat : NULL); else mul_m4_v3(pchan->chan_mat, cop); @@ -1084,8 +1084,8 @@ 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 && pdef_info->b_bone_mats != NULL) { - b_bone_deform(pdef_info, pchan->bone, cop, &bbonedq, NULL); + if (bone->segments > 1 && bone->segments == pchan->runtime.bbone_segments) { + b_bone_deform(pchan, cop, &bbonedq, NULL); add_weighted_dq_dq(dq, &bbonedq, weight); } else @@ -1110,19 +1110,6 @@ 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; - pdef_info->b_bone_mats = NULL; - pdef_info->b_bone_dual_quats = NULL; - - 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) { pdef_info->dual_quat = &data->dualquats[index]; mat4_to_dquat(pdef_info->dual_quat, pchan->bone->arm_mat, pchan->chan_mat); -- cgit v1.2.3