Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2005-10-04 00:53:54 +0400
committerTon Roosendaal <ton@blender.org>2005-10-04 00:53:54 +0400
commit7c199946ec13db309b79797358cb8308943ed3cf (patch)
tree585c92a3837e6b650f3ece5d667a679eaf119af5 /source
parent6cb422b88611204b22f5636b78858efb35e08f37 (diff)
Bugfix #3143
CTRL+click adding bones now respects X-axis mirror edit too.
Diffstat (limited to 'source')
-rw-r--r--source/blender/src/editarmature.c78
1 files changed, 50 insertions, 28 deletions
diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c
index bac31420e2f..301658f5339 100644
--- a/source/blender/src/editarmature.c
+++ b/source/blender/src/editarmature.c
@@ -1162,11 +1162,11 @@ void undo_push_armature(char *name)
/* *************** Adding stuff in editmode *************** */
/* default bone add, returns it selected, but without tail set */
-static EditBone *add_editbone(void)
+static EditBone *add_editbone(char *name)
{
EditBone *bone= MEM_callocN(sizeof(EditBone), "eBone");
- strcpy (bone->name,"Bone");
+ strcpy (bone->name, name);
unique_editbone_name (bone->name);
BLI_addtail(&G.edbo, bone);
@@ -1204,7 +1204,7 @@ static void add_primitive_bone(Object *ob)
deselectall_armature(0);
/* Create a bone */
- bone= add_editbone();
+ bone= add_editbone("Bone");
VECCOPY(bone->head, curs);
VecAddf(bone->tail, bone->head, imat[1]); // bone with unit length 1
@@ -1248,9 +1248,10 @@ void add_primitiveArmature(int type)
/* the ctrl-click method */
void addvert_armature(void)
{
- EditBone *ebone, *newbone;
+ bArmature *arm= G.obedit->data;
+ EditBone *ebone, *newbone, *flipbone;
float *curs, mat[3][3],imat[3][3];
- int to_root= 0;
+ int a, to_root= 0;
TEST_EDITARMATURE;
@@ -1268,32 +1269,53 @@ void addvert_armature(void)
}
deselectall_armature(0);
- newbone= add_editbone();
- newbone->flag |= BONE_ACTIVE;
- if(to_root) {
- VECCOPY(newbone->head, ebone->head);
- newbone->rad_head= ebone->rad_tail;
- newbone->parent= ebone->parent;
- }
- else {
- VECCOPY(newbone->head, ebone->tail);
- newbone->rad_head= ebone->rad_tail;
- newbone->parent= ebone;
- newbone->flag |= BONE_CONNECTED;
+ /* we re-use code for mirror editing... */
+ flipbone= NULL;
+ if(arm->flag & ARM_MIRROR_EDIT)
+ flipbone= armature_bone_get_mirrored(ebone);
+
+ for(a=0; a<2; a++) {
+ if(a==1) {
+ if(flipbone==NULL)
+ break;
+ else {
+ SWAP(EditBone *, flipbone, ebone);
+ }
+ }
+
+ newbone= add_editbone(ebone->name);
+ newbone->flag |= BONE_ACTIVE;
+
+ if(to_root) {
+ VECCOPY(newbone->head, ebone->head);
+ newbone->rad_head= ebone->rad_tail;
+ newbone->parent= ebone->parent;
+ }
+ else {
+ VECCOPY(newbone->head, ebone->tail);
+ newbone->rad_head= ebone->rad_tail;
+ newbone->parent= ebone;
+ newbone->flag |= BONE_CONNECTED;
+ }
+
+ curs= give_cursor();
+ VECCOPY(newbone->tail, curs);
+ VecSubf(newbone->tail, newbone->tail, G.obedit->obmat[3]);
+
+ if(a==1)
+ newbone->tail[0]= -newbone->tail[0];
+
+ Mat3CpyMat4(mat, G.obedit->obmat);
+ Mat3Inv(imat, mat);
+ Mat3MulVecfl(imat, newbone->tail);
+
+ newbone->length= VecLenf(newbone->head, newbone->tail);
+ newbone->rad_tail= newbone->length*0.05f;
+ newbone->dist= newbone->length*0.1f;
+
}
- curs= give_cursor();
- VECCOPY(newbone->tail, curs);
- VecSubf(newbone->tail, newbone->tail, G.obedit->obmat[3]);
-
- Mat3CpyMat4(mat, G.obedit->obmat);
- Mat3Inv(imat, mat);
- Mat3MulVecfl(imat, newbone->tail);
-
- newbone->length= VecLenf(newbone->head, newbone->tail);
- newbone->rad_tail= newbone->length*0.05f;
- newbone->dist= newbone->length*0.1f;
countall();