[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17359] branches/etch-a-ton/source/blender : Correct stroke normal alignment for retargetting ( transform into edit armature local space)
Martin Poirier
theeth at yahoo.com
Fri Nov 7 20:44:02 CET 2008
Revision: 17359
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17359
Author: theeth
Date: 2008-11-07 20:44:02 +0100 (Fri, 07 Nov 2008)
Log Message:
-----------
Correct stroke normal alignment for retargetting (transform into edit armature local space)
Modified Paths:
--------------
branches/etch-a-ton/source/blender/include/reeb.h
branches/etch-a-ton/source/blender/src/editarmature_retarget.c
branches/etch-a-ton/source/blender/src/editarmature_sketch.c
Modified: branches/etch-a-ton/source/blender/include/reeb.h
===================================================================
--- branches/etch-a-ton/source/blender/include/reeb.h 2008-11-07 19:21:52 UTC (rev 17358)
+++ branches/etch-a-ton/source/blender/include/reeb.h 2008-11-07 19:44:02 UTC (rev 17359)
@@ -63,7 +63,7 @@
float val;
int nv;
float p[3];
- float *no; /* if present, normal of the bucket */
+ float no[3]; /* if non-null, normal of the bucket */
} EmbedBucket;
typedef struct ReebNode {
@@ -81,7 +81,7 @@
float symmetry_axis[3];
/*********************************/
- float *no;
+ float no[3];
int index;
float weight;
Modified: branches/etch-a-ton/source/blender/src/editarmature_retarget.c
===================================================================
--- branches/etch-a-ton/source/blender/src/editarmature_retarget.c 2008-11-07 19:21:52 UTC (rev 17358)
+++ branches/etch-a-ton/source/blender/src/editarmature_retarget.c 2008-11-07 19:44:02 UTC (rev 17359)
@@ -162,12 +162,12 @@
VECCOPY(up_axis, mat[2]);
}
-float rollBoneByQuatAligned(EditBone *bone, float old_up_axis[3], float quat[4], float qroll[4], float aligned_axis[3])
+float rollBoneByQuatAligned(EditBone *bone, float old_up_axis[3], float qrot[4], float qroll[4], float aligned_axis[3])
{
float nor[3], new_up_axis[3], x_axis[3], z_axis[3];
VECCOPY(new_up_axis, old_up_axis);
- QuatMulVecf(quat, new_up_axis);
+ QuatMulVecf(qrot, new_up_axis);
VecSubf(nor, bone->tail, bone->head);
@@ -207,6 +207,8 @@
VECCOPY(new_up_axis, old_up_axis);
QuatMulVecf(quat, new_up_axis);
+ Normalize(new_up_axis);
+
return rollBoneToVector(bone, new_up_axis);
}
@@ -820,7 +822,6 @@
/* if owner is a control bone, link with it */
if (link && link->link)
{
- printf("%s -constraint- %s\n", ctrl->bone->name, link->bone->name);
RIG_parentControl(ctrl, link->bone);
found = 1;
break;
@@ -839,7 +840,6 @@
/* check if parent is already linked */
if (ctrl_parent && ctrl_parent->link)
{
- printf("%s -parent- %s\n", ctrl->bone->name, ctrl_parent->bone->name);
RIG_parentControl(ctrl, ctrl_parent->bone);
change = 1;
}
@@ -851,7 +851,6 @@
/* if a child is linked, link to that one */
if (ctrl_child->link && ctrl_child->bone->parent == ctrl->bone)
{
- printf("%s -child- %s\n", ctrl->bone->name, ctrl_child->bone->name);
RIG_parentControl(ctrl, ctrl_child->bone);
change = 1;
break;
@@ -1656,7 +1655,7 @@
}
-static void repositionBone(RigGraph *rigg, RigEdge *edge, float vec0[3], float vec1[3], float *up_axis)
+static void repositionBone(RigGraph *rigg, RigEdge *edge, float vec0[3], float vec1[3], float up_axis[3])
{
EditBone *bone;
RigControl *ctrl;
@@ -1679,7 +1678,7 @@
VECCOPY(bone->head, vec0);
VECCOPY(bone->tail, vec1);
- if (up_axis != NULL)
+ if (!VecIsNull(up_axis))
{
float qroll[4];
Modified: branches/etch-a-ton/source/blender/src/editarmature_sketch.c
===================================================================
--- branches/etch-a-ton/source/blender/src/editarmature_sketch.c 2008-11-07 19:21:52 UTC (rev 17358)
+++ branches/etch-a-ton/source/blender/src/editarmature_sketch.c 2008-11-07 19:44:02 UTC (rev 17359)
@@ -472,7 +472,7 @@
}
/*********************** CONVERSION ***************************/
-ReebNode *sk_pointToNode(SK_Point *pt, float imat[][4])
+ReebNode *sk_pointToNode(SK_Point *pt, float imat[][4], float tmat[][3])
{
ReebNode *node;
@@ -482,20 +482,21 @@
if (G.scene->toolsettings->skgen_retarget_options & SK_RETARGET_ROLL)
{
- node->no = pt->no;
+ VECCOPY(node->no, pt->no);
+ Mat3MulVecfl(tmat, node->no);
}
return node;
}
-ReebArc *sk_strokeToArc(SK_Stroke *stk, float imat[][4])
+ReebArc *sk_strokeToArc(SK_Stroke *stk, float imat[][4], float tmat[][3])
{
ReebArc *arc;
int i;
arc = MEM_callocN(sizeof(ReebArc), "reeb arc");
- arc->head = sk_pointToNode(stk->points, imat);
- arc->tail = sk_pointToNode(sk_lastStrokePoint(stk), imat);
+ arc->head = sk_pointToNode(stk->points, imat, tmat);
+ arc->tail = sk_pointToNode(sk_lastStrokePoint(stk), imat, tmat);
arc->bcount = stk->nb_points - 2; /* first and last are nodes, don't count */
arc->buckets = MEM_callocN(sizeof(EmbedBucket) * arc->bcount, "Buckets");
@@ -507,7 +508,8 @@
if (G.scene->toolsettings->skgen_retarget_options & SK_RETARGET_ROLL)
{
- arc->buckets[i].no = stk->points[i + 1].no;
+ VECCOPY(arc->buckets[i].no, stk->points[i + 1].no);
+ Mat3MulVecfl(tmat, arc->buckets[i].no);
}
}
@@ -517,11 +519,15 @@
void sk_retargetStroke(SK_Stroke *stk)
{
float imat[4][4];
+ float tmat[3][3];
ReebArc *arc;
Mat4Invert(imat, G.obedit->obmat);
- arc = sk_strokeToArc(stk, imat);
+ Mat3CpyMat4(tmat, G.obedit->obmat);
+ Mat3Transp(tmat);
+
+ arc = sk_strokeToArc(stk, imat, tmat);
BIF_retargetArc(arc);
More information about the Bf-blender-cvs
mailing list