diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-10-04 23:58:08 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-10-04 23:58:08 +0400 |
commit | 7fae6345ab475e9790dd250f1e54447aa883aaa6 (patch) | |
tree | 68821e6452d562f05ef9e6595959d57f1dd38d00 /source/blender/src/buttons_editing.c | |
parent | 32d7a061310177921d6055ef389a9734c78f79d3 (diff) |
Fix for bug #17752: the particle modifier convert button didn't
do anything for dupli objects and groups, which could already
be converted with ctrl+shift+A, but convert can do it as well.
Diffstat (limited to 'source/blender/src/buttons_editing.c')
-rw-r--r-- | source/blender/src/buttons_editing.c | 140 |
1 files changed, 80 insertions, 60 deletions
diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 007604f77b5..3a819d3d32b 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -1248,6 +1248,7 @@ static void modifiers_convertParticles(void *obv, void *mdv) ModifierData *md = mdv; ParticleSystem *psys; ParticleCacheKey *key, **cache; + ParticleSettings *part; Mesh *me; MVert *mvert; MEdge *medge; @@ -1260,78 +1261,90 @@ static void modifiers_convertParticles(void *obv, void *mdv) if(G.f & G_PARTICLEEDIT) return; psys=((ParticleSystemModifierData *)md)->psys; + part= psys->part; - if(psys->part->draw_as != PART_DRAW_PATH || psys->pathcache == 0) return; + if(part->draw_as == PART_DRAW_GR || part->draw_as == PART_DRAW_OB) { + make_object_duplilist_real(NULL); + } + else { + if(part->draw_as != PART_DRAW_PATH || psys->pathcache == 0) + return; - totpart= psys->totcached; - totchild= psys->totchildcache; + totpart= psys->totcached; + totchild= psys->totchildcache; - if(totchild && (psys->part->draw&PART_DRAW_PARENT)==0) - totpart= 0; + 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; - } + /* count */ + cache= psys->pathcache; + for(a=0; a<totpart; a++) { + key= cache[a]; + totvert+= key->steps+1; + totedge+= key->steps; + } - cache= psys->childcache; - for(a=0; a<totchild; a++) { - key= cache[a]; - totvert+= key->steps+1; - totedge+= key->steps; - } + cache= psys->childcache; + for(a=0; a<totchild; a++) { + key= cache[a]; + totvert+= key->steps+1; + totedge+= key->steps; + } + + if(totvert==0) return; - if(totvert==0) return; - - /* add new mesh */ - obn= add_object(OB_MESH); - me= obn->data; - - me->totvert= totvert; - me->totedge= totedge; - - 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); - - mvert= me->mvert; - medge= me->medge; - - /* copy coordinates */ - cache= psys->pathcache; - 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++; + /* add new mesh */ + obn= add_object(OB_MESH); + me= obn->data; + + me->totvert= totvert; + me->totedge= totedge; + + 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); + + mvert= me->mvert; + medge= me->medge; + + /* copy coordinates */ + cache= psys->pathcache; + 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; - for(a=0; a<totchild; 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; + for(a=0; a<totchild; 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++; + } } } } DAG_scene_sort(G.scene); + + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWOOPS, 0); + + BIF_undo_push("Convert particles to mesh object(s)."); } static void modifiers_applyModifier(void *obv, void *mdv) @@ -1870,8 +1883,15 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco uiBlockBeginAlign(block); if (md->type==eModifierType_ParticleSystem) { - but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Convert", lx,(cy-=19),60,19, 0, 0, 0, 0, 0, "Convert the current particles to a mesh object"); - uiButSetFunc(but, modifiers_convertParticles, ob, md); + ParticleSystem *psys; + psys= ((ParticleSystemModifierData *)md)->psys; + + if(!(G.f & G_PARTICLEEDIT)) { + if(ELEM3(psys->part->draw_as, PART_DRAW_PATH, PART_DRAW_GR, PART_DRAW_OB) && psys->pathcache) { + but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Convert", lx,(cy-=19),60,19, 0, 0, 0, 0, 0, "Convert the current particles to a mesh object"); + uiButSetFunc(but, modifiers_convertParticles, ob, md); + } + } } else{ but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Apply", lx,(cy-=19),60,19, 0, 0, 0, 0, 0, "Apply the current modifier and remove from the stack"); |