Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_convert_armature.c
| Show First 20 Lines • Show All 315 Lines • ▼ Show 20 Lines | static short pose_grab_with_ik_add(bPoseChannel *pchan) | ||||
| /* Sanity check */ | /* Sanity check */ | ||||
| if (pchan == NULL) { | if (pchan == NULL) { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| /* Rule: not if there's already an IK on this channel */ | /* Rule: not if there's already an IK on this channel */ | ||||
| for (con = pchan->constraints.first; con; con = con->next) { | for (con = pchan->constraints.first; con; con = con->next) { | ||||
| if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->flag & CONSTRAINT_OFF) == 0) { | if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->flag & CONSTRAINT_OFF) == 0) { | ||||
| data = con->data; | if ((con->flag & CONSTRAINT_DISABLE) == 0 && (con->enforce != 0.0f)) { | ||||
| return 0; | |||||
| if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == '\0')) { | |||||
| /* make reference to constraint to base things off later | |||||
| * (if it's the last targetless constraint encountered) */ | |||||
| targetless = (bKinematicConstraint *)con->data; | |||||
| /* but, if this is a targetless IK, we make it auto anyway (for the children loop) */ | |||||
| if (con->enforce != 0.0f) { | |||||
| data->flag |= CONSTRAINT_IK_AUTO; | |||||
| /* if no chain length has been specified, | |||||
| * just make things obey standard rotation locks too */ | |||||
| if (data->rootbone == 0) { | |||||
| for (bPoseChannel *pchan_iter = pchan; pchan_iter; pchan_iter = pchan_iter->parent) { | |||||
| /* here, we set ik-settings for bone from pchan->protectflag */ | |||||
| // XXX: careful with quats/axis-angle rotations where we're locking 4d components | |||||
| if (pchan_iter->protectflag & OB_LOCK_ROTX) { | |||||
| pchan_iter->ikflag |= BONE_IK_NO_XDOF_TEMP; | |||||
| } | |||||
| if (pchan_iter->protectflag & OB_LOCK_ROTY) { | |||||
| pchan_iter->ikflag |= BONE_IK_NO_YDOF_TEMP; | |||||
| } | |||||
| if (pchan_iter->protectflag & OB_LOCK_ROTZ) { | |||||
| pchan_iter->ikflag |= BONE_IK_NO_ZDOF_TEMP; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| if ((con->flag & CONSTRAINT_DISABLE) == 0 && (con->enforce != 0.0f)) { | data = con->data; | ||||
| if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == '\0')) { | |||||
| /* Temporary IK constraints will be added in add_pose_transdata for targetless constraints. | |||||
| * This means targetless constraints (including their specified chainlength) will be | |||||
| * preferred over the 'Auto IK' option when both are used in tandem. */ | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| data = add_temporary_ik_constraint(pchan, targetless)->data; | data = add_temporary_ik_constraint(pchan, targetless)->data; | ||||
| copy_v3_v3(data->grabtarget, pchan->pose_tail); | copy_v3_v3(data->grabtarget, pchan->pose_tail); | ||||
| ▲ Show 20 Lines • Show All 1,427 Lines • Show Last 20 Lines | |||||