Revision: 15475
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15475
Author:   theeth
Date:     2008-07-07 22:31:53 +0200 (Mon, 07 Jul 2008)

Log Message:
-----------
First draft: Use multiresolution graph for retargetting (enables bypassing 
small appendages that don't correspond to anything on the armature).

Modified Paths:
--------------
    branches/harmonic-skeleton/source/blender/blenlib/BLI_graph.h
    branches/harmonic-skeleton/source/blender/blenlib/intern/graph.c
    branches/harmonic-skeleton/source/blender/include/reeb.h
    branches/harmonic-skeleton/source/blender/src/autoarmature.c
    branches/harmonic-skeleton/source/blender/src/buttons_editing.c
    branches/harmonic-skeleton/source/blender/src/reeb.c

Modified: branches/harmonic-skeleton/source/blender/blenlib/BLI_graph.h
===================================================================
--- branches/harmonic-skeleton/source/blender/blenlib/BLI_graph.h       
2008-07-07 20:28:56 UTC (rev 15474)
+++ branches/harmonic-skeleton/source/blender/blenlib/BLI_graph.h       
2008-07-07 20:31:53 UTC (rev 15475)
@@ -78,6 +78,8 @@
 
 int BLI_FlagSubgraphs(BGraph *graph);
 
+int BLI_subtreeShape(BNode *node, BArc *rootArc, int include_root);
+
 void BLI_replaceNode(BGraph *graph, BNode *node_src, BNode *node_replaced);
 void BLI_removeDoubleNodes(BGraph *graph, float limit);
 

Modified: branches/harmonic-skeleton/source/blender/blenlib/intern/graph.c
===================================================================
--- branches/harmonic-skeleton/source/blender/blenlib/intern/graph.c    
2008-07-07 20:28:56 UTC (rev 15474)
+++ branches/harmonic-skeleton/source/blender/blenlib/intern/graph.c    
2008-07-07 20:31:53 UTC (rev 15475)
@@ -321,34 +321,40 @@
 
 /*********************************** GRAPH AS TREE FUNCTIONS 
*******************************************/
 
-int BLI_subtreeShape(BNode *node, BArc *rootArc)
+int BLI_subtreeShape(BNode *node, BArc *rootArc, int include_root)
 {
        int depth = 0;
        
-       /* Base case, no arcs leading away */
-       if (node->arcs == NULL || *(node->arcs) == NULL)
+       if (include_root)
        {
-               return 0;
+               BNode *newNode = BLI_otherNode(rootArc, node);
+               depth = BLI_subtreeShape(newNode, rootArc, 0);
        }
        else
        {
-               int i;
-
-               for(i = 0; i < node->degree; i++)
+               /* Base case, no arcs leading away */
+               if (node->arcs == NULL || *(node->arcs) == NULL)
                {
-                       BArc *arc = node->arcs[i];
-                       
-                       /* only arcs that go down the tree */
-                       if (arc != rootArc)
+                       return 0;
+               }
+               else
+               {
+                       int i;
+       
+                       for(i = 0; i < node->degree; i++)
                        {
-                               BNode *newNode = BLI_otherNode(arc, node);
-                               //depth = MAX2(depth, BLI_subtreeShape(newNode, 
arc));
-                               depth += BLI_subtreeShape(newNode, arc);
+                               BArc *arc = node->arcs[i];
+                               
+                               /* only arcs that go down the tree */
+                               if (arc != rootArc)
+                               {
+                                       BNode *newNode = BLI_otherNode(arc, 
node);
+                                       depth += BLI_subtreeShape(newNode, arc, 
0);
+                               }
                        }
                }
        }
        
-       //return depth + 1;
        return 10 * depth + 1;
 }
 
@@ -776,7 +782,7 @@
                        BNode *connectedNode = BLI_otherNode(connectedArc, 
node);
                        
                        /* symmetry level is positive value, negative values is 
subtree depth */
-                       connectedArc->symmetry_level = 
-BLI_subtreeShape(connectedNode, connectedArc);
+                       connectedArc->symmetry_level = 
-BLI_subtreeShape(connectedNode, connectedArc, 0);
                }
        }
 

Modified: branches/harmonic-skeleton/source/blender/include/reeb.h
===================================================================
--- branches/harmonic-skeleton/source/blender/include/reeb.h    2008-07-07 
20:28:56 UTC (rev 15474)
+++ branches/harmonic-skeleton/source/blender/include/reeb.h    2008-07-07 
20:31:53 UTC (rev 15475)
@@ -163,6 +163,8 @@
 void BIF_GlobalReebGraphFromEditMesh(void);
 void BIF_GlobalReebFree(void);
 
+ReebNode *BIF_otherNodeFromIndex(ReebArc *arc, ReebNode *node);
+
 void REEB_freeGraph(ReebGraph *rg);
 void REEB_exportGraph(ReebGraph *rg, int count);
 void REEB_draw();

Modified: branches/harmonic-skeleton/source/blender/src/autoarmature.c
===================================================================
--- branches/harmonic-skeleton/source/blender/src/autoarmature.c        
2008-07-07 20:28:56 UTC (rev 15474)
+++ branches/harmonic-skeleton/source/blender/src/autoarmature.c        
2008-07-07 20:31:53 UTC (rev 15475)
@@ -1257,11 +1257,22 @@
                        next_earc->symmetry_group == symmetry_group &&
                        next_earc->symmetry_level == symmetry_level)
                {
+                       int ishape, eshape;
 
                        printf("-----------------------\n");
                        printf("CORRESPONDING ARC FOUND\n");
                        RIG_printArcBones(next_iarc);
                        printf("flag %i -- symmetry level %i -- symmetry flag 
%i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag);
+                       
+                       ishape = BLI_subtreeShape((BNode*)start_node, 
(BArc*)next_iarc, 1);
+                       eshape = BLI_subtreeShape((BNode*)enode, 
(BArc*)next_earc, 1);
+                       
+                       while (ishape > eshape && next_earc->link)
+                       {
+                               next_earc = next_earc->link;
+                               enode = next_earc->head; //enode->link;
+                               eshape = BLI_subtreeShape((BNode*)enode, 
(BArc*)next_earc, 1);
+                       } 
 
                        next_earc->flag = 1; // mark as taken
                        next_iarc->link = next_earc;
@@ -1299,7 +1310,7 @@
                
        retargetArctoArc(iarc);
        
-       enode = (ReebNode*)BLI_otherNode((BArc*)earc, (BNode*)enode);
+       enode = BIF_otherNodeFromIndex(earc, enode);
        inode = (RigNode*)BLI_otherNode((BArc*)iarc, (BNode*)inode);
        
        inode->link = enode;

Modified: branches/harmonic-skeleton/source/blender/src/buttons_editing.c
===================================================================
--- branches/harmonic-skeleton/source/blender/src/buttons_editing.c     
2008-07-07 20:28:56 UTC (rev 15474)
+++ branches/harmonic-skeleton/source/blender/src/buttons_editing.c     
2008-07-07 20:31:53 UTC (rev 15475)
@@ -5027,10 +5027,10 @@
        uiDefButS(block, NUM, B_DIFF, "Resolution:",                            
                        1025,150,225,19, 
&G.scene->toolsettings->skgen_resolution,10.0,1000.0, 0, 0,            
"Specifies the resolution of the graph's embedding");
        uiDefButBitS(block, TOG, SKGEN_HARMONIC, B_DIFF,                "H",    
                1250,150, 25,19, &G.scene->toolsettings->skgen_options, 0, 0, 
0, 0,                                     "Apply harmonic smoothing to the 
weighting");
        uiDefButBitS(block, TOG, SKGEN_FILTER_INTERNAL, B_DIFF, "Filter In",    
1025,130, 83,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,             
                        "Filter internal small arcs from graph");
-       uiDefButF(block, NUM, B_DIFF,                                           
        "",                             1111,130,164,19, 
&G.scene->toolsettings->skgen_threshold_internal,0.0, 1.0, 10, 0,      "Specify 
the threshold ratio for filtering internal arcs");
+       uiDefButF(block, NUM, B_DIFF,                                           
        "",                             1111,130,164,19, 
&G.scene->toolsettings->skgen_threshold_internal,0.0, 5.0, 10, 0,      "Specify 
the threshold ratio for filtering internal arcs");
        uiDefButBitS(block, TOG, SKGEN_FILTER_EXTERNAL, B_DIFF, "Filter Ex",    
1025,110, 53,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,             
                        "Filter external small arcs from graph");
        uiDefButBitS(block, TOG, SKGEN_FILTER_SMART,    B_DIFF, "Sm",           
        1078,110, 30,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,     
                                "Smart Filtering");
-       uiDefButF(block, NUM, B_DIFF,                                           
        "",                             1111,110,164,19, 
&G.scene->toolsettings->skgen_threshold_external,0.0, 1.0, 10, 0,      "Specify 
the threshold ratio for filtering external arcs");
+       uiDefButF(block, NUM, B_DIFF,                                           
        "",                             1111,110,164,19, 
&G.scene->toolsettings->skgen_threshold_external,0.0, 5.0, 10, 0,      "Specify 
the threshold ratio for filtering external arcs");
        uiBlockEndAlign(block);
        
        uiDefButBitS(block, TOG, SKGEN_DISP_LENGTH, REDRAWVIEW3D,       
"Length",                       1025, 60, 83,19, 
&G.scene->toolsettings->skgen_options, 0, 0, 0, 0,             "Show Length");
@@ -5054,10 +5054,10 @@
        uiDefButS(block, NUM, B_DIFF, "Resolution:",                            
                        1025,150,225,19, 
&G.scene->toolsettings->skgen_resolution,10.0,1000.0, 0, 0,            
"Specifies the resolution of the graph's embedding");
        uiDefButBitS(block, TOG, SKGEN_HARMONIC, B_DIFF,                "H",    
                1250,150, 25,19, &G.scene->toolsettings->skgen_options, 0, 0, 
0, 0,                                     "Apply harmonic smoothing to the 
weighting");
        uiDefButBitS(block, TOG, SKGEN_FILTER_INTERNAL, B_DIFF, "Filter In",    
1025,130, 83,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,             
                        "Filter internal small arcs from graph");
-       uiDefButF(block, NUM, B_DIFF,                                           
        "",                             1111,130,164,19, 
&G.scene->toolsettings->skgen_threshold_internal,0.0, 1.0, 10, 0,      "Specify 
the threshold ratio for filtering internal arcs");
+       uiDefButF(block, NUM, B_DIFF,                                           
        "",                             1111,130,164,19, 
&G.scene->toolsettings->skgen_threshold_internal,0.0, 5.0, 10, 0,      "Specify 
the threshold ratio for filtering internal arcs");
        uiDefButBitS(block, TOG, SKGEN_FILTER_EXTERNAL, B_DIFF, "Filter Ex",    
1025,110, 53,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,             
                        "Filter external small arcs from graph");
        uiDefButBitS(block, TOG, SKGEN_FILTER_SMART,    B_DIFF, "Sm",           
        1078,110, 30,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,     
                                "Smart Filtering");
-       uiDefButF(block, NUM, B_DIFF,                                           
        "",                             1111,110,164,19, 
&G.scene->toolsettings->skgen_threshold_external,0.0, 1.0, 10, 0,      "Specify 
the threshold ratio for filtering external arcs");
+       uiDefButF(block, NUM, B_DIFF,                                           
        "",                             1111,110,164,19, 
&G.scene->toolsettings->skgen_threshold_external,0.0, 5.0, 10, 0,      "Specify 
the threshold ratio for filtering external arcs");
        uiBlockEndAlign(block);
 
        uiDefButF(block, NUM, B_DIFF,                                           
        "Ang:",                 1025, 60, 83,19, 
&G.scene->toolsettings->skgen_retarget_angle_weight, 0, 10, 1, 0,              
"Angle Weight");
@@ -5090,10 +5090,10 @@
        uiDefButS(block, NUM, B_DIFF, "Resolution:",                            
                        1025,150,225,19, 
&G.scene->toolsettings->skgen_resolution,10.0,1000.0, 0, 0,            
"Specifies the resolution of the graph's embedding");
        uiDefButBitS(block, TOG, SKGEN_HARMONIC, B_DIFF,                "H",    
                1250,150, 25,19, &G.scene->toolsettings->skgen_options, 0, 0, 
0, 0,                                     "Apply harmonic smoothing to the 
weighting");
        uiDefButBitS(block, TOG, SKGEN_FILTER_INTERNAL, B_DIFF, "Filter In",    
1025,130, 83,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,             
                        "Filter internal small arcs from graph");
-       uiDefButF(block, NUM, B_DIFF,                                           
        "",                             1111,130,164,19, 
&G.scene->toolsettings->skgen_threshold_internal,0.0, 1.0, 10, 0,      "Specify 
the threshold ratio for filtering internal arcs");
+       uiDefButF(block, NUM, B_DIFF,                                           
        "",                             1111,130,164,19, 
&G.scene->toolsettings->skgen_threshold_internal,0.0, 5.0, 10, 0,      "Specify 
the threshold ratio for filtering internal arcs");
        uiDefButBitS(block, TOG, SKGEN_FILTER_EXTERNAL, B_DIFF, "Filter Ex",    
1025,110, 53,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,             
                        "Filter external small arcs from graph");
        uiDefButBitS(block, TOG, SKGEN_FILTER_SMART,    B_DIFF, "Sm",           
        1078,110, 30,19, &G.scene->toolsettings->skgen_options, 0, 0, 0, 0,     
                                "Smart Filtering");
-       uiDefButF(block, NUM, B_DIFF,                                           
        "",                             1111,110,164,19, 
&G.scene->toolsettings->skgen_threshold_external,0.0, 1.0, 10, 0,      "Specify 
the threshold ratio for filtering external arcs");
+       uiDefButF(block, NUM, B_DIFF,                                           
        "",                             1111,110,164,19, 
&G.scene->toolsettings->skgen_threshold_external,0.0, 5.0, 10, 0,      "Specify 
the threshold ratio for filtering external arcs");
        uiBlockEndAlign(block);
 

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to