-> Fix for bug #3867
authorGeoffrey Bantle <hairbat@yahoo.com>
Thu, 8 Jun 2006 05:41:57 +0000 (05:41 +0000)
committerGeoffrey Bantle <hairbat@yahoo.com>
Thu, 8 Jun 2006 05:41:57 +0000 (05:41 +0000)
Face loop cut was failing on meshes with hidden parts. Also modified edge
ring selection code in editmesh_mods.c to ignore hidden parts of mesh.

source/blender/include/BIF_editmesh.h
source/blender/src/editmesh_loop.c
source/blender/src/editmesh_mods.c
source/blender/src/editmesh_tools.c

index 76cb9cada9cf0e15586446d45b0ba674a34012a8..7c5554de19878854d5851003c1eff2dbb38afbde 100644 (file)
@@ -182,6 +182,7 @@ extern short sharesFace(struct EditEdge* e1, struct EditEdge* e2);
 #define SUBDIV_SELECT_ORIG      0
 #define SUBDIV_SELECT_INNER     1
 #define SUBDIV_SELECT_INNER_SEL 2
+#define SUBDIV_SELECT_LOOPCUT 3
 
 extern void convert_to_triface(int direction);
 extern int removedoublesflag(short flag, float limit);
index e3d910fef1023211fc7e0479dd90c59778abe519..609b68b5cf5b6a88c660152291d4e58fd21cff19 100644 (file)
@@ -126,7 +126,7 @@ static void edgering_sel(EditEdge *startedge, int select, int previewlines)
                looking= 0;
                
                for(efa= em->faces.first; efa; efa= efa->next) {
-                       if(efa->e4 && efa->f1==0) {     // not done quad
+                       if(efa->e4 && efa->f1==0 && efa->h == 0) {      // not done quad
                                if(efa->e1->f1<=2 && efa->e2->f1<=2 && efa->e3->f1<=2 && efa->e4->f1<=2) { // valence ok
 
                                        // if edge tagged, select opposing edge and mark face ok
@@ -166,36 +166,38 @@ static void edgering_sel(EditEdge *startedge, int select, int previewlines)
                        //glEnd();
                        for(efa= em->faces.first; efa; efa= efa->next) {
                                if(efa->v4 == NULL) {  continue; }
-                               if(efa->e1->f2 == 1){
-                                       if(efa->e1->h == 1 || efa->e3->h == 1 )
-                                               continue;
-                                       
-                                       v[0][0] = efa->v1;
-                                       v[0][1] = efa->v2;
-                                       v[1][0] = efa->v4;
-                                       v[1][1] = efa->v3;
-                               } else if(efa->e2->f2 == 1){
-                                       if(efa->e2->h == 1 || efa->e4->h == 1)
-                                               continue;
-                                       v[0][0] = efa->v2;
-                                       v[0][1] = efa->v3;
-                                       v[1][0] = efa->v1;
-                                       v[1][1] = efa->v4;                                      
-                               } else { continue; }
-                                                                         
-                               for(i=1;i<=previewlines;i++){
-                                       co[0][0] = (v[0][1]->co[0] - v[0][0]->co[0])*(i/((float)previewlines+1))+v[0][0]->co[0];
-                                       co[0][1] = (v[0][1]->co[1] - v[0][0]->co[1])*(i/((float)previewlines+1))+v[0][0]->co[1];
-                                       co[0][2] = (v[0][1]->co[2] - v[0][0]->co[2])*(i/((float)previewlines+1))+v[0][0]->co[2];
-
-                                       co[1][0] = (v[1][1]->co[0] - v[1][0]->co[0])*(i/((float)previewlines+1))+v[1][0]->co[0];
-                                       co[1][1] = (v[1][1]->co[1] - v[1][0]->co[1])*(i/((float)previewlines+1))+v[1][0]->co[1];
-                                       co[1][2] = (v[1][1]->co[2] - v[1][0]->co[2])*(i/((float)previewlines+1))+v[1][0]->co[2];                                        
-                                       glColor3ub(255, 0, 255);
-                                       glBegin(GL_LINES);      
-                                       glVertex3f(co[0][0],co[0][1],co[0][2]);
-                                       glVertex3f(co[1][0],co[1][1],co[1][2]);
-                                       glEnd();
+                               if(efa->h == 0){
+                                       if(efa->e1->f2 == 1){
+                                               if(efa->e1->h == 1 || efa->e3->h == 1 )
+                                                       continue;
+                                               
+                                               v[0][0] = efa->v1;
+                                               v[0][1] = efa->v2;
+                                               v[1][0] = efa->v4;
+                                               v[1][1] = efa->v3;
+                                       } else if(efa->e2->f2 == 1){
+                                               if(efa->e2->h == 1 || efa->e4->h == 1)
+                                                       continue;
+                                               v[0][0] = efa->v2;
+                                               v[0][1] = efa->v3;
+                                               v[1][0] = efa->v1;
+                                               v[1][1] = efa->v4;                                      
+                                       } else { continue; }
+                                                                                 
+                                       for(i=1;i<=previewlines;i++){
+                                               co[0][0] = (v[0][1]->co[0] - v[0][0]->co[0])*(i/((float)previewlines+1))+v[0][0]->co[0];
+                                               co[0][1] = (v[0][1]->co[1] - v[0][0]->co[1])*(i/((float)previewlines+1))+v[0][0]->co[1];
+                                               co[0][2] = (v[0][1]->co[2] - v[0][0]->co[2])*(i/((float)previewlines+1))+v[0][0]->co[2];
+
+                                               co[1][0] = (v[1][1]->co[0] - v[1][0]->co[0])*(i/((float)previewlines+1))+v[1][0]->co[0];
+                                               co[1][1] = (v[1][1]->co[1] - v[1][0]->co[1])*(i/((float)previewlines+1))+v[1][0]->co[1];
+                                               co[1][2] = (v[1][1]->co[2] - v[1][0]->co[2])*(i/((float)previewlines+1))+v[1][0]->co[2];                                        
+                                               glColor3ub(255, 0, 255);
+                                               glBegin(GL_LINES);      
+                                               glVertex3f(co[0][0],co[0][1],co[0][2]);
+                                               glVertex3f(co[1][0],co[1][1],co[1][2]);
+                                               glEnd();
+                                       }
                                }
                        }
                        glPopMatrix();   
@@ -373,23 +375,14 @@ void CutEdgeloop(int numcuts)
        /* select edge ring */
        edgering_sel(nearest, 1, 0);
        
-       /* Deselect Hidden Edges */
-       for(eed=em->edges.first; eed; eed = eed->next){
-               if(eed->h == 1 || (eed->v1->h == 1 || eed->v2->h == 1)){
-                       EM_select_edge(eed,0);  
-                       hasHidden = 1;
-               }
-       }       
-       
-       
        /* now cut the loops */
        if(smooth){
                fac= 1.0f;
                if(fbutton(&fac, 0.0f, 5.0f, 10, 10, "Smooth:")==0) return;
                fac= 0.292f*fac;                        
-               esubdivideflag(SELECT,fac,B_SMOOTH,numcuts,SUBDIV_SELECT_INNER_SEL);
+               esubdivideflag(SELECT,fac,B_SMOOTH,numcuts,SUBDIV_SELECT_LOOPCUT);
        } else {
-               esubdivideflag(SELECT,0,0,numcuts,SUBDIV_SELECT_INNER_SEL);
+               esubdivideflag(SELECT,0,0,numcuts,SUBDIV_SELECT_LOOPCUT);
        }
        /* if this was a single cut, enter edgeslide mode */
        if(numcuts == 1 && hasHidden == 0){
index 19c6d6d509e61d7e3e3c60f2704ffc5dc702f6fd..14d30401c1de64311114e7ec6a511de6bbb287ea 100644 (file)
@@ -1407,7 +1407,7 @@ static void edgering_select(EditEdge *startedge, int select){
                looking= 0;
                
                for(efa= em->faces.first; efa; efa= efa->next) {
-                       if(efa->e4 && efa->f1==0) {     /* not done quad */
+                       if(efa->e4 && efa->f1==0 && !efa->h) {  /* not done quad */
                                if(efa->e1->f1<=2 && efa->e2->f1<=2 && efa->e3->f1<=2 && efa->e4->f1<=2) { /* valence ok */
 
                                        /* if edge tagged, select opposing edge and mark face ok */
index 1d3b218362ff6bed9a9dfaf8bb0d02fdb44bc6ef..45369e05883f633d6e7916464e584f4e78d5bbd5 100644 (file)
@@ -1190,6 +1190,9 @@ void fill_mesh(void)
 #define EDGEINNER  4
 #define EDGEOLD  8
 
+/*used by faceloop cut to select only edges valid for edge slide*/
+#define DOUBLEOPFILL 16
+
 /* Mostly mirrored from editdeform.c, here only used for the function below */
 /* Only to be used to add new weights in eve, the value of weight has been premultiplied with subdiv factor, so is added only */
 static void subdiv_add_defweight (EditVert *eve, int defgroup, float weight)
@@ -1718,6 +1721,7 @@ static void fill_quad_double_op(EditFace *efa, struct GHash *gh, int numcuts)
                hold = addfacelist(verts[0][i],verts[0][i+1],verts[1][vertsize-2-i],verts[1][vertsize-1-i],NULL,NULL);  
                if(i < vertsize-2) {
                        hold->e2->f2 |= EDGEINNER;
+                       hold->e2->f2 |= DOUBLEOPFILL;
                }
                facecopy(efa,hold);
        }         
@@ -2656,6 +2660,16 @@ void esubdivideflag(int flag, float rad, int beauty, int numcuts, int seltype)
                                EM_select_edge(eed,0); 
                        }
                }                 
+       } else if(seltype == SUBDIV_SELECT_LOOPCUT){
+               for(eed = em->edges.first;eed;eed = eed->next) {
+                       if(eed->f2 & DOUBLEOPFILL){
+                               eed->f |= flag;
+                               EM_select_edge(eed,1);
+                       }else{
+                               eed->f &= !flag;
+                               EM_select_edge(eed,0);
+                       }
+               }
        } 
         if(G.scene->selectmode & SCE_SELECT_VERTEX) {
                 for(eed = em->edges.first;eed;eed = eed->next) {