diff options
author | Joseph Eagar <joeedh@gmail.com> | 2011-02-27 09:19:40 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2011-02-27 09:19:40 +0300 |
commit | f01261d040be27337db9f9996d648a279c89b7c4 (patch) | |
tree | c448230939b3c90d53ce8852dd00925d6052e3a4 /source/blender/modifiers/intern/MOD_particlesystem.c | |
parent | dcaeda5c4e3a0687251b8511de4f2e8b85ef75c0 (diff) | |
parent | 2198cfdb2deec8b2e85e242c74a032f43d0b26ca (diff) |
merge with/from trunk at r35190
Diffstat (limited to 'source/blender/modifiers/intern/MOD_particlesystem.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_particlesystem.c | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c index 4feeef54882..80c96fd8553 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.c +++ b/source/blender/modifiers/intern/MOD_particlesystem.c @@ -30,10 +30,18 @@ * */ +/** \file blender/modifiers/intern/MOD_particlesystem.c + * \ingroup modifiers + */ + + #include "stddef.h" #include "DNA_material_types.h" +#include "BLI_utildefines.h" + + #include "BKE_cdderivedmesh.h" #include "BKE_material.h" #include "BKE_modifier.h" @@ -77,41 +85,36 @@ static void copyData(ModifierData *md, ModifierData *target) tpsmd->psys = psmd->psys; } -static CustomDataMask requiredDataMask(Object *ob, ModifierData *md) +static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) { ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; CustomDataMask dataMask = 0; - Material *ma; MTex *mtex; int i; if(!psmd->psys->part) return 0; - ma= give_current_material(ob, psmd->psys->part->omat); - if(ma) { - for(i=0; i<MAX_MTEX; i++) { - mtex=ma->mtex[i]; - if(mtex && (ma->septex & (1<<i))==0) - if(mtex->pmapto && (mtex->texco & TEXCO_UV)) - dataMask |= (1 << CD_MTFACE); - } + for(i=0; i<MAX_MTEX; i++) { + mtex = psmd->psys->part->mtex[i]; + if(mtex && mtex->mapto && (mtex->texco & TEXCO_UV)) + dataMask |= CD_MASK_MTFACE; } if(psmd->psys->part->tanfac!=0.0) - dataMask |= (1 << CD_MTFACE); + dataMask |= CD_MASK_MTFACE; /* ask for vertexgroups if we need them */ for(i=0; i<PSYS_TOT_VG; i++){ if(psmd->psys->vgroup[i]){ - dataMask |= (1 << CD_MDEFORMVERT); + dataMask |= CD_MASK_MDEFORMVERT; break; } } /* particles only need this if they are after a non deform modifier, and * the modifier stack will only create them in that case. */ - dataMask |= CD_MASK_ORIGSPACE; + dataMask |= CD_MASK_ORIGSPACE|CD_MASK_ORIGINDEX; dataMask |= CD_MASK_ORCO; @@ -119,9 +122,12 @@ static CustomDataMask requiredDataMask(Object *ob, ModifierData *md) } /* saves the current emitter state for a particle system and calculates particles */ -static void deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) +static void deformVerts(ModifierData *md, Object *ob, + DerivedMesh *derivedData, + float (*vertexCos)[3], + int UNUSED(numVerts), + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { DerivedMesh *dm = derivedData; ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; @@ -137,7 +143,7 @@ static void deformVerts( return; if(dm==0) { - dm= get_dm(md->scene, ob, NULL, NULL, vertexCos, 1); + dm= get_dm(ob, NULL, NULL, vertexCos, 1); if(!dm) return; @@ -150,6 +156,14 @@ static void deformVerts( psmd->dm->needsFree = 1; psmd->dm->release(psmd->dm); } + else if(psmd->flag & eParticleSystemFlag_file_loaded) { + /* in file read dm just wasn't saved in file so no need to reset everything */ + psmd->flag &= ~eParticleSystemFlag_file_loaded; + } + else { + /* no dm before, so recalc particles fully */ + psys->recalc |= PSYS_RECALC_RESET; + } /* make new dm */ psmd->dm=CDDM_copy(dm, 0); @@ -168,10 +182,8 @@ static void deformVerts( if(psmd->dm->getNumVerts(psmd->dm)!=psmd->totdmvert || psmd->dm->getNumEdges(psmd->dm)!=psmd->totdmedge || psmd->dm->getNumTessFaces(psmd->dm)!=psmd->totdmface){ - /* in file read dm hasn't really changed but just wasn't saved in file */ psys->recalc |= PSYS_RECALC_RESET; - psmd->flag |= eParticleSystemFlag_DM_changed; psmd->totdmvert= psmd->dm->getNumVerts(psmd->dm); psmd->totdmedge= psmd->dm->getNumEdges(psmd->dm); @@ -182,7 +194,6 @@ static void deformVerts( psmd->flag &= ~eParticleSystemFlag_psys_updated; particle_system_update(md->scene, ob, psys); psmd->flag |= eParticleSystemFlag_psys_updated; - psmd->flag &= ~eParticleSystemFlag_DM_changed; } } @@ -218,6 +229,7 @@ ModifierTypeInfo modifierType_ParticleSystem = { /* copyData */ copyData, /* deformVerts */ deformVerts, /* deformVertsEM */ 0 /* deformVertsEM */ , + /* deformMatrices */ 0, /* deformMatricesEM */ 0, /* applyModifier */ 0, /* applyModifierEM */ 0, @@ -227,6 +239,7 @@ ModifierTypeInfo modifierType_ParticleSystem = { /* isDisabled */ 0, /* updateDepgraph */ 0, /* dependsOnTime */ 0, + /* dependsOnNormals */ 0, /* foreachObjectLink */ 0, /* foreachIDLink */ 0, }; |