diff options
-rw-r--r-- | source/blender/blenlib/BLI_graph.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/graph.c | 13 | ||||
-rw-r--r-- | source/blender/src/reeb.c | 45 |
3 files changed, 38 insertions, 21 deletions
diff --git a/source/blender/blenlib/BLI_graph.h b/source/blender/blenlib/BLI_graph.h index be5d1f5d10c..66cf2a22842 100644 --- a/source/blender/blenlib/BLI_graph.h +++ b/source/blender/blenlib/BLI_graph.h @@ -80,6 +80,7 @@ void BLI_rebuildAdjacencyListForNode(BGraph* rg, BNode *node); void BLI_freeAdjacencyList(BGraph *rg); int BLI_FlagSubgraphs(BGraph *graph); +void BLI_ReflagSubgraph(BGraph *graph, int old_subgraph, int new_subgraph); #define SHAPE_RADIX 10 /* each shape level is encoded this base */ diff --git a/source/blender/blenlib/intern/graph.c b/source/blender/blenlib/intern/graph.c index abdf2969e49..aa899042a58 100644 --- a/source/blender/blenlib/intern/graph.c +++ b/source/blender/blenlib/intern/graph.c @@ -275,6 +275,19 @@ int BLI_FlagSubgraphs(BGraph *graph) return subgraph; } +void BLI_ReflagSubgraph(BGraph *graph, int old_subgraph, int new_subgraph) +{ + BNode *node; + + for (node = graph->nodes.first; node; node = node->next) + { + if (node->flag == old_subgraph) + { + node->flag = new_subgraph; + } + } +} + /*************************************** CYCLE DETECTION ***********************************************/ int detectCycle(BNode *node, BArc *src_arc) diff --git a/source/blender/src/reeb.c b/source/blender/src/reeb.c index 728dc2d7996..be5f754d5f0 100644 --- a/source/blender/src/reeb.c +++ b/source/blender/src/reeb.c @@ -350,7 +350,8 @@ void printArc(ReebArc *arc) { ReebEdge *edge; ReebNode *head = (ReebNode*)arc->head; - printf("arc: (%i)%f -> (%i)%f\n", head->index, head->weight, head->index, head->weight); + ReebNode *tail = (ReebNode*)arc->tail; + printf("arc: (%i) %f -> (%i) %f\n", head->index, head->weight, tail->index, tail->weight); for(edge = arc->edges.first; edge ; edge = edge->next) { @@ -499,7 +500,7 @@ void verifyFaces(ReebGraph *rg) #endif } -void verifyMultiResolutionLinks(ReebGraph *rg) +void verifyMultiResolutionLinks(ReebGraph *rg, int level) { #ifdef DEBUG_REEB ReebGraph *lower_rg = rg->link_up; @@ -512,12 +513,16 @@ void verifyMultiResolutionLinks(ReebGraph *rg) { if (BLI_findindex(&lower_rg->arcs, arc->link_up) == -1) { - printf("missing arc %p\n", arc->link_up); + printf("missing arc %p for level %i\n", arc->link_up, level); + printf("Source arc was ---\n"); + printArc(arc); + + arc->link_up = NULL; } } - verifyMultiResolutionLinks(lower_rg); + verifyMultiResolutionLinks(lower_rg, level + 1); } #endif } @@ -1160,7 +1165,9 @@ int joinSubgraphsEnds(ReebGraph *rg, float threshold, int nb_subgraphs) if (merging) - { + { + BLI_ReflagSubgraph((BGraph*)rg, end_node->flag, subgraph); + resizeArcBuckets(start_arc); fillArcEmptyBuckets(start_arc); @@ -1334,7 +1341,7 @@ void filterNullReebGraph(ReebGraph *rg) blend = (float)newNode->degree / (float)(newNode->degree + removedNode->degree); // blending factors - VecLerpf(newNode->p, newNode->p, removedNode->p, blend); + VecLerpf(newNode->p, removedNode->p, newNode->p, blend); filterArc(rg, newNode, removedNode, arc, 0); @@ -1440,9 +1447,6 @@ int filterExternalReebGraph(ReebGraph *rg, float threshold) if (middleNode->degree == 2) { continue; -// removedNode = middleNode; -// -// filterArc(rg, terminalNode, removedNode, arc, 1); } // Otherwise, just plain remove of the arc else @@ -1463,9 +1467,6 @@ int filterExternalReebGraph(ReebGraph *rg, float threshold) value = 1; } } - - /* join on normal nodes */ - removeNormalNodes(rg); return value; } @@ -1690,19 +1691,19 @@ void filterGraph(ReebGraph *rg, short options, float threshold_internal, float t { done = 0; /* no work done yet */ - if (options & SKGEN_FILTER_EXTERNAL) - { -// done |= filterExternalReebGraph(rg, threshold_external * rg->resolution); - done |= filterExternalReebGraph(rg, threshold_external); - verifyNodeDegree(rg); - } - if (options & SKGEN_FILTER_INTERNAL) { // done |= filterInternalReebGraph(rg, threshold_internal * rg->resolution); done |= filterInternalReebGraph(rg, threshold_internal); verifyNodeDegree(rg); } + + if (options & SKGEN_FILTER_EXTERNAL) + { +// done |= filterExternalReebGraph(rg, threshold_external * rg->resolution); + done |= filterExternalReebGraph(rg, threshold_external); + verifyNodeDegree(rg); + } } if (options & SKGEN_FILTER_SMART) @@ -2842,10 +2843,12 @@ int weightFromDistance(EditMesh *em) for (eve = em->verts.first; eve; eve = eve->next) { - if (eve->f1 != 1) + /* for every vertex visible that hasn't been processed yet */ + if (eve->h == 0 && eve->f1 != 1) { EditVert *closest_eve; + /* find the closest processed vertex */ for (closest_eve = em->verts.first; closest_eve; closest_eve = closest_eve->next) { /* vertex is already processed and distance is smaller than current minimum */ @@ -3292,7 +3295,7 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(void) relinkNodes(previous, rgi); } - verifyMultiResolutionLinks(rg); + verifyMultiResolutionLinks(rg, 0); return rg; } |