[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13725] trunk/blender/source/blender: Particle looping works again at least to some extent (don' t have time to test thoroughly).

Janne Karhu jhkarh at utu.fi
Sun Feb 17 15:44:12 CET 2008


Revision: 13725
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13725
Author:   jhk
Date:     2008-02-17 15:44:12 +0100 (Sun, 17 Feb 2008)

Log Message:
-----------
Particle looping works again at least to some extent (don't have time to test thoroughly). Instant looping had to be removed as it caused more trouble than good things.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/particle_system.c
    trunk/blender/source/blender/makesdna/DNA_particle_types.h
    trunk/blender/source/blender/src/buttons_object.c

Modified: trunk/blender/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/particle_system.c	2008-02-17 13:41:42 UTC (rev 13724)
+++ trunk/blender/source/blender/blenkernel/intern/particle_system.c	2008-02-17 14:44:12 UTC (rev 13725)
@@ -4049,8 +4049,8 @@
 
 			reset_particle(pa,psys,psmd,ob,dtime,cfra,vg_vel,vg_tan,vg_rot);
 
-			if(cfra>pa->time && part->flag & PART_LOOP && (part->flag & PART_LOOP_INSTANT)==0){
-				pa->loop=(short)((cfra-pa->time)/pa->lifetime)+1;
+			if(cfra>pa->time && part->flag & PART_LOOP){
+				pa->loop=(short)((cfra-pa->time)/pa->lifetime);
 				pa->alive=PARS_UNBORN;
 			}
 			else{
@@ -4117,10 +4117,12 @@
 
 			pa_die=0;
 
+			birthtime = pa->time + pa->loop * pa->lifetime;
+
 			if(pa->alive==PARS_UNBORN
 				|| pa->alive==PARS_KILLED
 				|| ELEM(part->phystype,PART_PHYS_NO,PART_PHYS_KEYED)
-				|| pa->time >= cfra){
+				|| birthtime >= cfra){
 				/* allways reset particles to emitter before birth */
 				reset_particle(pa,psys,psmd,ob,dtime,cfra,vg_vel,vg_tan,vg_rot);
 				copy_particle_key(key,&pa->state,1);
@@ -4131,27 +4133,22 @@
 				if(psys->reactevents.first && ELEM(pa->alive,PARS_DEAD,PARS_KILLED)==0)
 					react_to_events(psys,p);
 
-				pa_dfra= dfra;
-				pa_dtime= dtime;
+				pa_dfra = dfra;
+				pa_dtime = dtime;
 
-				if(pa->flag & PART_LOOP && pa->flag & PART_LOOP_INSTANT)
-					birthtime=pa->dietime;
-				else
-					birthtime=pa->time+pa->loop*pa->lifetime;
+				dietime = birthtime + pa->lifetime;
 
-				dietime=birthtime+pa->lifetime;
-
 				if(birthtime < cfra && birthtime >= psys->cfra){
 					/* particle is born some time between this and last step*/
-					pa->alive=PARS_ALIVE;
-					pa_dfra= cfra - birthtime;
-					pa_dtime= pa_dfra*timestep;
+					pa->alive = PARS_ALIVE;
+					pa_dfra = cfra - birthtime;
+					pa_dtime = pa_dfra*timestep;
 				}
 				else if(dietime <= cfra && psys->cfra < dietime){
 					/* particle dies some time between this and last step */
-					pa_dfra= dietime - psys->cfra;
-					pa_dtime= pa_dfra*timestep;
-					pa_die=1;
+					pa_dfra = dietime - psys->cfra;
+					pa_dtime = pa_dfra * timestep;
+					pa_die = 1;
 				}
 				else if(dietime < cfra){
 					/* TODO: figure out if there's something to be done when particle is dead */
@@ -4189,14 +4186,9 @@
 
 						if(part->flag & PART_LOOP){
 							pa->loop++;
-
-							if(part->flag & PART_LOOP_INSTANT){
-								reset_particle(pa,psys,psmd,ob,0.0,cfra,vg_vel,vg_tan,vg_rot);
-								pa->alive=PARS_ALIVE;
-								copy_particle_key(key,&pa->state,1);
-							}
-							else
-								pa->alive=PARS_UNBORN;
+							reset_particle(pa,psys,psmd,ob,0.0,cfra,vg_vel,vg_tan,vg_rot);
+							copy_particle_key(key,&pa->state,1);
+							pa->alive=PARS_ALIVE;
 						}
 						else{
 							pa->alive=PARS_DEAD;
@@ -4307,35 +4299,8 @@
 	IpoCurve *icu_esize=find_ipocurve(part->ipo,PART_EMIT_SIZE);
 	Material *ma=give_current_material(ob,part->omat);
 	int p;
-	float ipotime=cfra, disp;
+	float ipotime=cfra, disp, birthtime, dietime;
 
-	/* deprecated */
-	//if(psys->recalc&PSYS_DISTR){
-	//	/* The dm could have been changed so particle emitter element	 */
-	//	/* indices might be wrong. There's really no "nice" way to handle*/ 
-	//	/* this so we just try not to crash by correcting indices.		 */
-	//	int totnum=-1;
-	//	switch(part->from){
-	//		case PART_FROM_VERT:
-	//			totnum=psmd->dm->getNumVerts(psmd->dm);
-	//			break;
-	//		case PART_FROM_FACE:
-	//		case PART_FROM_VOLUME:
-	//			totnum=psmd->dm->getNumFaces(psmd->dm);
-	//			break;
-	//	}
-
-	//	if(totnum==0){
-	//		/* Now we're in real trouble, there's no emitter elements!! */
-	//		for(p=0, pa=psys->particles; p<psys->totpart; p++,pa++)
-	//			pa->num=-1;
-	//	}
-	//	else if(totnum>0){
-	//		for(p=0, pa=psys->particles; p<psys->totpart; p++,pa++)
-	//			pa->num=pa->num%totnum;
-	//	}
-	//}
-
 	if(psys->effectors.first)
 		psys_end_effectors(psys);
 	
@@ -4357,22 +4322,30 @@
 
 		psys->lattice=psys_get_lattice(ob,psys);
 
+		if(part->flag & PART_LOOP)
+			pa->loop = (short)((cfra - pa->time) / pa->lifetime);
+		else
+			pa->loop = 0;
+
+		birthtime = pa->time + pa->loop * pa->lifetime;
+		dietime = birthtime + pa->lifetime;
+
 		/* update alive status and push events */
-		if(pa->time>cfra)
-			pa->alive=PARS_UNBORN;
-		else if(pa->dietime<=cfra){
-			if(pa->dietime>psys->cfra){
-				state.time=pa->dietime;
+		if(pa->time > cfra)
+			pa->alive = PARS_UNBORN;
+		else if(dietime <= cfra){
+			if(dietime > psys->cfra){
+				state.time = pa->dietime;
 				psys_get_particle_state(ob,psys,p,&state,1);
 				push_reaction(ob,psys,p,PART_EVENT_DEATH,&state);
 			}
-			pa->alive=PARS_DEAD;
+			pa->alive = PARS_DEAD;
 		}
 		else{
-			pa->alive=PARS_ALIVE;
-			state.time=cfra;
+			pa->alive = PARS_ALIVE;
+			state.time = cfra;
 			psys_get_particle_state(ob,psys,p,&state,1);
-			state.time=cfra;
+			state.time = cfra;
 			push_reaction(ob,psys,p,PART_EVENT_NEAR,&state);
 		}
 

Modified: trunk/blender/source/blender/makesdna/DNA_particle_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_particle_types.h	2008-02-17 13:41:42 UTC (rev 13724)
+++ trunk/blender/source/blender/makesdna/DNA_particle_types.h	2008-02-17 14:44:12 UTC (rev 13725)
@@ -227,7 +227,7 @@
 #define PART_REACT_MULTIPLE	2
 
 #define PART_LOOP			4
-#define PART_LOOP_INSTANT	8
+//#define PART_LOOP_INSTANT	8
 
 #define PART_HAIR_GEOMETRY	16
 

Modified: trunk/blender/source/blender/src/buttons_object.c
===================================================================
--- trunk/blender/source/blender/src/buttons_object.c	2008-02-17 13:41:42 UTC (rev 13724)
+++ trunk/blender/source/blender/src/buttons_object.c	2008-02-17 14:44:12 UTC (rev 13725)
@@ -4136,11 +4136,11 @@
 	uiDefButBitI(block, TOG, PART_GLOB_TIME, B_PART_RECALC, "Global",	 butx,(buty-=buth),butw/2,buth, &part->flag, 0, 0, 0, 0, "Set all ipos that work on particles to be calculated in global/object time");
 	uiDefButBitI(block, TOG, PART_ABS_TIME, B_PART_RECALC, "Absolute",	 butx+butw/2,buty,butw/2,buth, &part->flag, 0, 0, 0, 0, "Set all ipos that work on particles to be calculated in absolute/relative time");
 
-	if(part->flag & PART_LOOP){
-		uiDefButBitI(block, TOG, PART_LOOP, B_PART_RECALC, "Loop",	 butx,(buty-=buth),butw/2,buth, &part->flag, 0, 0, 0, 0, "Loop particle lives");
-		uiDefButBitI(block, TOG, PART_LOOP_INSTANT, B_PART_RECALC, "Instantly",	 butx+butw/2,buty,butw/2,buth, &part->flag, 0, 0, 0, 0, "Loop particle life at time of death");
-	}
-	else
+	//if(part->flag & PART_LOOP){
+	//	uiDefButBitI(block, TOG, PART_LOOP, B_PART_RECALC, "Loop",	 butx,(buty-=buth),butw/2,buth, &part->flag, 0, 0, 0, 0, "Loop particle lives");
+	//	uiDefButBitI(block, TOG, PART_LOOP_INSTANT, B_PART_RECALC, "Instantly",	 butx+butw/2,buty,butw/2,buth, &part->flag, 0, 0, 0, 0, "Loop particle life at time of death");
+	//}
+	//else
 		uiDefButBitI(block, TOG, PART_LOOP, B_PART_RECALC, "Loop",	 butx,(buty-=buth),butw,buth, &part->flag, 0, 0, 0, 0, "Loop particle lives");
 
 	uiDefButF(block, NUM, B_PART_RECALC, "Tweak:",	butx,(buty-=buth),butw,buth, &part->timetweak, 0.0, 10.0, 1, 0, "A multiplier for physics timestep (1.0 means one frame = 1/25 seconds)");





More information about the Bf-blender-cvs mailing list