[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12647] trunk/blender/source/blender/src: Patch #7794: X-Axis Mirror Support for Various Operations in Armature EditMode
Joshua Leung
aligorith at gmail.com
Thu Nov 22 00:22:56 CET 2007
Revision: 12647
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12647
Author: aligorith
Date: 2007-11-22 00:22:56 +0100 (Thu, 22 Nov 2007)
Log Message:
-----------
Patch #7794: X-Axis Mirror Support for Various Operations in Armature EditMode
Patch by: Teppo Kansala (teppoka)
This patch adds X-Axis Mirror support for the following tools:
- Delete Bone (X)
- Recalculate Bone Roll Angles... (Ctrl-N)
- Duplicate Bone (Shift-D)
- Clear Parent... (Alt-P)
- Move Bone To Layer (M)
Modified Paths:
--------------
trunk/blender/source/blender/src/editarmature.c
trunk/blender/source/blender/src/poseobject.c
Modified: trunk/blender/source/blender/src/editarmature.c
===================================================================
--- trunk/blender/source/blender/src/editarmature.c 2007-11-21 22:44:17 UTC (rev 12646)
+++ trunk/blender/source/blender/src/editarmature.c 2007-11-21 23:22:56 UTC (rev 12647)
@@ -1076,6 +1076,19 @@
TEST_EDITARMATURE;
if (okee("Erase selected bone(s)")==0) return;
+
+ /* Select mirrored bones */
+ if (arm->flag & ARM_MIRROR_EDIT) {
+ for (curBone=G.edbo.first; curBone; curBone=curBone->next) {
+ if (arm->layer & curBone->layer) {
+ if (curBone->flag & BONE_SELECTED) {
+ next = armature_bone_get_mirrored(curBone);
+ if (next)
+ next->flag |= BONE_SELECTED;
+ }
+ }
+ }
+ }
/* First erase any associated pose channel */
if (G.obedit->pose) {
@@ -1321,13 +1334,19 @@
{
bArmature *arm= G.obedit->data;
EditBone *ebone;
+ EditBone *flipbone = NULL;
float delta[3];
float curmat[3][3];
float *cursor= give_cursor();
for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
- if(arm->layer & ebone->layer) {
- if (ebone->flag & BONE_SELECTED) {
+ if (arm->layer & ebone->layer) {
+ if (arm->flag & ARM_MIRROR_EDIT)
+ flipbone = armature_bone_get_mirrored(ebone);
+
+ if ((ebone->flag & BONE_SELECTED) ||
+ (flipbone && flipbone->flag & BONE_SELECTED))
+ {
/* specific method used to calculate roll depends on mode */
if (mode == 1) {
/* Z-Axis point towards cursor */
@@ -1386,7 +1405,7 @@
Mat3MulMat3(diffmat, imat, curmat);
ebone->roll = atan2(diffmat[2][0], diffmat[2][2]);
- }
+ }
}
}
}
@@ -1713,11 +1732,24 @@
EditBone *firstDup=NULL; /* The beginning of the duplicated bones in the edbo list */
countall(); // flushes selection!
+
+ /* Select mirrored bones */
+ if (arm->flag & ARM_MIRROR_EDIT) {
+ for (curBone=G.edbo.first; curBone; curBone=curBone->next) {
+ if (arm->layer & curBone->layer) {
+ if (curBone->flag & BONE_SELECTED) {
+ eBone = armature_bone_get_mirrored(curBone);
+ if (eBone)
+ eBone->flag |= BONE_SELECTED;
+ }
+ }
+ }
+ }
/* Find the selected bones and duplicate them as needed */
for (curBone=G.edbo.first; curBone && curBone!=firstDup; curBone=curBone->next){
- if(arm->layer & curBone->layer) {
- if (curBone->flag & BONE_SELECTED){
+ if (arm->layer & curBone->layer) {
+ if (curBone->flag & BONE_SELECTED) {
eBone=MEM_callocN(sizeof(EditBone), "addup_editbone");
eBone->flag |= BONE_SELECTED;
@@ -2034,10 +2066,22 @@
return;
}
+static void editbone_clear_parent(EditBone *ebone, int mode)
+{
+ if (ebone->parent) {
+ /* for nice selection */
+ ebone->parent->flag &= ~(BONE_TIPSEL);
+ }
+
+ if(mode==1) ebone->parent= NULL;
+ ebone->flag &= ~BONE_CONNECTED;
+}
+
void clear_bone_parent(void)
{
bArmature *arm= G.obedit->data;
EditBone *ebone;
+ EditBone *flipbone = NULL;
short val;
val= pupmenu("Clear Parent%t|Clear Parent%x1|Disconnect Bone%x2");
@@ -2046,13 +2090,13 @@
for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
if(arm->layer & ebone->layer) {
if(ebone->flag & BONE_SELECTED) {
- if(ebone->parent) {
- /* for nice selection */
- ebone->parent->flag &= ~(BONE_TIPSEL);
+
+ if(arm->flag & ARM_MIRROR_EDIT)
+ flipbone = armature_bone_get_mirrored(ebone);
- if(val==1) ebone->parent= NULL;
- ebone->flag &= ~BONE_CONNECTED;
- }
+ if (flipbone)
+ editbone_clear_parent(flipbone, val);
+ editbone_clear_parent(ebone, val);
}
}
}
@@ -3179,3 +3223,4 @@
+
Modified: trunk/blender/source/blender/src/poseobject.c
===================================================================
--- trunk/blender/source/blender/src/poseobject.c 2007-11-21 22:44:17 UTC (rev 12646)
+++ trunk/blender/source/blender/src/poseobject.c 2007-11-21 23:22:56 UTC (rev 12647)
@@ -917,6 +917,7 @@
else if (G.obedit) {
/* the check for editbone layer moving needs to occur before posemode one to work */
EditBone *ebo;
+ EditBone *flipBone;
for (ebo= G.edbo.first; ebo; ebo= ebo->next) {
if (arm->layer & ebo->layer) {
@@ -931,8 +932,14 @@
for (ebo= G.edbo.first; ebo; ebo= ebo->next) {
if (arm->layer & ebo->layer) {
- if (ebo->flag & BONE_SELECTED)
+ if (ebo->flag & BONE_SELECTED) {
ebo->layer= lay;
+ if (arm->flag & ARM_MIRROR_EDIT) {
+ flipBone = armature_bone_get_mirrored(ebo);
+ if (flipBone)
+ flipBone->layer = lay;
+ }
+ }
}
}
More information about the Bf-blender-cvs
mailing list