diff options
-rw-r--r-- | source/blender/include/editmesh.h | 2 | ||||
-rw-r--r-- | source/blender/src/editmesh_add.c | 35 | ||||
-rw-r--r-- | source/blender/src/editmesh_lib.c | 49 | ||||
-rw-r--r-- | source/blender/src/editmesh_tools.c | 2 |
4 files changed, 66 insertions, 22 deletions
diff --git a/source/blender/include/editmesh.h b/source/blender/include/editmesh.h index 091d256808a..b9827e8af54 100644 --- a/source/blender/include/editmesh.h +++ b/source/blender/include/editmesh.h @@ -70,7 +70,7 @@ extern int faceselectedAND(EditFace *efa, int flag); extern EditFace *exist_face(EditVert *v1, EditVert *v2, EditVert *v3, EditVert *v4); extern void flipface(EditFace *efa); // flips for normal direction -extern int compareface(EditFace *vl1, EditFace *vl2, int test); +extern int compareface(EditFace *vl1, EditFace *vl2); /* flag for selection bits, *nor will be filled with normal for extrusion constraint */ /* return value defines if such normal was set */ diff --git a/source/blender/src/editmesh_add.c b/source/blender/src/editmesh_add.c index 052d1eb02ff..ffdba26bfa6 100644 --- a/source/blender/src/editmesh_add.c +++ b/source/blender/src/editmesh_add.c @@ -315,6 +315,34 @@ static EditFace *addface_from_edges(void) return NULL; } +/* this also allows to prevent triangles being made in quads */ +static int compareface_overlaps(EditFace *vl1, EditFace *vl2) +{ + EditVert *v1, *v2, *v3, *v4; + int equal= 0; + + v1= vl2->v1; + v2= vl2->v2; + v3= vl2->v3; + v4= vl2->v4; + + if(v4==NULL && vl1->v4==NULL) { + if(vl1->v1==v1 || vl1->v2==v1 || vl1->v3==v1) equal++; + if(vl1->v1==v2 || vl1->v2==v2 || vl1->v3==v2) equal++; + if(vl1->v1==v3 || vl1->v2==v3 || vl1->v3==v3) equal++; + } + else { + if(vl1->v1==v1 || vl1->v2==v1 || vl1->v3==v1 || vl1->v4==v1) equal++; + if(vl1->v1==v2 || vl1->v2==v2 || vl1->v3==v2 || vl1->v4==v2) equal++; + if(vl1->v1==v3 || vl1->v2==v3 || vl1->v3==v3 || vl1->v4==v3) equal++; + if(vl1->v1==v4 || vl1->v2==v4 || vl1->v3==v4 || vl1->v4==v4) equal++; + } + + if(equal>=3) return 1; + + return 0; +} + /* checks for existance, and for tria overlapping inside quad */ static EditFace *exist_face_overlaps(EditVert *v1, EditVert *v2, EditVert *v3, EditVert *v4) { @@ -328,7 +356,7 @@ static EditFace *exist_face_overlaps(EditVert *v1, EditVert *v2, EditVert *v3, E efa= em->faces.first; while(efa) { - if(compareface(&efatest, efa, 3)) return efa; + if(compareface_overlaps(&efatest, efa)) return efa; efa= efa->next; } return NULL; @@ -389,6 +417,7 @@ void addedgeface_mesh(void) else error("The selected vertices already form a face"); } else if(amount==4) { + /* this test survives when theres 2 triangles */ if(exist_face(neweve[0], neweve[1], neweve[2], neweve[3])==0) { int tria= 0; @@ -399,7 +428,7 @@ void addedgeface_mesh(void) if(exist_face(neweve[1], neweve[2], neweve[3], NULL)) tria++; if(tria==2) join_triangles(); - else { + else if(exist_face_overlaps(neweve[0], neweve[1], neweve[2], neweve[3])==0) { /* if 4 edges exist, we just create the face, convex or not */ efa= addface_from_edges(); @@ -417,7 +446,7 @@ void addedgeface_mesh(void) else error("The selected vertices form a concave quad"); } } - + else error("The selected vertices already form a face"); } else error("The selected vertices already form a face"); } diff --git a/source/blender/src/editmesh_lib.c b/source/blender/src/editmesh_lib.c index 72e3aa18867..8580cd9a54a 100644 --- a/source/blender/src/editmesh_lib.c +++ b/source/blender/src/editmesh_lib.c @@ -1372,26 +1372,41 @@ void recalc_editnormals(void) } } - -/* this also allows to prevent triangles being made in quads */ -int compareface(EditFace *vl1, EditFace *vl2, int test) +int compareface(EditFace *vl1, EditFace *vl2) { EditVert *v1, *v2, *v3, *v4; - int equal= 0; - - v1= vl2->v1; - v2= vl2->v2; - v3= vl2->v3; - v4= vl2->v4; - if(vl1->v1==v1 || vl1->v2==v1 || vl1->v3==v1 || vl1->v4==v1) equal++; - if(vl1->v1==v2 || vl1->v2==v2 || vl1->v3==v2 || vl1->v4==v2) equal++; - if(vl1->v1==v3 || vl1->v2==v3 || vl1->v3==v3 || vl1->v4==v3) equal++; - if(vl1->v1==v4 || vl1->v2==v4 || vl1->v3==v4 || vl1->v4==v4) equal++; + if(vl1->v4 && vl2->v4) { + v1= vl2->v1; + v2= vl2->v2; + v3= vl2->v3; + v4= vl2->v4; + + if(vl1->v1==v1 || vl1->v2==v1 || vl1->v3==v1 || vl1->v4==v1) { + if(vl1->v1==v2 || vl1->v2==v2 || vl1->v3==v2 || vl1->v4==v2) { + if(vl1->v1==v3 || vl1->v2==v3 || vl1->v3==v3 || vl1->v4==v3) { + if(vl1->v1==v4 || vl1->v2==v4 || vl1->v3==v4 || vl1->v4==v4) { + return 1; + } + } + } + } + } + else if(vl1->v4==0 && vl2->v4==0) { + v1= vl2->v1; + v2= vl2->v2; + v3= vl2->v3; + + if(vl1->v1==v1 || vl1->v2==v1 || vl1->v3==v1) { + if(vl1->v1==v2 || vl1->v2==v2 || vl1->v3==v2) { + if(vl1->v1==v3 || vl1->v2==v3 || vl1->v3==v3) { + return 1; + } + } + } + } - if(equal<test) return 0; - - return 1; + return 0; } /* checks for existance, not tria overlapping inside quad */ @@ -1407,7 +1422,7 @@ EditFace *exist_face(EditVert *v1, EditVert *v2, EditVert *v3, EditVert *v4) efa= em->faces.first; while(efa) { - if(compareface(&efatest, efa, 4)) return efa; + if(compareface(&efatest, efa)) return efa; efa= efa->next; } return NULL; diff --git a/source/blender/src/editmesh_tools.c b/source/blender/src/editmesh_tools.c index bed7ee4db32..169a2ef017d 100644 --- a/source/blender/src/editmesh_tools.c +++ b/source/blender/src/editmesh_tools.c @@ -414,7 +414,7 @@ int removedoublesflag(short flag, float limit) /* return amount */ /* second test: is test permitted? */ efa= vsb1->efa; if( (efa->f1 & 128)==0 ) { - if( compareface(efa, vsb->efa, 4)) efa->f1 |= 128; + if( compareface(efa, vsb->efa)) efa->f1 |= 128; } vsb1++; |