Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_convert_armature.c
| Show All 20 Lines | |||||
| * \ingroup edtransform | * \ingroup edtransform | ||||
| */ | */ | ||||
| #include "DNA_armature_types.h" | #include "DNA_armature_types.h" | ||||
| #include "DNA_constraint_types.h" | #include "DNA_constraint_types.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_listbase.h" | |||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BKE_action.h" | #include "BKE_action.h" | ||||
| #include "BKE_armature.h" | #include "BKE_armature.h" | ||||
| #include "BKE_constraint.h" | #include "BKE_constraint.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| ▲ Show 20 Lines • Show All 488 Lines • ▼ Show 20 Lines | |||||
| * context; posemode armature, with mirror editing enabled. | * context; posemode armature, with mirror editing enabled. | ||||
| */ | */ | ||||
| void pose_transform_mirror_update(TransInfo *t, TransDataContainer *tc, Object *ob) | void pose_transform_mirror_update(TransInfo *t, TransDataContainer *tc, Object *ob) | ||||
| { | { | ||||
| float flip_mtx[4][4]; | float flip_mtx[4][4]; | ||||
| unit_m4(flip_mtx); | unit_m4(flip_mtx); | ||||
| flip_mtx[0][0] = -1; | flip_mtx[0][0] = -1; | ||||
| for (bPoseChannel *pchan_orig = ob->pose->chanbase.first; pchan_orig; | LISTBASE_FOREACH (bPoseChannel *, pchan_orig, &ob->pose->chanbase) { | ||||
| pchan_orig = pchan_orig->next) { | |||||
| /* Clear the MIRROR flag from previous runs. */ | /* Clear the MIRROR flag from previous runs. */ | ||||
| pchan_orig->bone->flag &= ~BONE_TRANSFORM_MIRROR; | pchan_orig->bone->flag &= ~BONE_TRANSFORM_MIRROR; | ||||
| } | } | ||||
| bPose *pose = ob->pose; | bPose *pose = ob->pose; | ||||
| PoseInitData_Mirror *pid = NULL; | PoseInitData_Mirror *pid = NULL; | ||||
| if ((t->mode != TFM_BONESIZE) && (pose->flag & POSE_MIRROR_RELATIVE)) { | if ((t->mode != TFM_BONESIZE) && (pose->flag & POSE_MIRROR_RELATIVE)) { | ||||
| pid = tc->custom.type.data; | pid = tc->custom.type.data; | ||||
| ▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | if (arm->flag & ARM_RESTPOS) { | ||||
| BKE_report(t->reports, RPT_ERROR, "Cannot change Pose when 'Rest Position' is enabled"); | BKE_report(t->reports, RPT_ERROR, "Cannot change Pose when 'Rest Position' is enabled"); | ||||
| tc->data_len = 0; | tc->data_len = 0; | ||||
| continue; | continue; | ||||
| } | } | ||||
| } | } | ||||
| if (mirror) { | if (mirror) { | ||||
| int total_mirrored = 0; | int total_mirrored = 0; | ||||
| for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { | LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { | ||||
| if ((pchan->bone->flag & BONE_TRANSFORM) && | if ((pchan->bone->flag & BONE_TRANSFORM) && | ||||
| BKE_pose_channel_get_mirrored(ob->pose, pchan->name)) { | BKE_pose_channel_get_mirrored(ob->pose, pchan->name)) { | ||||
| total_mirrored++; | total_mirrored++; | ||||
| } | } | ||||
| } | } | ||||
| PoseInitData_Mirror *pid = MEM_mallocN((total_mirrored + 1) * sizeof(PoseInitData_Mirror), | PoseInitData_Mirror *pid = MEM_mallocN((total_mirrored + 1) * sizeof(PoseInitData_Mirror), | ||||
| "PoseInitData_Mirror"); | "PoseInitData_Mirror"); | ||||
| Show All 33 Lines | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| tdx = tc->data_ext = MEM_callocN(tc->data_len * sizeof(TransDataExtension), | tdx = tc->data_ext = MEM_callocN(tc->data_len * sizeof(TransDataExtension), | ||||
| "TransPoseBoneExt"); | "TransPoseBoneExt"); | ||||
| for (i = 0; i < tc->data_len; i++, td++, tdx++) { | for (i = 0; i < tc->data_len; i++, td++, tdx++) { | ||||
| td->ext = tdx; | td->ext = tdx; | ||||
| td->val = NULL; | td->val = NULL; | ||||
| } | } | ||||
| if (mirror) { | if (mirror) { | ||||
| for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) { | LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) { | ||||
| if (pchan->bone->flag & BONE_TRANSFORM) { | if (pchan->bone->flag & BONE_TRANSFORM) { | ||||
| bPoseChannel *pchan_mirror = BKE_pose_channel_get_mirrored(ob->pose, pchan->name); | bPoseChannel *pchan_mirror = BKE_pose_channel_get_mirrored(ob->pose, pchan->name); | ||||
| if (pchan_mirror) { | if (pchan_mirror) { | ||||
| pchan_mirror->bone->flag |= BONE_TRANSFORM_MIRROR; | pchan_mirror->bone->flag |= BONE_TRANSFORM_MIRROR; | ||||
| pose_mirror_info_init(&pid[pid_index], pchan_mirror, pchan, is_mirror_relative); | pose_mirror_info_init(&pid[pid_index], pchan_mirror, pchan, is_mirror_relative); | ||||
| pid_index++; | pid_index++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* do we need to add temporal IK chains? */ | /* do we need to add temporal IK chains? */ | ||||
| if ((pose->flag & POSE_AUTO_IK) && t->mode == TFM_TRANSLATION) { | if ((pose->flag & POSE_AUTO_IK) && t->mode == TFM_TRANSLATION) { | ||||
| if (pose_grab_with_ik(bmain, ob)) { | if (pose_grab_with_ik(bmain, ob)) { | ||||
| t->flag |= T_AUTOIK; | t->flag |= T_AUTOIK; | ||||
| has_translate_rotate[0] = true; | has_translate_rotate[0] = true; | ||||
| } | } | ||||
| } | } | ||||
| /* use pose channels to fill trans data */ | /* use pose channels to fill trans data */ | ||||
| td = tc->data; | td = tc->data; | ||||
| for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { | LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { | ||||
| if (pchan->bone->flag & BONE_TRANSFORM) { | if (pchan->bone->flag & BONE_TRANSFORM) { | ||||
| add_pose_transdata(t, pchan, ob, tc, td); | add_pose_transdata(t, pchan, ob, tc, td); | ||||
| td++; | td++; | ||||
| } | } | ||||
| } | } | ||||
| if (td != (tc->data + tc->data_len)) { | if (td != (tc->data + tc->data_len)) { | ||||
| BKE_report(t->reports, RPT_DEBUG, "Bone selection count error"); | BKE_report(t->reports, RPT_DEBUG, "Bone selection count error"); | ||||
| ▲ Show 20 Lines • Show All 327 Lines • Show Last 20 Lines | |||||