[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19140] branches/blender2.5/blender/source /blender/editors: Bugfixes for armature operators - parent + align operators weren' t working correctly, since the active bone wasn' t being accounted for in the right way.
Joshua Leung
aligorith at gmail.com
Sat Feb 28 11:23:51 CET 2009
Revision: 19140
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19140
Author: aligorith
Date: 2009-02-28 11:23:36 +0100 (Sat, 28 Feb 2009)
Log Message:
-----------
Bugfixes for armature operators - parent + align operators weren't working correctly, since the active bone wasn't being accounted for in the right way.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/editors/armature/editarmature.c
branches/blender2.5/blender/source/blender/editors/space_outliner/outliner.c
Modified: branches/blender2.5/blender/source/blender/editors/armature/editarmature.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/editarmature.c 2009-02-28 09:59:27 UTC (rev 19139)
+++ branches/blender2.5/blender/source/blender/editors/armature/editarmature.c 2009-02-28 10:23:36 UTC (rev 19140)
@@ -679,7 +679,7 @@
/* Ensure we're not in editmode and that the active object is an armature*/
if (ob->type!=OB_ARMATURE) return 0;
- if(arm->edbo) return 0;
+ if (arm->edbo) return 0;
if (object_data_is_libdata(ob)) {
error_libdata();
@@ -1173,7 +1173,6 @@
*bone &= ~flag;
else
*bone ^= flag;
-
}
else {
if (mode == 2)
@@ -2428,7 +2427,7 @@
eBone=MEM_callocN(sizeof(EditBone), "addup_editbone");
eBone->flag |= BONE_SELECTED;
- /* Copy data from old bone to new bone */
+ /* Copy data from old bone to new bone */
memcpy(eBone, curBone, sizeof(EditBone));
curBone->temp = eBone;
@@ -2489,33 +2488,35 @@
if (curBone->flag & BONE_SELECTED) {
eBone=(EditBone*) curBone->temp;
- /* If this bone has no parent,
- Set the duplicate->parent to NULL
- */
- if (!curBone->parent)
+ if (!curBone->parent) {
+ /* If this bone has no parent,
+ * Set the duplicate->parent to NULL
+ */
eBone->parent = NULL;
- /* If this bone has a parent that IS selected,
- Set the duplicate->parent to the curBone->parent->duplicate
- */
- else if (curBone->parent->flag & BONE_SELECTED)
+ }
+ else if (curBone->parent->flag & BONE_SELECTED) {
+ /* If this bone has a parent that IS selected,
+ * Set the duplicate->parent to the curBone->parent->duplicate
+ */
eBone->parent= (EditBone *)curBone->parent->temp;
- /* If this bone has a parent that IS not selected,
- Set the duplicate->parent to the curBone->parent
- */
+ }
else {
+ /* If this bone has a parent that IS not selected,
+ * Set the duplicate->parent to the curBone->parent
+ */
eBone->parent=(EditBone*) curBone->parent;
eBone->flag &= ~BONE_CONNECTED;
}
/* Lets try to fix any constraint subtargets that might
- have been duplicated */
+ * have been duplicated
+ */
update_dup_subtarget(obedit, eBone);
}
}
}
/* Deselect the old bones and select the new ones */
-
for (curBone=arm->edbo->first; curBone && curBone!=firstDup; curBone=curBone->next) {
if (EBONE_VISIBLE(arm, curBone))
curBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL | BONE_ACTIVE);
@@ -2523,9 +2524,6 @@
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
-// XXX BIF_TransformSetUndo("Add Duplicate");
-// initTransform(TFM_TRANSLATION, CTX_NO_PET);
-// Transform();
return OPERATOR_FINISHED;
}
@@ -3501,6 +3499,8 @@
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
/* ***************** Parenting *********************** */
+
+/* armature parenting options */
#define ARM_PAR_CONNECT 1
#define ARM_PAR_OFFSET 2
@@ -3610,14 +3610,19 @@
/* Parent 'selected' bones to the active one
* - the context iterator contains both selected bones and their mirrored copies,
* so we assume that unselected bones are mirrored copies of some selected bone
+ * - since the active one (and/or its mirror) will also be selected, we also need
+ * to check that we are not trying to opearate on them, since such an operation
+ * would cause errors
*/
- /* align selected bones to the active one */
+ /* parent selected bones to the active one */
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) {
- if (ebone->flag & BONE_SELECTED)
- bone_connect_to_new_parent(arm->edbo, ebone, actbone, val);
- else
- bone_connect_to_new_parent(arm->edbo, ebone, actmirb, val);
+ if (ELEM(ebone, actbone, actmirb) == 0) {
+ if (ebone->flag & BONE_SELECTED)
+ bone_connect_to_new_parent(arm->edbo, ebone, actbone, val);
+ else
+ bone_connect_to_new_parent(arm->edbo, ebone, actmirb, val);
+ }
}
CTX_DATA_END;
}
@@ -3976,14 +3981,19 @@
/* Align 'selected' bones to the active one
* - the context iterator contains both selected bones and their mirrored copies,
* so we assume that unselected bones are mirrored copies of some selected bone
+ * - since the active one (and/or its mirror) will also be selected, we also need
+ * to check that we are not trying to opearate on them, since such an operation
+ * would cause errors
*/
/* align selected bones to the active one */
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) {
- if (ebone->flag & BONE_SELECTED)
- bone_align_to_bone(arm->edbo, ebone, actbone);
- else
- bone_align_to_bone(arm->edbo, ebone, actmirb);
+ if (ELEM(ebone, actbone, actmirb) == 0) {
+ if (ebone->flag & BONE_SELECTED)
+ bone_align_to_bone(arm->edbo, ebone, actbone);
+ else
+ bone_align_to_bone(arm->edbo, ebone, actmirb);
+ }
}
CTX_DATA_END;
}
Modified: branches/blender2.5/blender/source/blender/editors/space_outliner/outliner.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_outliner/outliner.c 2009-02-28 09:59:27 UTC (rev 19139)
+++ branches/blender2.5/blender/source/blender/editors/space_outliner/outliner.c 2009-02-28 10:23:36 UTC (rev 19140)
@@ -3127,7 +3127,7 @@
/* step 1: flatten out hierarchy of parents into a flat chain */
for (tem= te->parent; tem; tem= tem->parent) {
- ld= MEM_callocN(sizeof(LinkData), "LinkData for ks_editop_add_cb()");
+ ld= MEM_callocN(sizeof(LinkData), "LinkData for tree_element_to_path()");
ld->data= tem;
BLI_addhead(&hierarchy, ld);
}
@@ -3145,7 +3145,6 @@
/* just 'append' property to path
* - to prevent memory leaks, we must write to newpath not path, then free old path + swap them
*/
-
if(tse->type == TSE_RNA_PROPERTY) {
if(RNA_property_type(ptr, prop) == PROP_POINTER) {
/* for pointer we just append property name */
More information about the Bf-blender-cvs
mailing list