Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-09-25 11:42:43 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-09-25 11:42:43 +0400
commit3379099a6ea212eb9bb08b9271940658b85fdcd4 (patch)
treed2d88a0dd53f906a78b5c234726b910376dbe094 /source/blender/makesrna
parent58a74bc87faf30b036d3088b8f741b353296b6a4 (diff)
patch [#28616] Multiple particle systems support
from Andrea Rugliancich (andrearu01)
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/rna_particle.c57
1 files changed, 31 insertions, 26 deletions
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; 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))
- 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)