From 06ea86c0a8ce56a38547856a469cf6e6b84c0a3f Mon Sep 17 00:00:00 2001 From: Howard Trickey Date: Tue, 29 Nov 2011 11:49:53 +0000 Subject: [PATCH] Allow scanfill caller to specify boundary edges and use to fix knifetool extra-face bug --- source/blender/blenlib/BLI_scanfill.h | 4 ++++ source/blender/blenlib/intern/scanfill.c | 24 ++++++++++++------------ source/blender/editors/mesh/knifetool.c | 5 ++++- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/source/blender/blenlib/BLI_scanfill.h b/source/blender/blenlib/BLI_scanfill.h index fb8ad4780fd..6fd4766a6a0 100644 --- a/source/blender/blenlib/BLI_scanfill.h +++ b/source/blender/blenlib/BLI_scanfill.h @@ -52,6 +52,10 @@ extern "C" { struct EditVert *BLI_addfillvert(float *vec); struct EditEdge *BLI_addfilledge(struct EditVert *v1, struct EditVert *v2); +/* Optionally set EditEdge f to this to mark original boundary edges. + Only needed if there are internal diagonal edges pased to BLI_edgefill. */ +#define FILLBOUNDARY 1 + int BLI_begin_edgefill(void); int BLI_edgefill(short mat_nr); void BLI_end_edgefill(void); diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 6501b57170b..920e1989117 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -580,7 +580,6 @@ static int scanfill(PolyFill *pf, short mat_nr) eed= filledgebase.first; while(eed) { nexted= eed->next; - eed->f= 0; BLI_remlink(&filledgebase,eed); /* This code is for handling zero-length edges that get collapsed in step 0. It was removed for some time to @@ -706,8 +705,8 @@ static int scanfill(PolyFill *pf, short mat_nr) ed1->v2->f= 0; ed1->v1->h--; ed1->v2->h--; - /* ed2 can be removed when it's an old one */ - if(ed2->f==0 && twoconnected) { + /* ed2 can be removed when it's a boundary edge */ + if(ed2->f==0 && twoconnected || ed2->f==FILLBOUNDARY) { BLI_remlink((ListBase *)&(sc->first),ed2); BLI_addtail(&filledgebase,ed2); ed2->v2->f= 0; @@ -725,19 +724,20 @@ static int scanfill(PolyFill *pf, short mat_nr) /* printf("add new edge %x %x\n",v1,v3); */ sc1= addedgetoscanlist(ed3, verts); - if(sc1) { /* ed3 already exists: remove */ + if(sc1) { /* ed3 already exists: remove if a boundary */ /* printf("Edge exists\n"); */ ed3->v1->h--; ed3->v2->h--; - if(twoconnected) ed3= sc1->first; - else ed3= 0; + ed3= sc1->first; while(ed3) { if( (ed3->v1==v1 && ed3->v2==v3) || (ed3->v1==v3 && ed3->v2==v1) ) { - BLI_remlink((ListBase *)&(sc1->first),ed3); - BLI_addtail(&filledgebase,ed3); - ed3->v1->h--; - ed3->v2->h--; + if (twoconnected || ed3->f==FILLBOUNDARY) { + BLI_remlink((ListBase *)&(sc1->first),ed3); + BLI_addtail(&filledgebase,ed3); + ed3->v1->h--; + ed3->v2->h--; + } break; } ed3= ed3->next; @@ -838,7 +838,7 @@ int BLI_edgefill(short mat_nr) /* including resetting of flags */ eed= filledgebase.first; while(eed) { - eed->f= eed->f1= eed->h= 0; + eed->f1= eed->h= 0; eed->v1->f= 1; eed->v2->f= 1; @@ -998,7 +998,7 @@ int BLI_edgefill(short mat_nr) - eve->h :amount of edges connected to vertex - eve->tmp.v :store! original vertex number - - eed->f : + - eed->f :1= boundary edge (optionally set by caller) - eed->f1 :poly number */ diff --git a/source/blender/editors/mesh/knifetool.c b/source/blender/editors/mesh/knifetool.c index c55f16c8462..74954bed4fd 100755 --- a/source/blender/editors/mesh/knifetool.c +++ b/source/blender/editors/mesh/knifetool.c @@ -1547,7 +1547,10 @@ static void knifenet_fill_faces(knifetool_opdata *kcd) eve = BLI_smallhash_lookup(hash, (intptr_t)entry->kfe->v2); if (eve->xs > 1 && lasteve->xs > 1) { - BLI_addfilledge(lasteve, eve); + EditEdge *eed; + eed = BLI_addfilledge(lasteve, eve); + if (entry->kfe->oe) + eed->f = FILLBOUNDARY; /* mark as original boundary edge */ BMO_ClearFlag(bm, entry->kfe->e->v1, DEL); BMO_ClearFlag(bm, entry->kfe->e->v2, DEL);