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

Janne Karhu janne.karhu at utu.fi
Tue Jul 10 22:45:41 CEST 2007


Revision: 11218
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11218
Author:   jhk
Date:     2007-07-10 22:45:41 +0200 (Tue, 10 Jul 2007)

Log Message:
-----------
*bugs fixed:
	-billboards aligned to velocity didn't render correctly
	-boids wasn't listed in the physics menu when keyed physics was active, thanks olivS
	-keyed particles didn't check for valid target properly
	-a loop in keyed targets was not checked for
	-drawing particle indexes didn't work with path visualization
*new things:
	-field fall-off controls (due to space requirements also had to move deflections to a separate tab)
	-modifications to how some fields work (like for example damping=1.0 for harmonic effector is (near) critical damping)
	-even distribution is always on for children between faces
	-boid predators can now kill their prey.. this happens when predator gets closer than it's size to the prey if "die on hit" is selected in the prey system
	-option to only render child particles
	-curve guides now have options from child particle clump & kink to apply along the curve
	-curve guides can apply to child particles

Modified Paths:
--------------
    branches/particles/source/blender/blenkernel/BKE_particle.h
    branches/particles/source/blender/blenkernel/intern/particle.c
    branches/particles/source/blender/blenkernel/intern/particle_system.c
    branches/particles/source/blender/makesdna/DNA_object_force.h
    branches/particles/source/blender/makesdna/DNA_particle_types.h
    branches/particles/source/blender/render/intern/source/convertblender.c
    branches/particles/source/blender/src/buttons_object.c
    branches/particles/source/blender/src/drawobject.c

Modified: branches/particles/source/blender/blenkernel/BKE_particle.h
===================================================================
--- branches/particles/source/blender/blenkernel/BKE_particle.h	2007-07-10 19:34:41 UTC (rev 11217)
+++ branches/particles/source/blender/blenkernel/BKE_particle.h	2007-07-10 20:45:41 UTC (rev 11218)
@@ -139,7 +139,7 @@
 void psys_find_parents(struct ParticleSystemModifierData *psmd, struct ParticleSystem *psys);
 
 void psys_cache_paths(struct Object *ob, struct ParticleSystemModifierData *psmd, struct ParticleSystem *psys, float cfra);
-void do_guide(struct ParticleKey *state, int pa_num, float time, struct ListBase *lb);
+int do_guide(struct ParticleKey *state, int pa_num, float time, struct ListBase *lb);
 float psys_get_size(struct Material *ma, struct ParticleSystemModifierData *psmd, struct IpoCurve *icu_size, struct ParticleSystem *psys, struct ParticleSettings *part, struct ParticleData *pa, float *vg_size);
 float psys_get_timestep(struct ParticleSettings *part);
 float psys_get_child_time(struct ParticleSystem *psys, int child_nbr, float cfra);

Modified: branches/particles/source/blender/blenkernel/intern/particle.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/particle.c	2007-07-10 19:34:41 UTC (rev 11217)
+++ branches/particles/source/blender/blenkernel/intern/particle.c	2007-07-10 20:45:41 UTC (rev 11218)
@@ -1129,16 +1129,34 @@
 			break;
 	}
 }
-void do_guide(ParticleKey *state, int pa_num, float time, ListBase *lb)
+static void do_clump(ParticleKey *state, ParticleKey *par, float time, float clumpfac, float clumppow, float pa_clump)
 {
+	if(par && clumpfac!=0.0){
+		float clump, cpow;
+
+		if(clumppow<0.0)
+			cpow=1.0f+clumppow;
+		else
+			cpow=1.0f+9.0f*clumppow;
+
+		if(clumpfac<0.0) /* clump roots instead of tips */
+			clump = -clumpfac*pa_clump*(float)pow(1.0-(double)time,(double)cpow);
+		else
+			clump = clumpfac*pa_clump*(float)pow((double)time,(double)cpow);
+		VecLerpf(state->co,state->co,par->co,clump);
+	}
+}
+int do_guide(ParticleKey *state, int pa_num, float time, ListBase *lb)
+{
 	PartDeflect *pd;
 	ParticleEffectorCache *ec;
 	Object *eob;
 	Curve *cu;
+	ParticleKey key, par;
 
 	float effect[3]={0.0,0.0,0.0}, distance, f_force, mindist, totforce=0.0;
 	float guidevec[4], guidedir[3], rot2[4], temp[3], angle, pa_loc[3], pa_zero[3]={0.0f,0.0f,0.0f};
-	float veffect[3]={0.0,0.0,0.0};
+	float veffect[3]={0.0,0.0,0.0}, *q;
 
 	effect[0]=effect[1]=effect[2]=0.0;
 
@@ -1180,12 +1198,8 @@
 					else
 						where_on_path(eob, time, guidevec, guidedir);
 
-					Normalize(guidedir);
-
-					VECADD(guidedir,guidedir,guidevec);
 					Mat4MulVecfl(ec->ob->obmat,guidevec);
-					Mat4MulVecfl(ec->ob->obmat,guidedir);
-					VECSUB(guidedir,guidedir,guidevec);
+					Mat4Mul3Vecfl(ec->ob->obmat,guidedir);
 
 					Normalize(guidedir);
 
@@ -1200,7 +1214,14 @@
 						/* curve tilt */
 						VecRotToQuat(guidedir,guidevec[3]-ec->firstloc[3],rot2);
 						QuatMulVecf(rot2,pa_loc);
+
+						q=vectoquat(guidedir, pd->kink_axis, (pd->kink_axis+1)%3);
+						QuatMul(par.rot,rot2,q);
 					}
+					else{
+						par.rot[0]=1.0f;
+						par.rot[1]=par.rot[2]=par.rot[3]=0.0f;
+					}
 
 					/* curve taper */
 					if(cu->taperobj)
@@ -1210,8 +1231,13 @@
 					///* curve size*/
 					//	calc_curve_subdiv_radius(cu,cu->nurb.first,((Nurb*)cu->nurb.first)->
 					//}
+					par.co[0]=par.co[1]=par.co[2]=0.0f;
+					VECCOPY(key.co,pa_loc);
+					do_prekink(&key, &par, time, pd->kink_freq, pd->kink_shape, pd->kink_amp, pd->kink, pd->kink_axis, 0);
+					do_clump(&key, &par, time, pd->clump_fac, pd->clump_pow, 1.0f);
+					do_postkink(&key, &par, time, pd->kink_freq, pd->kink_shape, pd->kink_amp, pd->kink, pd->kink_axis, 0);
+					VECCOPY(pa_loc,key.co);
 
-
 					VECADD(pa_loc,pa_loc,guidevec);
 					VECSUB(pa_loc,pa_loc,pa_zero);
 					VECADDFAC(effect,effect,pa_loc,f_force);
@@ -1231,8 +1257,10 @@
 			Normalize(veffect);
 			VecMulf(veffect,VecLength(state->vel));
 			VECCOPY(state->vel,veffect);
+			return 1;
 		}
 	}
+	return 0;
 }
 static void do_rough(float *loc, float t, float fac, float size, float thres, ParticleKey *state)
 {
@@ -1404,6 +1432,9 @@
 
 	if(G.rendering)
 		steps=(int)pow(2.0,(double)part->ren_step);
+	else if(part->flag & PART_CHILD_RENDER){
+		totchild=0;
+	}
 	else{
 		totchild=(int)((float)totchild*(float)part->disp/100.0f);
 		totparent=MIN2(totparent,totchild);
@@ -1672,7 +1703,8 @@
 			}
 
 			/* apply guide curves to path data */
-			if(edit==0 && psys->effectors.first && (baked==0 || part->flag&PART_BAKED_GUIDES))
+			if(edit==0 && psys->effectors.first && (part->flag & PART_CHILD_GUIDE)==0 &&
+				(baked==0 || part->flag&PART_BAKED_GUIDES))
 				do_guide(state,p,time,&psys->effectors);
 
 			/* check if path needs to be cut before actual end of data points */
@@ -1702,6 +1734,7 @@
 
 	/*---second main loop: create all child particles' paths---*/
 	for(p=0,cpa=psys->child; p<totchild; p++, cpa++){
+		int guided=0;
 		float *cpa_fuv=0;
 		float branch_begin=BLI_frand();
 		float branch_end=branch_begin+(1.0f-branch_begin)*BLI_frand();
@@ -1839,27 +1872,19 @@
 			}
 
 			/* apply different deformations to the child path */
-			if(part->kink)
-				do_prekink(state,par,t,part->kink_freq*pa_kink,part->kink_shape,part->kink_amp,part->kink,part->kink_axis,ob->obmat);
-					
-			if(par && part->clumpfac!=0.0){
-				float clump, clumppow;
+			if(part->flag & PART_CHILD_GUIDE)
+				guided=do_guide(state,p,t,&(psys->effectors));
 
-				if(part->clumppow<0.0)
-					clumppow=1.0f+part->clumppow;
-				else
-					clumppow=1.0f+9.0f*part->clumppow;
+			if(guided==0){
+				if(part->kink)
+					do_prekink(state,par,t,part->kink_freq*pa_kink,part->kink_shape,part->kink_amp,part->kink,part->kink_axis,ob->obmat);
+						
+				do_clump(state,par,t,part->clumpfac,part->clumppow,pa_clump);
 
-				if(part->clumpfac<0.0) /* clump roots instead of tips */
-					clump = -part->clumpfac*pa_clump*(float)pow(1.0-(double)t,(double)clumppow);
-				else
-					clump = part->clumpfac*pa_clump*(float)pow((double)t,(double)clumppow);
-				VecLerpf(state->co,state->co,par->co,clump);
+				if(part->kink)
+					do_postkink(state,par,t,part->kink_freq*pa_kink,part->kink_shape,part->kink_amp,part->kink,part->kink_axis,ob->obmat);
 			}
 
-			if(part->kink)
-				do_postkink(state,par,t,part->kink_freq*pa_kink,part->kink_shape,part->kink_amp,part->kink,part->kink_axis,ob->obmat);
-
 			if(part->flag & PART_BRANCHING && between==0 && part->flag & PART_ANIM_BRANCHING)
 				rough_t = t*rough_rand;
 			else
@@ -2563,6 +2588,9 @@
 		edit=1;
 	}
 
+	if(G.rendering==0 && part->flag&PART_CHILD_RENDER)
+		totchild=0;
+
 	/* user want's cubic interpolation but only without sb it possible */
 	if(interpolation==PART_INTER_CUBIC && baked && psys->softflag==OB_SB_ENABLE)
 		interpolation=PART_INTER_BSPLINE;
@@ -2663,6 +2691,10 @@
 			keytime=(t-key1->time)/dfra;
 		}
 		else{/* keyed particles */
+			if(psys->totkeyed==0){
+				copy_particle_key(state,&pa->state,0);
+				return;
+			}
 			t*=(float)psys->totkeyed;
 
 			kpsys=psys;
@@ -2910,6 +2942,8 @@
 		cfra=bsystem_time(0,0,(float)G.scene->r.cfra,0.0);
 
 	if(psys->totchild && p>=totpart){
+		if(G.rendering==0 && part->flag&PART_CHILD_RENDER)
+			return 0;
 		if(part->from!=PART_FROM_PARTICLE && ELEM(part->childtype,PART_CHILD_EDGES,PART_CHILD_FACES)){
 			between=1;
 		}

Modified: branches/particles/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/particle_system.c	2007-07-10 19:34:41 UTC (rev 11217)
+++ branches/particles/source/blender/blenkernel/intern/particle_system.c	2007-07-10 20:45:41 UTC (rev 11218)
@@ -519,7 +519,7 @@
 	sum=MEM_callocN(sizeof(float)*tot, "particle_distribution_sum");
 
 	/* 2.1 */
-	if(part->flag&PART_EDISTR && ELEM(from,PART_FROM_PARTICLE,PART_FROM_VERT)==0){
+	if((part->flag&PART_EDISTR || children) && ELEM(from,PART_FROM_PARTICLE,PART_FROM_VERT)==0){
 		switch(from){
 			case PART_FROM_EDGE:
 			{
@@ -1404,7 +1404,11 @@
 	Object *kob=ob,*tob;
 	int select=ob->flag&SELECT;
 	short totkeyed=0;
+	Base *base;
 
+	ListBase lb;
+	lb.first=lb.last=0;
+
 	tob=psys->keyed_ob;
 	while(tob){
 		if(tob->particleSystem && kpsys->keyed_psys<=tob->totpart){
@@ -1412,6 +1416,19 @@
 			tpart=tpsys->part;
 
 			if(tpart->phystype==PART_PHYS_KEYED){
+				if(lb.first){
+					for(base=lb.first;base;base=base->next){
+						if(tob==base->object){
+							fprintf(stderr,"Error: loop in keyed chain!\n");
+							BLI_freelistN(&lb);
+							return select;
+						}
+					}
+				}
+				base=MEM_callocN(sizeof(Base), "keyed base");
+				base->object=tob;
+				BLI_addtail(&lb,base);
+
 				if(tob->flag&SELECT)
 					select++;
 				kob=tob;
@@ -1428,6 +1445,7 @@
 			tob=0;
 	}
 	psys->totkeyed=totkeyed;
+	BLI_freelistN(&lb);
 	return select;
 }
 /************************************************/
@@ -1629,90 +1647,211 @@
 /************************************************/
 /*			Effectors							*/
 /************************************************/
-static void do_physical_effector(short type, float force_val, float distance, float power, float size, float damp,
+static float effector_falloff(PartDeflect *pd, float *eff_velocity, float *vec_to_part)
+{
+	float eff_dir[3], temp[3];
+	float falloff=1.0, fac, r_fac;
+	
+	VecCopyf(eff_dir,eff_velocity);
+	Normalize(eff_dir);
+
+	if(pd->flag & PFIELD_POSZ && Inpf(eff_dir,vec_to_part)<0.0f)
+		falloff=0.0f;
+	else switch(pd->falloff){
+		case PFIELD_FALL_SPHERE:
+			fac=VecLength(vec_to_part);
+			if(pd->flag&PFIELD_USEMAX && fac>pd->maxdist){
+				falloff=0.0f;
+				break;
+			}
+
+			if(pd->flag & PFIELD_USEMIN){
+				if(fac>pd->mindist)
+					fac+=1.0f-pd->mindist;
+				else
+					fac=1.0f;
+			}
+			else if(fac<0.001)
+				fac=0.001f;
+
+			falloff=1.0f/(float)pow((double)fac,(double)pd->f_power);
+			break;
+
+		case PFIELD_FALL_TUBE:
+			fac=Inpf(vec_to_part,eff_dir);
+			if(pd->flag&PFIELD_USEMAX && ABS(fac)>pd->maxdist){
+				falloff=0.0f;
+				break;
+			}
+
+			VECADDFAC(temp,vec_to_part,eff_dir,-fac);
+			r_fac=VecLength(temp);
+			if(pd->flag&PFIELD_USEMAXR && r_fac>pd->maxrad){
+				falloff=0.0f;
+				break;
+			}
+
+			fac=ABS(fac);
+
+
+			if(pd->flag & PFIELD_USEMIN){
+				if(fac>pd->mindist)
+					fac+=1.0f-pd->mindist;
+				else
+					fac=1.0f;
+			}
+			else if(fac<0.001)
+				fac=0.001f;
+
+			if(pd->flag & PFIELD_USEMINR){

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list