static void draw_filled_lasso(wmGesture *gt) { EditVert *v=NULL, *lastv=NULL, *firstv=NULL; EditEdge *e; EditFace *efa; short *lasso= (short *)gt->customdata; int i; for (i=0; i<gt->points; i++, lasso+=2) { float co[3]; co[0]= (float)lasso[0]; co[1]= (float)lasso[1]; co[2]= 0.0f; v = BLI_addfillvert(co); if (lastv) e = BLI_addfilledge(lastv, v); lastv = v; if (firstv==NULL) firstv = v; } /* highly unlikely this will fail, but could crash if (gt->points == 0) */ if(firstv) { BLI_addfilledge(firstv, v); BLI_edgefill(0); glEnable(GL_BLEND); glColor4f(1.0, 1.0, 1.0, 0.05); glBegin(GL_TRIANGLES); for (efa = fillfacebase.first; efa; efa=efa->next) { glVertex2f(efa->v1->co[0], efa->v1->co[1]); glVertex2f(efa->v2->co[0], efa->v2->co[1]); glVertex2f(efa->v3->co[0], efa->v3->co[1]); } glEnd(); glDisable(GL_BLEND); BLI_end_edgefill(); } }
void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) { EditVert *eve, *v1, *vlast; EditFace *efa; DispList *dlnew=NULL, *dl; float *f1; int colnr=0, charidx=0, cont=1, tot, a, *index, nextcol= 0; intptr_t totvert; if(dispbase==NULL) return; if(dispbase->first==NULL) return; while(cont) { cont= 0; totvert= 0; nextcol= 0; dl= dispbase->first; while(dl) { if(dl->type==DL_POLY) { if(charidx<dl->charidx) cont= 1; else if(charidx==dl->charidx) { /* character with needed index */ if(colnr==dl->col) { /* make editverts and edges */ f1= dl->verts; a= dl->nr; eve= v1= NULL; while(a--) { vlast= eve; eve= BLI_addfillvert(f1); totvert++; if(vlast==NULL) v1= eve; else { BLI_addfilledge(vlast, eve); } f1+=3; } if(eve!=NULL && v1!=NULL) { BLI_addfilledge(eve, v1); } } else if (colnr<dl->col) { /* got poly with next material at current char */ cont= 1; nextcol= 1; } } } dl= dl->next; } if(totvert && (tot= BLI_edgefill(0))) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) { if(tot) { dlnew= MEM_callocN(sizeof(DispList), "filldisplist"); dlnew->type= DL_INDEX3; dlnew->col= colnr; dlnew->nr= totvert; dlnew->parts= tot; dlnew->index= MEM_mallocN(tot*3*sizeof(int), "dlindex"); dlnew->verts= MEM_mallocN(totvert*3*sizeof(float), "dlverts"); /* vert data */ f1= dlnew->verts; totvert= 0; eve= fillvertbase.first; while(eve) { VECCOPY(f1, eve->co); f1+= 3; /* index number */ eve->tmp.l = totvert; totvert++; eve= eve->next; } /* index data */ efa= fillfacebase.first; index= dlnew->index; while(efa) { index[0]= (intptr_t)efa->v1->tmp.l; index[1]= (intptr_t)efa->v2->tmp.l; index[2]= (intptr_t)efa->v3->tmp.l; if(flipnormal) SWAP(int, index[0], index[2]); index+= 3; efa= efa->next; } } BLI_addhead(to, dlnew); } BLI_end_edgefill(); if(nextcol) { /* stay at current char but fill polys with next material */ colnr++; } else { /* switch to next char and start filling from first material */ charidx++; colnr= 0; } } /* do not free polys, needed for wireframe display */ }