Sketch Retargetting: Rolling bone perpendicular to stroke's normal is now optional.
authorMartin Poirier <theeth@yahoo.com>
Mon, 3 Nov 2008 17:54:12 +0000 (17:54 +0000)
committerMartin Poirier <theeth@yahoo.com>
Mon, 3 Nov 2008 17:54:12 +0000 (17:54 +0000)
Normal pointer added to reeb nodes (the last bone in a chain needs it and can't get it from the embedding).

source/blender/include/reeb.h
source/blender/makesdna/DNA_scene_types.h
source/blender/src/drawview.c
source/blender/src/editarmature_retarget.c
source/blender/src/editarmature_sketch.c

index 5dcbad7e80b2188002b2a5e75e3f9010dbf069fa..6496eb34836b26d63c4f3e120e43e47ae82b7192 100644 (file)
@@ -80,6 +80,8 @@ typedef struct ReebNode {
        int symmetry_flag;
        float symmetry_axis[3];
        /*********************************/
+       
+       float *no;
 
        int index;
        float weight;
index 6f33ece2ee9d39a780affd65609ff944edbd71d8..3899600af30b40c77c33f817d4cdef2e43acc0bb 100644 (file)
@@ -446,10 +446,11 @@ typedef struct ToolSettings {
        char bone_sketching;
        char bone_sketching_convert;
        char skgen_subdivision_number;
+       char skgen_retarget_options;
        
        /* Alt+RMB option */
        char edge_mode;
-       char pad3[4];
+       char pad3[3];
 } ToolSettings;
 
 /* Used by all brushes to store their properties, which can be directly set
@@ -883,6 +884,10 @@ typedef struct Scene {
 #define        SK_CONVERT_CUT_CORRELATION              3
 #define        SK_CONVERT_RETARGET                             4
 
+/* toolsettings->skgen_retarget_options */
+#define        SK_RETARGET_ROLL                                1
+
+
 #ifdef __cplusplus
 }
 #endif
index 7f1e8122da68766cca7baf07e1b6661eabe13bd0..d799d31c7423f81c76b03b34851e0b0acfbda652 100644 (file)
@@ -2321,18 +2321,19 @@ static void view3d_panel_bonesketch_spaces(short cntrl)
                uiBlockBeginAlign(block);
 
                uiDefButC(block, ROW, B_REDR, "Length", 10, yco, 60, 19, &G.scene->toolsettings->bone_sketching_convert, 0, SK_CONVERT_CUT_LENGTH, 0, 0,                                "Subdivide arcs in bones of equal length");
-               uiDefButF(block, NUM, B_REDR,                                   "L:",           70, yco, 90, 19, &G.scene->toolsettings->skgen_length_limit,0.1,50.0, 10, 0,            "Maximum length of the bones when subdividing");
+               uiDefButF(block, NUM, B_REDR,                                   "L:",           70, yco, 90, 19, &G.scene->toolsettings->skgen_length_limit,0.1,50.0, 10, 0,            "Maximum length of the subdivided bones");
                yco -= 20;
 
                uiDefButC(block, ROW, B_REDR, "Correlation",    10, yco, 60, 19, &G.scene->toolsettings->bone_sketching_convert, 0, SK_CONVERT_CUT_CORRELATION, 0, 0,                                   "Subdivide arcs based on correlation");
-               uiDefButF(block, NUM, B_REDR,                                            "T:",                  70, yco, 90, 19, &G.scene->toolsettings->skgen_correlation_limit,0.0, 1.0, 0.01, 0,     "Specify the threshold correlation for subdivision");
+               uiDefButF(block, NUM, B_REDR,                                            "T:",                  70, yco, 90, 19, &G.scene->toolsettings->skgen_correlation_limit,0.0, 1.0, 0.01, 0,     "Correlation threshold for subdivision");
                yco -= 20;
        
                uiDefButC(block, ROW, B_REDR, "Fixed",          10, yco, 60, 19, &G.scene->toolsettings->bone_sketching_convert, 0, SK_CONVERT_CUT_FIXED, 0, 0,                                 "Subdivide arcs based on a fixed number of bones");
-               uiDefButC(block, NUM, B_REDR,                                   "N:",           70, yco, 90, 19, &G.scene->toolsettings->skgen_subdivision_number,1, 100, 1, 5, "Specify the bones to subdivide into");
+               uiDefButC(block, NUM, B_REDR,                                   "N:",           70, yco, 90, 19, &G.scene->toolsettings->skgen_subdivision_number,1, 100, 1, 5, "Number of subdivided bones");
                yco -= 20;
 
-               uiDefButC(block, ROW, B_REDR, "Retarget",               10, yco,150, 19, &G.scene->toolsettings->bone_sketching_convert, 0, SK_CONVERT_RETARGET, 0, 0,                                  "Subdivide arcs based on a fixed number of bones");
+               uiDefButC(block, ROW, B_REDR, "Retarget",               10, yco,80, 19, &G.scene->toolsettings->bone_sketching_convert, 0, SK_CONVERT_RETARGET, 0, 0,                                   "Retarget selected bones to stroke");
+               uiDefButBitC(block, TOG, SK_RETARGET_ROLL, B_DIFF,      "Roll",         90, yco, 70,19, &G.scene->toolsettings->skgen_retarget_options, 0, 0, 0, 0,                             "Roll bones perpendicular to view");
                /* button here to select what to do (copy or not), template, ...*/
                yco -= 20;
 
index 34c5064e5f3f79d7dd9034d31f894b66b18083b4..d54389e7d80fa6369934ce34f23817329cbd96b9 100644 (file)
@@ -2264,6 +2264,7 @@ static void retargetArctoArcAggresive(RigGraph *rigg, RigArc *iarc, RigNode *ino
                else
                {
                        vec1 = node_end->p;
+                       no = node_end->no;
                }
                
                if (edge->bone)
@@ -2349,7 +2350,7 @@ static void retargetArctoArcLength(RigGraph *rigg, RigArc *iarc, RigNode *inode_
                if (bucket == NULL)
                {
                        vec1 = node_end->p;
-                       no = NULL;
+                       no = node_end->no;
                }
 
                /* no need to move virtual edges (space between unconnected bones) */           
@@ -2398,11 +2399,11 @@ void *exec_retargetArctoArc(void *param)
 
                if (testFlipArc(iarc, inode_start))
                {
-                       repositionBone(rigg, edge, earc->tail->p, earc->head->p, NULL);
+                       repositionBone(rigg, edge, earc->tail->p, earc->head->p, earc->head->no);
                }
                else
                {
-                       repositionBone(rigg, edge, earc->head->p, earc->tail->p, NULL);
+                       repositionBone(rigg, edge, earc->head->p, earc->tail->p, earc->tail->no);
                }
        }
        else
index f1ca1bd03878f8ee1613702c91a1b16039e17fb3..aeff63ce4d7cbe99fbad17c59b248f9df901323b 100644 (file)
@@ -362,6 +362,11 @@ ReebNode *pointToNode(SK_Point *pt)
        node = MEM_callocN(sizeof(ReebNode), "reeb node");
        VECCOPY(node->p, pt->p);
        
+       if (G.scene->toolsettings->skgen_retarget_options & SK_RETARGET_ROLL)
+       {
+               node->no = pt->no;
+       }
+       
        return node;
 }
 
@@ -380,7 +385,10 @@ ReebArc *strokeToArc(SK_Stroke *stk)
        for (i = 0; i < arc->bcount; i++)
        {
                VECCOPY(arc->buckets[i].p, stk->points[i + 1].p);
-               arc->buckets[i].no = stk->points[i + 1].no;
+               if (G.scene->toolsettings->skgen_retarget_options & SK_RETARGET_ROLL)
+               {
+                       arc->buckets[i].no = stk->points[i + 1].no;
+               }
        }
        
        return arc;