[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15039] trunk/blender/source/blender/src/ editarmature.c: Fill Bone Between Joints:
Joshua Leung
aligorith at gmail.com
Thu May 29 03:04:24 CEST 2008
Revision: 15039
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15039
Author: aligorith
Date: 2008-05-29 03:04:12 +0200 (Thu, 29 May 2008)
Log Message:
-----------
Fill Bone Between Joints:
This tool now parents the newly created bone to whichever bone acted as it's 'head' point. It also sets the connected-to-parent flag.
Modified Paths:
--------------
trunk/blender/source/blender/src/editarmature.c
Modified: trunk/blender/source/blender/src/editarmature.c
===================================================================
--- trunk/blender/source/blender/src/editarmature.c 2008-05-29 00:42:22 UTC (rev 15038)
+++ trunk/blender/source/blender/src/editarmature.c 2008-05-29 01:04:12 UTC (rev 15039)
@@ -2396,6 +2396,7 @@
else if (count == 2) {
EditBonePoint *ebp, *ebp2;
float head[3], tail[3];
+ short headtail = 0;
/* check that the points don't belong to the same bone */
ebp= (EditBonePoint *)points.first;
@@ -2420,7 +2421,7 @@
float distA, distB;
/* get cursor location */
- VECCOPY (curs, give_cursor());
+ VECCOPY(curs, give_cursor());
Mat4Invert(G.obedit->imat, G.obedit->obmat);
Mat4MulVecfl(G.obedit->imat, curs);
@@ -2432,26 +2433,47 @@
distB= VecLength(vecB);
/* compare distances - closer one therefore acts as direction for bone to go */
- if (distA < distB) {
- VECCOPY(head, ebp2->vec);
- VECCOPY(tail, ebp->vec);
- }
- else {
- VECCOPY(head, ebp->vec);
- VECCOPY(tail, ebp2->vec);
- }
+ headtail= (distA < distB) ? 2 : 1;
}
else if (ebp->head_owner) {
+ headtail = 1;
+ }
+ else if (ebp2->head_owner) {
+ headtail = 2;
+ }
+
+ /* assign head/tail combinations */
+ if (headtail == 1) {
VECCOPY(head, ebp->vec);
VECCOPY(tail, ebp2->vec);
}
- else if (ebp2->head_owner) {
+ else if (headtail == 2) {
VECCOPY(head, ebp2->vec);
VECCOPY(tail, ebp->vec);
}
- /* add new bone */
- newbone= add_points_bone(head, tail);
+ /* add new bone and parent it to the appropriate end */
+ if (headtail) {
+ newbone= add_points_bone(head, tail);
+
+ /* do parenting (will need to set connected flag too) */
+ if (headtail == 1) {
+ /* ebp tail or head - tail gets priority */
+ if (ebp->tail_owner)
+ newbone->parent= ebp->tail_owner;
+ else
+ newbone->parent= ebp->head_owner;
+ }
+ else {
+ /* ebp2 tail or head - tail gets priority */
+ if (ebp2->tail_owner)
+ newbone->parent= ebp2->tail_owner;
+ else
+ newbone->parent= ebp2->head_owner;
+ }
+
+ newbone->flag |= BONE_CONNECTED;
+ }
}
else {
// FIXME.. figure out a method for multiple bones
More information about the Bf-blender-cvs
mailing list