[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40534] trunk/blender/source/blender/ makesrna/intern/rna_particle.c: patch [#28616] Multiple particle systems support

Campbell Barton ideasman42 at gmail.com
Sun Sep 25 09:42:44 CEST 2011


Revision: 40534
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40534
Author:   campbellbarton
Date:     2011-09-25 07:42:43 +0000 (Sun, 25 Sep 2011)
Log Message:
-----------
patch [#28616] Multiple particle systems support
from Andrea Rugliancich (andrearu01)

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_particle.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_particle.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_particle.c	2011-09-25 07:03:20 UTC (rev 40533)
+++ trunk/blender/source/blender/makesrna/intern/rna_particle.c	2011-09-25 07:42:43 UTC (rev 40534)
@@ -145,33 +145,38 @@
 	*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;
-	}
+	/* 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.
+	 */
 
-	if (!psmd || !psmd->dm || !psmd->psys) {
-		return;
+	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;
+					}
+				}
+			}
+		}
 	}
-
-	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;
-	}
-
-	*psmd_pt= psmd;
-	*pa_pt= pa;
 }
 
 static void rna_ParticleHairKey_location_object_get(PointerRNA *ptr, float *values)




More information about the Bf-blender-cvs mailing list