diff options
author | Joshua Leung <aligorith@gmail.com> | 2011-02-08 02:21:28 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2011-02-08 02:21:28 +0300 |
commit | d454d6c6bca8969f532f4b4863f3d3686660a2e0 (patch) | |
tree | 2ddb92af14d032844341cca353fc90aa153a7761 | |
parent | 0d8416acc7fa39a8519043e6e57006a203622644 (diff) |
Bugfix: Constraint target validation code was broken
While testing Apply Visual transforms last night, I noticed that
setting a constraint to use its owner as its target was allowed and
didn't trigger any warnings. This clearly doesn't do any good and is
different from the old behaviour.
-rw-r--r-- | source/blender/editors/object/object_constraint.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index f695f112bc0..e92d73a3e67 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -405,11 +405,26 @@ static void test_constraints (Object *owner, bPoseChannel *pchan) for (ct= targets.first; ct; ct= ct->next) { /* general validity checks (for those constraints that need this) */ if (exist_object(ct->tar) == 0) { + /* object doesn't exist, but constraint requires target */ ct->tar = NULL; curcon->flag |= CONSTRAINT_DISABLE; } else if (ct->tar == owner) { - if (!get_named_bone(get_armature(owner), ct->subtarget)) { + if (type == CONSTRAINT_OBTYPE_BONE) { + if (!get_named_bone(get_armature(owner), ct->subtarget)) { + /* bone must exist in armature... */ + // TODO: clear subtarget? + curcon->flag |= CONSTRAINT_DISABLE; + } + else if (strcmp(pchan->name, ct->subtarget) == 0) { + /* cannot target self */ + ct->subtarget[0] = '\0'; + curcon->flag |= CONSTRAINT_DISABLE; + } + } + else { + /* cannot use self as target */ + ct->tar = NULL; curcon->flag |= CONSTRAINT_DISABLE; } } |