diff options
author | Martin Poirier <theeth@yahoo.com> | 2008-07-08 00:31:53 +0400 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2008-07-08 00:31:53 +0400 |
commit | 52219d52dd5e4902f38d9be4d07f39e67ba461b2 (patch) | |
tree | e71d1f0a2ba4dd15ed5eaf193af1d6a9b290c729 /source/blender/blenlib/intern/graph.c | |
parent | f139e1f1b4a496b193d988cdde02e290dc8cb478 (diff) |
First draft: Use multiresolution graph for retargetting (enables bypassing small appendages that don't correspond to anything on the armature).
Diffstat (limited to 'source/blender/blenlib/intern/graph.c')
-rw-r--r-- | source/blender/blenlib/intern/graph.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/source/blender/blenlib/intern/graph.c b/source/blender/blenlib/intern/graph.c index 1371e59a77a..2aea9bc0a4a 100644 --- a/source/blender/blenlib/intern/graph.c +++ b/source/blender/blenlib/intern/graph.c @@ -321,34 +321,40 @@ BArc * BLI_findConnectedArc(BGraph *graph, BArc *arc, BNode *v) /*********************************** 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 @@ void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level, float 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); } } |