diff options
author | Martin Poirier <theeth@yahoo.com> | 2008-06-24 01:47:31 +0400 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2008-06-24 01:47:31 +0400 |
commit | c0daf627333b21c72ec6d120805a74a8b274b429 (patch) | |
tree | 11c474771f27b0eaa4aec2344b86d0a9c0a2eae3 /source/blender/blenlib | |
parent | 488fa13fc04ff4ed55c89914df5c3631697f61dd (diff) |
More robust primary symmetry axis algorithm (support branch in two)
Draw primary axis and weight delta
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/graph.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/source/blender/blenlib/intern/graph.c b/source/blender/blenlib/intern/graph.c index 2c577983112..5c398339ec8 100644 --- a/source/blender/blenlib/intern/graph.c +++ b/source/blender/blenlib/intern/graph.c @@ -695,9 +695,14 @@ static void markdownSecondarySymmetry(BGraph *graph, BNode *node, int depth, int void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level, float limit) { int i; - arc->symmetry_level = level; - - node = BLI_otherNode(arc, node); + + /* if arc is null, we start straight from a node */ + if (arc) + { + arc->symmetry_level = level; + + node = BLI_otherNode(arc, node); + } for (i = 0; i < node->degree; i++) { @@ -727,7 +732,7 @@ void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level, float /* true by default */ issymmetryAxis = 1; - for (j = 0; j < node->degree && issymmetryAxis == 1; j++) + for (j = 0; j < node->degree; j++) { BArc *otherArc = node->arcs[j]; @@ -736,6 +741,7 @@ void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level, float { /* not on the symmetry axis */ issymmetryAxis = 0; + break; } } } @@ -748,11 +754,10 @@ void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level, float { arc = connectedArc; } - else + else if (connectedArc->symmetry_level < arc->symmetry_level) { - /* there can't be more than one symmetry arc */ - arc = NULL; - break; + /* go with more complex subtree as symmetry arc */ + arc = connectedArc; } } } @@ -796,12 +801,21 @@ void BLI_markdownSymmetry(BGraph *graph, BNode *root_node, float limit) node = root_node; - /* only work on acyclic graphs and if only one arc is incident on the first node */ - if (node->degree == 1) + /* sanity check REMOVE ME */ + if (node->degree > 0) { arc = node->arcs[0]; - markdownSymmetryArc(graph, arc, node, 1, limit); + if (node->degree == 1) + { + markdownSymmetryArc(graph, arc, node, 1, limit); + } + else + { + markdownSymmetryArc(graph, NULL, node, 1, limit); + } + + /* mark down non-symetric arcs */ for (arc = graph->arcs.first; arc; arc = arc->next) |