etch-a-ton
authorMartin Poirier <theeth@yahoo.com>
Tue, 7 Apr 2009 20:05:32 +0000 (20:05 +0000)
committerMartin Poirier <theeth@yahoo.com>
Tue, 7 Apr 2009 20:05:32 +0000 (20:05 +0000)
Use head not tail normal for bone orientation.
Simplify roll to normal a bit.

source/blender/src/editarmature_generate.c
source/blender/src/editarmature_sketch.c

index ad312f079bd723e863c28f0dd697b4ed2691be8d..930ca263499620cf4a2498f541fe0e3d6a8e7ce9 100644 (file)
@@ -51,14 +51,14 @@ void setBoneRollFromNormal(EditBone *bone, float *no, float invmat[][4], float t
 {
        if (no != NULL && !VecIsNull(no))
        {
-               float tangent[3], cotangent[3], normal[3];
+               float tangent[3], vec[3], normal[3];
 
                VECCOPY(normal, no);    
                Mat3MulVecfl(tmat, normal);
 
                VecSubf(tangent, bone->tail, bone->head);
-               Crossf(cotangent, tangent, normal);
-               Crossf(normal, cotangent, tangent);
+               Projf(vec, tangent, normal);
+               VecSubf(normal, normal, vec);
                
                Normalize(normal);
                
index 38e44319b47b8c9dd5378beb0828b2330794be44..91aadd07392a657fac7ec39b1dcae94b1ea7fdbc 100644 (file)
@@ -1011,7 +1011,22 @@ void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int end)
                }
                
                glEnd();
-       
+
+#if 0  
+               glColor3f(0, 0, 1);
+               glBegin(GL_LINES);
+
+               for (i = 0; i < stk->nb_points; i++)
+               {
+                       float *p = stk->points[i].p;
+                       float *no = stk->points[i].no;
+                       glVertex3fv(p);
+                       glVertex3f(p[0] + no[0], p[1] + no[1], p[2] + no[2]);
+               }
+               
+               glEnd();
+#endif
+
                glColor3f(0, 0, 0);
                glBegin(GL_POINTS);
        
@@ -1961,7 +1976,7 @@ void sk_convertStroke(SK_Stroke *stk)
 
                                        Mat4MulVecfl(invmat, bone->head);
                                        Mat4MulVecfl(invmat, bone->tail);
-                                       setBoneRollFromNormal(bone, pt->no, invmat, tmat);
+                                       setBoneRollFromNormal(bone, head->no, invmat, tmat);
                                }
                                
                                new_parent = bone;