Fix #23925: converting text into a curve looses materials

filldisplist worked incorrect with polys when charidx matched but col doesn't
Also fixed material loose when converting text/curve to mesh
This commit is contained in:
Sergey Sharybin 2010-09-22 05:08:52 +00:00
parent d2bc4a31a0
commit 916085247a
2 changed files with 37 additions and 26 deletions

@ -930,7 +930,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal)
EditFace *efa; EditFace *efa;
DispList *dlnew=0, *dl; DispList *dlnew=0, *dl;
float *f1; float *f1;
int colnr=0, charidx=0, cont=1, tot, a, *index; int colnr=0, charidx=0, cont=1, tot, a, *index, nextcol= 0;
intptr_t totvert; intptr_t totvert;
if(dispbase==0) return; if(dispbase==0) return;
@ -938,38 +938,41 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal)
while(cont) { while(cont) {
cont= 0; cont= 0;
totvert=0; totvert= 0;
nextcol= 0;
dl= dispbase->first; dl= dispbase->first;
while(dl) { while(dl) {
if(dl->type==DL_POLY) { if(dl->type==DL_POLY) {
if(charidx<dl->charidx) cont= 1; if(charidx<dl->charidx) cont= 1;
else if(charidx==dl->charidx) { 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= 0;
colnr= dl->col; while(a--) {
charidx= dl->charidx; vlast= eve;
/* make editverts and edges */ eve= BLI_addfillvert(f1);
f1= dl->verts; totvert++;
a= dl->nr;
eve= v1= 0;
while(a--) { if(vlast==0) v1= eve;
vlast= eve; else {
BLI_addfilledge(vlast, eve);
eve= BLI_addfillvert(f1); }
totvert++; f1+=3;
if(vlast==0) v1= eve;
else {
BLI_addfilledge(vlast, eve);
} }
f1+=3;
}
if(eve!=0 && v1!=0) { if(eve!=0 && v1!=0) {
BLI_addfilledge(eve, v1); BLI_addfilledge(eve, v1);
}
} else if (colnr<dl->col) {
/* got poly with next material at current char */
cont= 1;
nextcol= 1;
} }
} }
} }
@ -1032,7 +1035,14 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal)
} }
BLI_end_edgefill(); BLI_end_edgefill();
charidx++; 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 */ /* do not free polys, needed for wireframe display */

@ -854,6 +854,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
mface->v2= startvert+index[2]; mface->v2= startvert+index[2];
mface->v3= startvert+index[1]; mface->v3= startvert+index[1];
mface->v4= 0; mface->v4= 0;
mface->mat_nr= (unsigned char)dl->col;
test_index_face(mface, NULL, 0, 3); test_index_face(mface, NULL, 0, 3);
if(smooth) mface->flag |= ME_SMOOTH; if(smooth) mface->flag |= ME_SMOOTH;