From 3379099a6ea212eb9bb08b9271940658b85fdcd4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 25 Sep 2011 07:42:43 +0000 Subject: patch [#28616] Multiple particle systems support from Andrea Rugliancich (andrearu01) --- source/blender/makesrna/intern/rna_particle.c | 57 +++++++++++++++------------ 1 file changed, 31 insertions(+), 26 deletions(-) (limited to 'source') diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 77fa975761f..5dc2f2ccac5 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -145,33 +145,38 @@ static void rna_ParticleHairKey_location_object_info(PointerRNA *ptr, ParticleSy *psmd_pt= NULL; *pa_pt= NULL; - /* weak, what about multiple particle systems? */ - for (md = ob->modifiers.first; md; md=md->next) { - if (md->type == eModifierType_ParticleSystem) - psmd= (ParticleSystemModifierData*) md; - } - - if (!psmd || !psmd->dm || !psmd->psys) { - return; - } - - psys= psmd->psys; - - /* not a very efficient way of getting hair key location data, - * but it's the best we've got at the present */ - - /* find the particle that corresponds with this HairKey */ - for(i=0, pa=psys->particles; itotpart; i++, pa++) { - - /* hairkeys are stored sequentially in memory, so we can find if - * it's the same particle by comparing pointers, without having - * to iterate over them all */ - if ((hkey >= pa->hair) && (hkey < pa->hair + pa->totkey)) - break; + /* given the pointer HairKey *hkey, we iterate over all particles in all + * particle systems in the object "ob" in order to find + *- the ParticleSystemData to which the HairKey (and hence the particle) + * belongs (will be stored in psmd_pt) + *- the ParticleData to which the HairKey belongs (will be stored in pa_pt) + * + * not a very efficient way of getting hair key location data, + * but it's the best we've got at the present + * + * IDEAS: include additional information in pointerRNA beforehand, + * for example a pointer to the ParticleStstemModifierData to which the + * hairkey belongs. + */ + + for (md= ob->modifiers.first; md; md=md->next) { + if (md->type == eModifierType_ParticleSystem) { + psmd= (ParticleSystemModifierData *) md; + if (psmd && psmd->dm && psmd->psys) { + psys = psmd->psys; + for(i= 0, pa= psys->particles; i < psys->totpart; i++, pa++) { + /* hairkeys are stored sequentially in memory, so we can + * find if it's the same particle by comparing pointers, + * without having to iterate over them all */ + if ((hkey >= pa->hair) && (hkey < pa->hair + pa->totkey)) { + *psmd_pt = psmd; + *pa_pt = pa; + return; + } + } + } + } } - - *psmd_pt= psmd; - *pa_pt= pa; } static void rna_ParticleHairKey_location_object_get(PointerRNA *ptr, float *values) -- cgit v1.2.3