From d454d6c6bca8969f532f4b4863f3d3686660a2e0 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 7 Feb 2011 23:21:28 +0000 Subject: 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. --- source/blender/editors/object/object_constraint.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/object/object_constraint.c') 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; } } -- cgit v1.2.3