Fix #140183: Add Armature Constraint (with target) wrong behavior
Two issues here: - if only one bone is selected blender would create an **Empty** as target (does not make sense as a target for an armature constraint though) - if other bones are also selected, none would be set up as a real target for the Armature Constraint So to resolve, change behavior in the following way: - if only one bone is selected -> dont create a "dummy" target at all (just like for `Clamp To` or `Spline IK`, does not really make sense to create a default Curve / Armature in this case since the user would always use something else) - if you have another bone selected -> set it up as bone target in the armature constraint for the user For the second to work properly, we have to add a target to the armature constraint "manually" (since armature constraints dont have a target by default) Pull Request: https://projects.blender.org/blender/blender/pulls/140200
This commit is contained in:
committed by
Philipp Oeser
parent
701eb56f5e
commit
1203b726d1
@@ -2187,6 +2187,11 @@ static bool get_new_constraint_target(
|
||||
only_ob = true;
|
||||
add = false;
|
||||
break;
|
||||
|
||||
/* Armature only. */
|
||||
case CONSTRAINT_TYPE_ARMATURE:
|
||||
add = false;
|
||||
break;
|
||||
}
|
||||
|
||||
/* if the active Object is Armature, and we can search for bones, do so... */
|
||||
@@ -2335,6 +2340,18 @@ static wmOperatorStatus constraint_add_exec(
|
||||
|
||||
/* get the target objects, adding them as need be */
|
||||
if (get_new_constraint_target(C, type, &tar_ob, &tar_pchan, true)) {
|
||||
|
||||
/* Armature constraints dont have a target by default, add one. */
|
||||
if (type == CONSTRAINT_TYPE_ARMATURE) {
|
||||
bArmatureConstraint *acon = static_cast<bArmatureConstraint *>(con->data);
|
||||
bConstraintTarget *ct = MEM_callocN<bConstraintTarget>("Constraint Target");
|
||||
|
||||
ct->weight = 1.0f;
|
||||
BLI_addtail(&acon->targets, ct);
|
||||
|
||||
constraint_dependency_tag_update(bmain, ob, con);
|
||||
}
|
||||
|
||||
/* Method of setting target depends on the type of target we've got - by default,
|
||||
* just set the first target (distinction here is only for multiple-targeted constraints).
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user