Suggested by bug reporter; pressing Fkey to make a face, whilst the

selection already is 2 triangles, it should create a new face but
remove the old triangles. It actually calls the 'ALT+J' command then
(join triangles)

While testing found out more cases where new selection flags were not
properly used (join trias, beauty fill, flip edges, rotate edges)
This commit is contained in:
Ton Roosendaal 2004-10-16 13:53:41 +00:00
parent 96f2f71cb1
commit a463798984
4 changed files with 45 additions and 40 deletions

@ -68,7 +68,7 @@ extern void EM_hide_reset(void);
extern int faceselectedOR(EditFace *efa, int flag);
extern int faceselectedAND(EditFace *efa, int flag);
extern int exist_face(EditVert *v1, EditVert *v2, EditVert *v3, EditVert *v4);
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);

@ -337,17 +337,27 @@ void addedgeface_mesh(void)
}
else if(amount==4) {
if(exist_face(neweve[0], neweve[1], neweve[2], neweve[3])==0) {
int tria= 0;
/* remove trias if they exist, 4 cases.... */
if(exist_face(neweve[0], neweve[1], neweve[2], NULL)) tria++;
if(exist_face(neweve[0], neweve[1], neweve[3], NULL)) tria++;
if(exist_face(neweve[0], neweve[2], neweve[3], NULL)) tria++;
if(exist_face(neweve[1], neweve[2], neweve[3], NULL)) tria++;
con1= convex(neweve[0]->co, neweve[1]->co, neweve[2]->co, neweve[3]->co);
con2= convex(neweve[0]->co, neweve[2]->co, neweve[3]->co, neweve[1]->co);
con3= convex(neweve[0]->co, neweve[3]->co, neweve[1]->co, neweve[2]->co);
if(tria==2) join_triangles();
else {
con1= convex(neweve[0]->co, neweve[1]->co, neweve[2]->co, neweve[3]->co);
con2= convex(neweve[0]->co, neweve[2]->co, neweve[3]->co, neweve[1]->co);
con3= convex(neweve[0]->co, neweve[3]->co, neweve[1]->co, neweve[2]->co);
if(con1>=con2 && con1>=con3)
efa= addfacelist(neweve[0], neweve[1], neweve[2], neweve[3], NULL, NULL);
else if(con2>=con1 && con2>=con3)
efa= addfacelist(neweve[0], neweve[2], neweve[3], neweve[1], NULL, NULL);
else
efa= addfacelist(neweve[0], neweve[2], neweve[1], neweve[3], NULL, NULL);
if(con1>=con2 && con1>=con3)
efa= addfacelist(neweve[0], neweve[1], neweve[2], neweve[3], NULL, NULL);
else if(con2>=con1 && con2>=con3)
efa= addfacelist(neweve[0], neweve[2], neweve[3], neweve[1], NULL, NULL);
else
efa= addfacelist(neweve[0], neweve[2], neweve[1], neweve[3], NULL, NULL);
}
}
else error("The selected vertices already form a face");

@ -370,12 +370,7 @@ void EM_selectmode_flush(void)
// make sure selected faces have selected edges too, for extrude (hack?)
else if(G.scene->selectmode & SCE_SELECT_FACE) {
for(efa= em->faces.first; efa; efa= efa->next) {
if(efa->f & SELECT) {
efa->e1->f |= SELECT;
efa->e2->f |= SELECT;
efa->e3->f |= SELECT;
if(efa->e4) efa->e4->f |= SELECT;
}
if(efa->f & SELECT) EM_select_face(efa, 1);
}
}
check_fgons_selection();
@ -1306,7 +1301,7 @@ int compareface(EditFace *vl1, EditFace *vl2)
return 0;
}
int exist_face(EditVert *v1, EditVert *v2, EditVert *v3, EditVert *v4)
EditFace *exist_face(EditVert *v1, EditVert *v2, EditVert *v3, EditVert *v4)
{
EditMesh *em = G.editMesh;
EditFace *efa, efatest;
@ -1318,10 +1313,10 @@ int exist_face(EditVert *v1, EditVert *v2, EditVert *v3, EditVert *v4)
efa= em->faces.first;
while(efa) {
if(compareface(&efatest, efa)) return 1;
if(compareface(&efatest, efa)) return efa;
efa= efa->next;
}
return 0;
return NULL;
}

@ -1752,12 +1752,12 @@ void subdivideflag(int flag, float rad, int beauty)
makeDispList(G.obedit);
}
static int count_edges(EditEdge *ed)
static int count_selected_edges(EditEdge *ed)
{
int totedge = 0;
while(ed) {
ed->vn= 0;
if( (ed->v1->f & 1) && (ed->v2->f & 1) ) totedge++;
if( ed->f & SELECT ) totedge++;
ed= ed->next;
}
return totedge;
@ -2006,7 +2006,9 @@ void beauty_fill(void)
* - if true: remedge, addedge, all edges at the edge get new face pointers
*/
totedge = count_edges(em->edges.first);
EM_selectmode_flush(); // makes sure in selectmode 'face' the edges of selected faces are selected too
totedge = count_selected_edges(em->edges.first);
if(totedge==0) return;
if(okee("Beautify fill")==0) return;
@ -2172,8 +2174,9 @@ void join_triangles(void)
float *uv[4];
unsigned int col[4];
totedge = count_edges(em->edges.first);
EM_selectmode_flush(); // makes sure in selectmode 'face' the edges of selected faces are selected too
totedge = count_selected_edges(em->edges.first);
if(totedge==0) return;
efaar= (EVPTuple *) MEM_callocN(totedge * sizeof(EVPTuple), "jointris");
@ -2268,7 +2271,9 @@ void edge_flip(void)
- if true: remedge, addedge, all edges at the edge get new face pointers
*/
totedge = count_edges(em->edges.first);
EM_selectmode_flush(); // makes sure in selectmode 'face' the edges of selected faces are selected too
totedge = count_selected_edges(em->edges.first);
if(totedge==0) return;
/* temporary array for : edge -> face[1], face[2] */
@ -2310,7 +2315,7 @@ void edge_flip(void)
if( convex(v1->co, v2->co, v3->co, v4->co) > 0.01) {
if(exist_face(v1, v2, v3, v4)==0) {
w = addfacelist(v1, v2, v3, 0, efaa[1], NULL); /* outch this may break seams */
EM_select_face(w, 1);
untag_edges(w);
UVCOPY(w->tf.uv[0], uv[0]);
@ -2320,6 +2325,7 @@ void edge_flip(void)
w->tf.col[0] = col[0]; w->tf.col[1] = col[1]; w->tf.col[2] = col[2];
w = addfacelist(v1, v3, v4, 0, efaa[1], NULL); /* outch this may break seams */
EM_select_face(w, 1);
untag_edges(w);
UVCOPY(w->tf.uv[0], uv[0]);
@ -2345,7 +2351,7 @@ void edge_flip(void)
/* clear tagged edges and faces: */
free_tagged_edgelist(em->edges.first);
free_tagged_facelist(em->faces.first);
MEM_freeN(efaar);
allqueue(REDRAWVIEW3D, 0);
@ -2365,7 +2371,7 @@ static void edge_rotate(EditEdge *eed)
for(efa = em->faces.first;efa;efa = efa->next){
if((efa->e1 == eed || efa->e2 == eed) || (efa->e3 == eed || efa->e4 == eed)){
if(facecount == 2){
scrarea_do_windraw(curarea);
scrarea_do_windraw(curarea); /// what is this for? (ton)
screen_swapbuffers();
return;
}
@ -2582,7 +2588,10 @@ static void edge_rotate(EditEdge *eed)
else if(fac1 == 4)
newFace[0]->e4->f2 |= 2;
/* added this for proper select flags, probably whats below is obsolete then */
EM_select_face(newFace[0], 1);
EM_select_face(newFace[1], 1);
/* mark the f1's of the verts for re-selection */
faces[0][(p1+1)%fac1]->f1 |= 1;
faces[1][(p3+1)%fac2]->f1 |= 1;
@ -2625,7 +2634,7 @@ void edge_rotate_selected()
eed = eed->next;
continue;
}
if(eed->v1->f & 1 && eed->v2->f & 1){
if(eed->f & SELECT){ // changed this... (ton)
temp = eed;
eed = eed->next;
edge_rotate(temp);
@ -2633,21 +2642,12 @@ void edge_rotate_selected()
eed = eed->next;
}
/* clear all selections */
for(ev = G.editMesh->verts.first;ev;ev = ev->next)
ev->f &= ~1;
/*set new selections*/
for(ev = G.editMesh->verts.first;ev;ev = ev->next){
if(ev->f1 & 1)
ev->f |= 1;
}
/*clear new edge flags*/
for(eed = G.editMesh->edges.first; eed; eed = eed->next)
eed->f2 &= ~2;
/* flush selected vertices to edges/faces */
/* flush selected vertices (again) to edges/faces */
EM_select_flush();
allqueue(REDRAWVIEW3D, 0);