diff options
author | Joshua Leung <aligorith@gmail.com> | 2012-10-15 07:16:38 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2012-10-15 07:16:38 +0400 |
commit | 04f063de84efde869fe712d4533361d687a66980 (patch) | |
tree | ebbb6406c6131500a38734fcd6351cc453e27984 /source/blender/editors | |
parent | 2babbb59b931f13fb37692b8a84c12febc4b5a07 (diff) |
Parenting an object to a deformer (armature/curve/lattice) will now attempt to
check if the object is already parented to said deformer before trying to add a
new modifier
This should help reduce the number of cases where users inadvertantly end up
creating multiple deform modifiers pointing to the same object, which has been
known to be a cause of "double-transform" artifacts.
Note that this is only able to detect these cases by checking if the parent
object is selected, so this will only really work for the Ctrl-P shortcut where
you have to select both objects first. However, it shouldn't be a problem either
in the Outliner (drag and drop), as the object probably won't be a child of its
parent already if you're doing this.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/object/object_relations.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 9e6cce7fee9..b7efe9189d8 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -669,23 +669,32 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object ob->partype = PAROBJECT; /* note, dna define, not operator property */ //ob->partype= PARSKEL; /* note, dna define, not operator property */ - /* BUT, to keep the deforms, we need a modifier, and then we need to set the object that it uses */ + /* BUT, to keep the deforms, we need a modifier, and then we need to set the object that it uses + * - We need to ensure that the modifier we're adding doesn't already exist, so we check this by + * assuming that the parent is selected too... + */ // XXX currently this should only happen for meshes, curves, surfaces, and lattices - this stuff isn't available for metas yet if (ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) { ModifierData *md; switch (partype) { case PAR_CURVE: /* curve deform */ - md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Curve); - ((CurveModifierData *)md)->object = par; + if (modifiers_isDeformedByCurve(ob) != par) { + md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Curve); + ((CurveModifierData *)md)->object = par; + } break; case PAR_LATTICE: /* lattice deform */ - md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Lattice); - ((LatticeModifierData *)md)->object = par; + if (modifiers_isDeformedByLattice(ob) != par) { + md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Lattice); + ((LatticeModifierData *)md)->object = par; + } break; default: /* armature deform */ - md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Armature); - ((ArmatureModifierData *)md)->object = par; + if (modifiers_isDeformedByArmature(ob) != par) { + md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Armature); + ((ArmatureModifierData *)md)->object = par; + } break; } } |