Fix #20803: convert button in particle modifier didn't work

for creating duplis yet.
This commit is contained in:
Brecht Van Lommel 2010-01-26 11:15:45 +00:00
parent 50e324c5d0
commit 5fe3524ab1
3 changed files with 63 additions and 67 deletions

@ -797,8 +797,10 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, Modif
if (md->type==eModifierType_ParticleSystem) { if (md->type==eModifierType_ParticleSystem) {
ParticleSystem *psys= ((ParticleSystemModifierData *)md)->psys; ParticleSystem *psys= ((ParticleSystemModifierData *)md)->psys;
if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) { if (!(ob->mode & OB_MODE_PARTICLE_EDIT) && psys->pathcache) {
if(ELEM3(psys->part->ren_as, PART_DRAW_PATH, PART_DRAW_GR, PART_DRAW_OB) && psys->pathcache) if(ELEM(psys->part->ren_as, PART_DRAW_GR, PART_DRAW_OB))
uiItemO(row, "Convert", 0, "OBJECT_OT_duplicates_make_real");
else if(psys->part->ren_as == PART_DRAW_PATH)
uiItemO(row, "Convert", 0, "OBJECT_OT_modifier_convert"); uiItemO(row, "Convert", 0, "OBJECT_OT_modifier_convert");
} }
} }

@ -1152,7 +1152,6 @@ void OBJECT_OT_duplicates_make_real(wmOperatorType *ot)
ot->idname= "OBJECT_OT_duplicates_make_real"; ot->idname= "OBJECT_OT_duplicates_make_real";
/* api callbacks */ /* api callbacks */
ot->invoke= WM_operator_confirm;
ot->exec= object_duplicates_make_real_exec; ot->exec= object_duplicates_make_real_exec;
ot->poll= ED_operator_scene_editable; ot->poll= ED_operator_scene_editable;

@ -265,78 +265,73 @@ int ED_object_modifier_convert(ReportList *reports, Scene *scene, Object *ob, Mo
psys=((ParticleSystemModifierData *)md)->psys; psys=((ParticleSystemModifierData *)md)->psys;
part= psys->part; part= psys->part;
if(part->ren_as == PART_DRAW_GR || part->ren_as == PART_DRAW_OB) { if(part->ren_as != PART_DRAW_PATH || psys->pathcache == 0)
; // XXX make_object_duplilist_real(NULL); return 0;
totpart= psys->totcached;
totchild= psys->totchildcache;
if(totchild && (part->draw&PART_DRAW_PARENT)==0)
totpart= 0;
/* count */
cache= psys->pathcache;
for(a=0; a<totpart; a++) {
key= cache[a];
totvert+= key->steps+1;
totedge+= key->steps;
} }
else {
if(part->ren_as != PART_DRAW_PATH || psys->pathcache == 0)
return 0;
totpart= psys->totcached; cache= psys->childcache;
totchild= psys->totchildcache; for(a=0; a<totchild; a++) {
key= cache[a];
totvert+= key->steps+1;
totedge+= key->steps;
}
if(totchild && (part->draw&PART_DRAW_PARENT)==0) if(totvert==0) return 0;
totpart= 0;
/* count */ /* add new mesh */
cache= psys->pathcache; obn= add_object(scene, OB_MESH);
for(a=0; a<totpart; a++) { me= obn->data;
key= cache[a];
totvert+= key->steps+1;
totedge+= key->steps;
}
cache= psys->childcache; me->totvert= totvert;
for(a=0; a<totchild; a++) { me->totedge= totedge;
key= cache[a];
totvert+= key->steps+1;
totedge+= key->steps;
}
if(totvert==0) return 0; me->mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, totvert);
me->medge= CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
me->mface= CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, 0);
/* add new mesh */ mvert= me->mvert;
obn= add_object(scene, OB_MESH); medge= me->medge;
me= obn->data;
me->totvert= totvert; /* copy coordinates */
me->totedge= totedge; cache= psys->pathcache;
for(a=0; a<totpart; a++) {
me->mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, totvert); key= cache[a];
me->medge= CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, NULL, totedge); kmax= key->steps;
me->mface= CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, 0); for(k=0; k<=kmax; k++,key++,cvert++,mvert++) {
VECCOPY(mvert->co,key->co);
mvert= me->mvert; if(k) {
medge= me->medge; medge->v1= cvert-1;
medge->v2= cvert;
/* copy coordinates */ medge->flag= ME_EDGEDRAW|ME_EDGERENDER|ME_LOOSEEDGE;
cache= psys->pathcache; medge++;
for(a=0; a<totpart; a++) {
key= cache[a];
kmax= key->steps;
for(k=0; k<=kmax; k++,key++,cvert++,mvert++) {
VECCOPY(mvert->co,key->co);
if(k) {
medge->v1= cvert-1;
medge->v2= cvert;
medge->flag= ME_EDGEDRAW|ME_EDGERENDER|ME_LOOSEEDGE;
medge++;
}
} }
} }
}
cache=psys->childcache; cache=psys->childcache;
for(a=0; a<totchild; a++) { for(a=0; a<totchild; a++) {
key=cache[a]; key=cache[a];
kmax=key->steps; kmax=key->steps;
for(k=0; k<=kmax; k++,key++,cvert++,mvert++) { for(k=0; k<=kmax; k++,key++,cvert++,mvert++) {
VECCOPY(mvert->co,key->co); VECCOPY(mvert->co,key->co);
if(k) { if(k) {
medge->v1=cvert-1; medge->v1=cvert-1;
medge->v2=cvert; medge->v2=cvert;
medge->flag= ME_EDGEDRAW|ME_EDGERENDER|ME_LOOSEEDGE; medge->flag= ME_EDGEDRAW|ME_EDGERENDER|ME_LOOSEEDGE;
medge++; medge++;
}
} }
} }
} }