[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [10731] trunk/blender/source/blender/src/ editarmature.c: Plumifero's wishlist:
Chris Want
cwant at ualberta.ca
Fri May 18 18:06:12 CEST 2007
Chris Want wrote:
> Log Message:
> -----------
> Plumifero's wishlist:
>
> * When duplicating bones that have constraints (edit mode),
> duplicate them too with TARGET field updated.
Ok, if I have a ik chain and a subtarget bone selected, and I
duplicate both, it works fine and the new ik chain points to
the new subtarget bone. Leaving editmode though, I get an
ominous warning like:
Cycle in Bone.007 to Bone.010
Cycle in Bone.008 to Bone.010
Cycle in Bone.009 to Bone.010
Things work fine, however, and this message does not repeat
the next time entering editmode. I am guessing that I need to
tell depsgraph about the new constraints that were created,
but I can't figure out the code -- can anybody familiar with
the code see an obvious fix? I am told that Algorith would
probably know what to do to get rid of the depsgraph
problem.
Regards,
Chris
> This is code that I wrote a few years ago before the armature
> refactor. It is simple code that compiles and seems to work fine,
> but should be checked by Ton or somebody else with better knowledge
> of the current armature system.
>
> Usage description, (stolen from the first time this code was
> committed):
>
> "Duplicating bones in edit mode now also duplicates the constraints
> associated with that bone ... if the constraint subtarget bone is
> also duplicated the new constraint points to this new bone as it's
> subtarget."
>
> Modified Paths:
> --------------
> trunk/blender/source/blender/src/editarmature.c
>
> Modified: trunk/blender/source/blender/src/editarmature.c
> ===================================================================
> --- trunk/blender/source/blender/src/editarmature.c 2007-05-17 17:15:22 UTC (rev 10730)
> +++ trunk/blender/source/blender/src/editarmature.c 2007-05-17 21:28:33 UTC (rev 10731)
> @@ -1539,6 +1539,54 @@
> }
>
>
> +static EditBone *get_named_editbone(char *name)
> +{
> + EditBone *eBone;
> +
> + if (name)
> + for (eBone=G.edbo.first; eBone; eBone=eBone->next){
> + if (!strcmp (name, eBone->name))
> + return eBone;
> + }
> +
> + return NULL;
> +}
> +
> +static void update_dup_subtarget(EditBone *dupBone)
> +{
> + /* If an edit bone has been duplicated, lets
> + * update it's constraints if the subtarget
> + * they point to has also been duplicated
> + */
> + EditBone *oldtarget, *newtarget;
> + bPoseChannel *chan;
> + bConstraint *curcon;
> + ListBase *conlist;
> + char *subname;
> +
> +
> + if ( (chan = verify_pose_channel(OBACT->pose, dupBone->name)) )
> + if ( (conlist = &chan->constraints) )
> + for (curcon = conlist->first; curcon; curcon=curcon->next) {
> + /* does this constraint have a subtarget in
> + * this armature?
> + */
> + subname = get_con_subtarget_name(curcon, G.obedit);
> + oldtarget = get_named_editbone(subname);
> + if (oldtarget)
> + /* was the subtarget bone duplicated too? If
> + * so, update the constraint to point at the
> + * duplicate of the old subtarget.
> + */
> + if (oldtarget->flag & BONE_SELECTED){
> + newtarget = (EditBone*) oldtarget->temp;
> + strcpy(subname, newtarget->name);
> + }
> + }
> +
> +}
> +
> +
> void adduplicate_armature(void)
> {
> bArmature *arm= G.obedit->data;
> @@ -1570,7 +1618,24 @@
> /* Lets duplicate the list of constraits that the
> * current bone has.
> */
> - /* temporal removed (ton) */
> + if (OBACT->pose) {
> + bPoseChannel *chanold, *channew;
> + ListBase *listold, *listnew;
> +
> + chanold = verify_pose_channel (OBACT->pose, curBone->name);
> + if (chanold) {
> + listold = &chanold->constraints;
> + if (listold){
> + channew =
> + verify_pose_channel(OBACT->pose, eBone->name);
> + if (channew) {
> + listnew = &channew->constraints;
> + copy_constraints (listnew, listold);
> + }
> + }
> + }
> + }
> +
> }
> }
> }
> @@ -1603,8 +1668,8 @@
>
> /* Lets try to fix any constraint subtargets that might
> have been duplicated */
> - /* temporal removed (ton) */
> - }
> + update_dup_subtarget(eBone);
> + }
> }
> }
>
!DSPAM:18,464dd03936371665811764!
More information about the Bf-committers
mailing list