[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11127] branches/particles/source/blender: *bugs fixed:

Janne Karhu janne.karhu at utu.fi
Sat Jun 30 01:41:51 CEST 2007


Revision: 11127
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11127
Author:   jhk
Date:     2007-06-30 01:41:50 +0200 (Sat, 30 Jun 2007)

Log Message:
-----------
*bugs fixed:
	-adding particles in particle mode crashed and as an extra bonus bug had a memory leak :)
	-explode modifier didn't update properly when "use size" was toggled
	-particle instance modifier crashed with child particles
*new things:
	-the first texture channel is mapped to the "halotex" texture if wanted (halotex selected), previously in this case halos discarded the rest of the texture channels, but now they're applied normally on top of the first channel with specified blending modes
	-global & object mapping works for halo textures
	-multi- & single-reactions
	-variable reaction strength dependence on distance to particle
	-set default billboard alignment to view
	-split and non-split uv coordinate selection for billboards (now possible for example: alpha is same for every bb, colour/image different)
	-emit time ipo changed to emit frequency (i.e. how many particles per frame)

Modified Paths:
--------------
    branches/particles/source/blender/blenkernel/intern/ipo.c
    branches/particles/source/blender/blenkernel/intern/modifier.c
    branches/particles/source/blender/blenkernel/intern/particle.c
    branches/particles/source/blender/blenkernel/intern/particle_edit.c
    branches/particles/source/blender/blenkernel/intern/particle_system.c
    branches/particles/source/blender/makesdna/DNA_ipo_types.h
    branches/particles/source/blender/makesdna/DNA_particle_types.h
    branches/particles/source/blender/render/intern/source/convertblender.c
    branches/particles/source/blender/render/intern/source/renderdatabase.c
    branches/particles/source/blender/src/buttons_editing.c
    branches/particles/source/blender/src/buttons_object.c
    branches/particles/source/blender/src/drawobject.c
    branches/particles/source/blender/src/editipo.c
    branches/particles/source/blender/src/editipo_lib.c
    branches/particles/source/blender/src/transform_conversions.c

Modified: branches/particles/source/blender/blenkernel/intern/ipo.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/ipo.c	2007-06-29 16:16:24 UTC (rev 11126)
+++ branches/particles/source/blender/blenkernel/intern/ipo.c	2007-06-29 23:41:50 UTC (rev 11127)
@@ -182,7 +182,7 @@
 };
 
 int part_ar[PART_TOTIPO]= {
-	PART_EMIT_TIME, PART_EMIT_LIFE, PART_EMIT_VEL, PART_EMIT_AVE, PART_EMIT_SIZE,
+	PART_EMIT_FREQ, PART_EMIT_LIFE, PART_EMIT_VEL, PART_EMIT_AVE, PART_EMIT_SIZE,
 	PART_AVE, PART_SIZE, PART_DRAG, PART_BROWN, PART_DAMP, PART_LENGTH, PART_CLUMP,
     PART_GRAV_X, PART_GRAV_Y, PART_GRAV_Z, PART_KINK_AMP, PART_KINK_FREQ, PART_KINK_SHAPE,
 	PART_BB_TILT
@@ -1534,7 +1534,7 @@
 		part= (ParticleSettings *)id;
 		
 		switch(icu->adrcode) {
-		case PART_EMIT_TIME:
+		case PART_EMIT_FREQ:
 		case PART_EMIT_LIFE:
 		case PART_EMIT_VEL:
 		case PART_EMIT_AVE:

Modified: branches/particles/source/blender/blenkernel/intern/modifier.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/modifier.c	2007-06-29 16:16:24 UTC (rev 11126)
+++ branches/particles/source/blender/blenkernel/intern/modifier.c	2007-06-29 23:41:50 UTC (rev 11127)
@@ -5206,11 +5206,28 @@
 		MFace *inMF;
 		MFace *mf = mface + i;
 
-		pa=pars+i/totface;
+		if(pimd->flag & eParticleInstanceFlag_Parents){
+			if(i/totface>=psys->totpart){
+				if(psys->part->childtype==PART_CHILD_PARTICLES)
+					pa=psys->particles+(psys->child+i/totface-psys->totpart)->parent;
+				else
+					pa=0;
+			}
+			else
+				pa=pars+i/totface;
+		}
+		else{
+			if(psys->part->childtype==PART_CHILD_PARTICLES)
+				pa=psys->particles+(psys->child+i/totface)->parent;
+			else
+				pa=0;
+		}
 
-		if(pa->alive==PARS_UNBORN && (pimd->flag&eParticleInstanceFlag_Unborn)==0) continue;
-		if(pa->alive==PARS_ALIVE && (pimd->flag&eParticleInstanceFlag_Alive)==0) continue;
-		if(pa->alive==PARS_DEAD && (pimd->flag&eParticleInstanceFlag_Dead)==0) continue;
+		if(pa){
+			if(pa->alive==PARS_UNBORN && (pimd->flag&eParticleInstanceFlag_Unborn)==0) continue;
+			if(pa->alive==PARS_ALIVE && (pimd->flag&eParticleInstanceFlag_Alive)==0) continue;
+			if(pa->alive==PARS_DEAD && (pimd->flag&eParticleInstanceFlag_Dead)==0) continue;
+		}
 
 		inMF = orig_mface + i%totface;
 		DM_copy_face_data(dm, result, i%totface, i, 1);
@@ -6077,9 +6094,12 @@
 		if(psys->part==0 || psys->particles==0) return derivedData;
 
 		/* 1. find faces to be exploded if needed */
-		if(emd->facepa==0 || psmd->flag & (eParticleSystemFlag_Pars+eExplodeFlag_CalcFaces)){
+		if(emd->facepa==0 || psmd->flag&eParticleSystemFlag_Pars || emd->flag&eExplodeFlag_CalcFaces){
 			if(psmd->flag & eParticleSystemFlag_Pars)
 				psmd->flag &= ~eParticleSystemFlag_Pars;
+			
+			if(emd->flag & eExplodeFlag_CalcFaces)
+				emd->flag &= ~eExplodeFlag_CalcFaces;
 
 			explodeModifier_createFacepa(emd,psmd,derivedData);
 		}

Modified: branches/particles/source/blender/blenkernel/intern/particle.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/particle.c	2007-06-29 16:16:24 UTC (rev 11126)
+++ branches/particles/source/blender/blenkernel/intern/particle.c	2007-06-29 23:41:50 UTC (rev 11127)
@@ -2238,6 +2238,8 @@
 	part->distr= PART_DISTR_JIT;
 	part->draw_as=PART_DRAW_DOT;
 	part->bb_uv_split=1;
+	part->bb_align=PART_BB_VIEW;
+	part->flag=PART_REACT_MULTIPLE;
 
 	part->sta= 1.0;
 	part->end= 100.0;
@@ -2270,6 +2272,8 @@
 	part->max_tan_acc = 0.2f;
 	part->max_lat_acc = 1.0f;
 
+	part->reactshape=1.0f;
+
 	part->mass=1.0;
 	part->size=1.0;
 	part->childsize=1.0;

Modified: branches/particles/source/blender/blenkernel/intern/particle_edit.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/particle_edit.c	2007-06-29 16:16:24 UTC (rev 11126)
+++ branches/particles/source/blender/blenkernel/intern/particle_edit.c	2007-06-29 23:41:50 UTC (rev 11127)
@@ -1713,8 +1713,8 @@
 		ParticleTreeNode *tree=0;
 		ParticleData *pa, *npa, *new_pars = MEM_callocN(newtotpart*sizeof(ParticleData),"ParticleData new");
 		ParticleKey **key, **nkey, **new_keys = MEM_callocN(newtotpart*sizeof(ParticleKey *),"ParticleKey array new");
-		float **nlen, **new_lengths = MEM_callocN(newtotpart*sizeof(float *),"Particle length array new");
-		float **nwco, **new_wcos = MEM_callocN(newtotpart*sizeof(float *),"Particle wcos array new");
+		float **olen, **nlen, **new_lengths = MEM_callocN(newtotpart*sizeof(float *),"Particle length array new");
+		float **owco, **nwco, **new_wcos = MEM_callocN(newtotpart*sizeof(float *),"Particle wcos array new");
 
 		if(ep->flag&PSYS_EP_ADD_INTERP && psys->totpart){
 			ParticleTreeNode *cur;
@@ -1731,7 +1731,9 @@
 		npa=new_pars;
 		key=psys->keys;
 		nkey=new_keys;
+		olen=ep->lengths;
 		nlen=new_lengths;
+		owco=ep->world_cos;
 		nwco=new_wcos;
 
 		for(i=0; i<newtotpart; i++, pa++, npa++, key++, nkey++, nlen++, nwco++){
@@ -1740,6 +1742,10 @@
 				memcpy(nkey,key,sizeof(ParticleKey*));
 				*nlen=MEM_callocN((pa->totkey-1)*sizeof(float),"Particle length");
 				*nwco=MEM_callocN(3*pa->totkey*sizeof(float),"Particle wco");
+				MEM_freeN(*olen);
+				MEM_freeN(*owco);
+				olen++;
+				owco++;
 			}
 			else{
 				memcpy(npa,add_pars+i-psys->totpart,sizeof(ParticleData));

Modified: branches/particles/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/particle_system.c	2007-06-29 16:16:24 UTC (rev 11126)
+++ branches/particles/source/blender/blenkernel/intern/particle_system.c	2007-06-29 23:41:50 UTC (rev 11127)
@@ -938,11 +938,11 @@
 	if(part->type==PART_REACTOR && (part->flag&PART_REACT_STA_END)==0)
 		pa->time=MAXFRAMEF;
 	else{
-		icu=find_ipocurve(psys->part->ipo,PART_EMIT_TIME);
-		if(icu){
-			calc_icu(icu,100*ptex.time);
-			ptex.time=icu->curval;
-		}
+		//icu=find_ipocurve(psys->part->ipo,PART_EMIT_TIME);
+		//if(icu){
+		//	calc_icu(icu,100*ptex.time);
+		//	ptex.time=icu->curval;
+		//}
 
 		pa->time= part->sta + (part->end - part->sta)*ptex.time;
 	}
@@ -998,11 +998,58 @@
 	pa->loop=0;
 }
 static void initialize_all_particles(Object *ob, ParticleSystem *psys, ParticleSystemModifierData *psmd){
+	IpoCurve *icu=0;
 	ParticleData *pa;
 	int p, totpart=psys->totpart;
 
 	for(p=0, pa=psys->particles; p<totpart; p++, pa++)
 		initialize_particle(pa,p,ob,psys,psmd);
+
+	icu=find_ipocurve(psys->part->ipo,PART_EMIT_FREQ);
+	if(icu){
+		float time=psys->part->sta, end=psys->part->end;
+		float v1, v2, a=0.0f, t1,t2, d;
+
+		p=0;
+		pa=psys->particles;
+
+		calc_icu(icu,time);
+		v1=icu->curval;
+		if(v1<0.0f) v1=0.0f;
+
+		calc_icu(icu,time+1.0f);
+		v2=icu->curval;
+		if(v2<0.0f) v2=0.0f;
+
+		for(p=0, pa=psys->particles; p<totpart && time<end; p++, pa++){
+			while(a+0.5*(v1+v2) < (float)(p+1) && time<end){
+				a+=0.5*(v1+v2);
+				v1=v2;
+				time++;
+				calc_icu(icu,time+1.0f);
+				v2=icu->curval;
+			}
+			if(time<end){
+				if(v1==v2){
+					pa->time=time+((float)(p+1)-a)/v1;
+				}
+				else{
+					d=sqrt(v1*v1-2.0f*(v2-v1)*(a-(float)(p+1)));
+					t1=(-v1+d)/(v2-v1);
+					t2=(-v1-d)/(v2-v1);
+
+					/* the root between 0-1 is the correct one */
+					if(t1>0.0f && t1<=1.0f)
+						pa->time=time+t1;
+					else
+						pa->time=time+t2;
+				}
+			}
+		}
+		for(; p<totpart; p++, pa++){
+			pa->time=MAXFRAMEF;
+		}
+	}
 }
 /* sets particle to the emitter surface with initial velocity & rotation */
 void reset_particle(ParticleData *pa, ParticleSystem *psys, ParticleSystemModifierData *psmd, Object *ob, float dtime, float cfra, float *vg_vel){
@@ -1322,97 +1369,133 @@
 	ParticleSettings *part=psys->part;
 	ParticleData *pa=psys->particles+pa_num;
 	ParticleReactEvent *re=psys->reactevents.first;
-	int react=0;
+	int birth=0;
 	float dist=0.0f;
 
 	for(re=psys->reactevents.first; re; re=re->next){
-		react=0;
-		switch(re->event){
-			case PART_EVENT_DEATH:
-				if(part->from==PART_FROM_PARTICLE){
-					if(pa->alive==PARS_UNBORN && pa->num==re->pa_num){
+		birth=0;
+		if(part->from==PART_FROM_PARTICLE){
+			if(pa->num==re->pa_num){
+				if(re->event==PART_EVENT_NEAR){
+					ParticleData *tpa = re->psys->particles+re->pa_num;
+					float pa_time=tpa->time + pa->fuv[2]*tpa->lifetime;
+					if(re->time > pa_time){
 						pa->alive=PARS_ALIVE;
-						pa->time=re->time;
+						pa->time=pa_time;
 						pa->dietime=pa->time+pa->lifetime;
 					}
 				}
 				else{
-					dist=VecLenf(pa->state.co, re->state.co);
-					if(dist <= re->size){
-						if(pa->alive==PARS_UNBORN){
-							pa->alive=PARS_ALIVE;
-							pa->time=re->time;
-							pa->dietime=pa->time+pa->lifetime;
-						}
-						react=1;
+					if(pa->alive==PARS_UNBORN){
+						pa->alive=PARS_ALIVE;
+						pa->time=re->time;
+						pa->dietime=pa->time+pa->lifetime;
 					}
 				}
-				break;
-			case PART_EVENT_COLLIDE:
-				if(part->from==PART_FROM_PARTICLE){
-					if(pa->num==re->pa_num){
-						if(pa->alive==PARS_UNBORN){
-							pa->alive=PARS_ALIVE;
-							pa->time=re->time;
-							pa->dietime=pa->time+pa->lifetime;
-						}
-					}
+			}
+		}
+		else{
+			dist=VecLenf(pa->state.co, re->state.co);
+			if(dist <= re->size){
+				if(pa->alive==PARS_UNBORN){
+					pa->alive=PARS_ALIVE;
+					pa->time=re->time;
+					pa->dietime=pa->time+pa->lifetime;
+					birth=1;
 				}
-				else{
-					dist=VecLenf(pa->state.co,re->state.co);
-					if(dist <= re->size){
-						//float tan[3],tan2[3];
+			if(birth || part->flag&PART_REACT_MULTIPLE){
+				float vec[3];
+				VECSUB(vec,pa->state.co, re->state.co);
+				if(birth==0)
+					VecMulf(vec,pow(1.0f-dist/re->size,part->reactshape));
+				VECADDFAC(pa->state.vel,pa->state.vel,vec,part->reactfac);
+				VECADDFAC(pa->state.vel,pa->state.vel,re->state.vel,part->partfac);
+			}
+			if(birth)
+				VecMulf(pa->state.vel,pow(1.0f-dist/re->size,part->reactshape));
+			}
+		}
+		//switch(re->event){
+		//	case PART_EVENT_DEATH:
+		//		if(part->from==PART_FROM_PARTICLE){
+		//			if(pa->alive==PARS_UNBORN && pa->num==re->pa_num){
+		//				pa->alive=PARS_ALIVE;
+		//				pa->time=re->time;
+		//				pa->dietime=pa->time+pa->lifetime;
+		//			}
+		//		}
+		//		else{
+		//			dist=VecLenf(pa->state.co, re->state.co);
+		//			if(dist <= re->size){
+		//				if(pa->alive==PARS_UNBORN){
+		//					pa->alive=PARS_ALIVE;
+		//					pa->time=re->time;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list