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:
authorJoshua Leung <aligorith@gmail.com>2011-02-01 08:15:32 +0300
committerJoshua Leung <aligorith@gmail.com>2011-02-01 08:15:32 +0300
commit6f0aa2cb0ed6b42d284d8352e697a4e4b5c2ebc5 (patch)
treea9f3f5910807baf55bee9b0ba1f1446b75578609 /source/blender/editors/transform/transform_conversions.c
parent0362d19f2d2b48b2b502bc1a136a9647ca86cb43 (diff)
Targetless IK Bugfixes + Tweaks:
- "CONSTRAINT_IK_AUTO" flag for targetless IK constraints was being set in the wrong place. This is for the IK constraint data's flag, not the generic constraint's flag - Converting stack var "targetless" from type bConstraint to bKinematicConstraint (i.e. constraint baseclass -> specialised data), since it was only used in one place with a cast used there. - When using targetless IK with no specified chain length, bone rotation locks are taken into account too, saving a bit of extra setup work
Diffstat (limited to 'source/blender/editors/transform/transform_conversions.c')
-rw-r--r--source/blender/editors/transform/transform_conversions.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 4ffbb0181a4..ac876a23ade 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -827,9 +827,9 @@ static void pose_grab_with_ik_clear(Object *ob)
/* adds the IK to pchan - returns if added */
static short pose_grab_with_ik_add(bPoseChannel *pchan)
{
+ bKinematicConstraint *targetless = NULL;
bKinematicConstraint *data;
bConstraint *con;
- bConstraint *targetless = 0;
/* Sanity check */
if (pchan == NULL)
@@ -838,15 +838,31 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
/* Rule: not if there's already an IK on this channel */
for (con= pchan->constraints.first; con; con= con->next) {
if (con->type==CONSTRAINT_TYPE_KINEMATIC) {
- bKinematicConstraint *data= con->data;
- if(data->tar==NULL || (data->tar->type==OB_ARMATURE && data->subtarget[0]==0)) {
- targetless = con;
+ data= con->data;
+
+ 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) {
- targetless->flag |= CONSTRAINT_IK_AUTO;
- return 0;
+ 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 (; pchan; pchan=pchan->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->protectflag & OB_LOCK_ROTX) pchan->ikflag |= BONE_IK_NO_XDOF_TEMP;
+ if (pchan->protectflag & OB_LOCK_ROTY) pchan->ikflag |= BONE_IK_NO_YDOF_TEMP;
+ if (pchan->protectflag & OB_LOCK_ROTZ) pchan->ikflag |= BONE_IK_NO_ZDOF_TEMP;
+ }
+ }
+
+ return 0;
}
}
+
if ((con->flag & CONSTRAINT_DISABLE)==0 && (con->enforce!=0.0f))
return 0;
}
@@ -855,8 +871,9 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
con = add_pose_constraint(NULL, pchan, "TempConstraint", CONSTRAINT_TYPE_KINEMATIC);
pchan->constflag |= (PCHAN_HAS_IK|PCHAN_HAS_TARGET); /* for draw, but also for detecting while pose solving */
data= con->data;
- if (targetless) { /* if exists use values from last targetless IK-constraint as base */
- *data = *((bKinematicConstraint*)targetless->data);
+ if (targetless) {
+ /* if exists, use values from last targetless (but disabled) IK-constraint as base */
+ *data = *targetless;
}
else
data->flag= CONSTRAINT_IK_TIP;