diff options
Diffstat (limited to 'source/blender/blenkernel/intern/particle_system.c')
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index c00101c98ab..9b694ccf584 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -61,7 +61,6 @@ #include "DNA_ipo_types.h" // XXX old animation system stuff... to be removed! #include "DNA_listBase.h" -#include "BLI_edgehash.h" #include "BLI_rand.h" #include "BLI_jitter.h" #include "BLI_math.h" @@ -71,6 +70,7 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" #include "BLI_linklist.h" +#include "BLI_edgehash.h" #include "BKE_main.h" #include "BKE_animsys.h" @@ -352,9 +352,9 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm, ParticleSystem *psys) origindex= dm->getVertDataArray(dm, CD_ORIGINDEX); } else { /* FROM_FACE/FROM_VOLUME */ - totdmelem= dm->getNumFaces(dm); - totelem= me->totface; - origindex= dm->getFaceDataArray(dm, CD_ORIGINDEX); + totdmelem= dm->getNumTessFaces(dm); + totelem= me->totpoly; + origindex= dm->getTessFaceDataArray(dm, CD_ORIGINDEX); } nodedmelem= MEM_callocN(sizeof(LinkNode)*totdmelem, "psys node elems"); @@ -523,8 +523,8 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) int a, a1, a2, a0mul, a1mul, a2mul, totface; int amax= from==PART_FROM_FACE ? 3 : 1; - totface=dm->getNumFaces(dm); - mface_array= dm->getFaceDataArray(dm,CD_MFACE); + totface=dm->getNumTessFaces(dm); + mface=mface_array=dm->getTessFaceDataArray(dm,CD_MFACE); for(a=0; a<amax; a++){ if(a==0){ a0mul=res*res; a1mul=res; a2mul=1; } @@ -783,7 +783,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch MFace *mface; pa->num = i = ctx->index[p]; - mface = dm->getFaceData(dm,i,CD_MFACE); + mface = dm->getTessFaceData(dm,i,CD_MFACE); switch(distr){ case PART_DISTR_JIT: @@ -813,7 +813,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch if(from==PART_FROM_VOLUME){ MVert *mvert=dm->getVertDataArray(dm,CD_MVERT); - tot=dm->getNumFaces(dm); + tot=dm->getNumTessFaces(dm); psys_interpolate_face(mvert,mface,0,0,pa->fuv,co1,nor,0,0,0,0); @@ -825,7 +825,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch min_d=2.0; intersect=0; - for(i=0,mface=dm->getFaceDataArray(dm,CD_MFACE); i<tot; i++,mface++){ + for(i=0,mface=dm->getTessFaceDataArray(dm,CD_MFACE); i<tot; i++,mface++){ if(i==pa->num) continue; v1=mvert[mface->v1].co; @@ -873,7 +873,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch return; } - mf= dm->getFaceData(dm, ctx->index[p], CD_MFACE); + mf= dm->getTessFaceData(dm, ctx->index[p], CD_MFACE); randu= rng_getFloat(thread->rng); randv= rng_getFloat(thread->rng); @@ -1040,7 +1040,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D if(totpart==0) return 0; - if (!finaldm->deformedOnly && !finaldm->getFaceDataArray(finaldm, CD_ORIGINDEX)) { + if (!finaldm->deformedOnly && !finaldm->getTessFaceDataArray(finaldm, CD_ORIGINDEX)) { printf("Can't create particles with the current modifier stack, disable destructive modifiers\n"); // XXX error("Can't paint with the current modifier stack, disable destructive modifiers"); return 0; @@ -1071,6 +1071,10 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D distr=PART_DISTR_RAND; BLI_srandom(31415926 + psys->seed + psys->child_seed); dm= finaldm; + + /* BMESH ONLY */ + DM_ensure_tessface(dm); + children=1; tree=BLI_kdtree_new(totpart); @@ -1092,6 +1096,11 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D dm= CDDM_from_mesh((Mesh*)ob->data, ob); + /* BMESH ONLY, for verts we dont care about tessfaces */ + if (from != PART_FROM_VERT) { + DM_ensure_tessface(dm); + } + /* we need orco for consistent distributions */ DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, get_mesh_orco_verts(ob)); @@ -1117,7 +1126,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D } /* Get total number of emission elements and allocate needed arrays */ - totelem = (from == PART_FROM_VERT) ? dm->getNumVerts(dm) : dm->getNumFaces(dm); + totelem = (from == PART_FROM_VERT) ? dm->getNumVerts(dm) : dm->getNumTessFaces(dm); if(totelem == 0){ distribute_invalid(scene, psys, children ? PART_FROM_CHILD : 0); @@ -1146,7 +1155,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D orcodata= dm->getVertDataArray(dm, CD_ORCO); for(i=0; i<totelem; i++){ - MFace *mf=dm->getFaceData(dm,i,CD_MFACE); + MFace *mf=dm->getTessFaceData(dm,i,CD_MFACE); if(orcodata) { copy_v3_v3(co1, orcodata[mf->v1]); @@ -1204,7 +1213,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D } else { /* PART_FROM_FACE / PART_FROM_VOLUME */ for(i=0;i<totelem; i++){ - MFace *mf=dm->getFaceData(dm,i,CD_MFACE); + MFace *mf=dm->getTessFaceData(dm,i,CD_MFACE); tweight = vweight[mf->v1] + vweight[mf->v2] + vweight[mf->v3]; if(mf->v4) { @@ -1278,8 +1287,8 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D COMPARE_ORIG_INDEX= dm->getVertDataArray(dm, CD_ORIGINDEX); } else { - if(dm->numFaceData) - COMPARE_ORIG_INDEX= dm->getFaceDataArray(dm, CD_ORIGINDEX); + if(dm->numTessFaceData) + COMPARE_ORIG_INDEX= dm->getTessFaceDataArray(dm, CD_ORIGINDEX); } if(COMPARE_ORIG_INDEX) { @@ -3516,7 +3525,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim) } if(!dm) { - dm = psys->hair_in_dm = CDDM_new(totpoint, totedge, 0); + dm = psys->hair_in_dm = CDDM_new(totpoint, totedge, 0, 0, 0); DM_add_vert_layer(dm, CD_MDEFORMVERT, CD_CALLOC, NULL); } @@ -3551,7 +3560,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim) if(dvert) { if(!dvert->totweight) { - dvert->dw = MEM_callocN (sizeof(MDeformWeight), "deformWeight"); + dvert->dw = MEM_callocN(sizeof(MDeformWeight), "deformWeight"); dvert->totweight = 1; } @@ -3572,7 +3581,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim) if(dvert) { if(!dvert->totweight) { - dvert->dw = MEM_callocN (sizeof(MDeformWeight), "deformWeight"); + dvert->dw = MEM_callocN(sizeof(MDeformWeight), "deformWeight"); dvert->totweight = 1; } /* roots should be 1.0, the rest can be anything from 0.0 to 1.0 */ |