[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12437] branches/particles/source/blender: -Removed "edges" as an option for emitting particles and children as it wasn' t really a realistic option for usage and caused nasty problems for proper interpolation through modifier stack .

Janne Karhu jhkarh at utu.fi
Tue Oct 30 13:51:16 CET 2007


Revision: 12437
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12437
Author:   jhk
Date:     2007-10-30 13:51:15 +0100 (Tue, 30 Oct 2007)

Log Message:
-----------
-Removed "edges" as an option for emitting particles and children as it wasn't really a realistic option for usage and caused nasty problems for proper interpolation through modifier stack. If people have some recent blends then I recommend switching particle distributions to "from vertices" in an old build for the particles to load properly before using a build after this commit.
-There was a bug in child path random length calculation that led to a crash.

Modified Paths:
--------------
    branches/particles/source/blender/blenkernel/intern/particle.c
    branches/particles/source/blender/blenkernel/intern/particle_system.c
    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
    branches/particles/source/blender/src/editparticle.c

Modified: branches/particles/source/blender/blenkernel/intern/particle.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/particle.c	2007-10-30 11:18:50 UTC (rev 12436)
+++ branches/particles/source/blender/blenkernel/intern/particle.c	2007-10-30 12:51:15 UTC (rev 12437)
@@ -764,11 +764,6 @@
 	switch(from){
 		case PART_FROM_VERT:
 			return values[index];
-		case PART_FROM_EDGE:
-		{
-			MEdge *me=dm->getEdgeData(dm,index,CD_MEDGE);
-			return (1.0f-fuv[0])*values[me->v1] + fuv[0]*values[me->v2];
-		}
 		case PART_FROM_FACE:
 		case PART_FROM_VOLUME:
 		{
@@ -791,61 +786,34 @@
 	if (deform_only) {
 		/* this works for meshes with deform verts only - constructive modifiers wont work properly*/
 		float temp1[3], temp2[3];
-		switch(from){
-			case PART_FROM_VERT:
-				dm->getVertCo(dm,index,vec);
-				if(nor){
-					dm->getVertNo(dm,index,nor);
-					Normalize(nor);
-				}
-				break;
-			case PART_FROM_EDGE:
-			{
-				MEdge *me=dm->getEdgeData(dm,index,CD_MEDGE);
-				MVert *mv1=dm->getVertData(dm,me->v1,CD_MVERT);
-				MVert *mv2=dm->getVertData(dm,me->v2,CD_MVERT);
-	
-				VecSubf(temp1,mv2->co,mv1->co);
-				VECADDFAC(vec,mv1->co,temp1,fuv[0]);
-	
-				/*make float normals*/
-				if(nor){
-					VECCOPY(temp1,mv1->no);
-					VECCOPY(temp2,mv2->no);
-					Normalize(temp1);
-					Normalize(temp2);
-	
-					VECSUB(temp2,temp2,temp1)
-					VECADDFAC(nor,temp1,temp2,fuv[0]);
-				}
-				break;
+		if(from == PART_FROM_VERT) {
+			dm->getVertCo(dm,index,vec);
+			if(nor){
+				dm->getVertNo(dm,index,nor);
+				Normalize(nor);
 			}
-			case PART_FROM_FACE:
-			case PART_FROM_VOLUME:
-			{
-				MFace *mface=dm->getFaceData(dm,index,CD_MFACE);
-				MTFace *mtface=0;
-				MVert *mvert=dm->getVertDataArray(dm,CD_MVERT);
-				int uv_index=CustomData_get_active_layer_index(&dm->faceData,CD_MTFACE);
-	
-				if(uv_index>=0){
-					CustomDataLayer *layer=&dm->faceData.layers[uv_index];
-					mtface= &((MTFace*)layer->data)[index];
-				}
-	
-				if(from==PART_FROM_VOLUME){
-					psys_interpolate_face(mvert,mface,mtface,fuv,vec,temp1,utan,vtan);
-					if(nor)
-						VECCOPY(nor,temp1);
-					Normalize(temp1);
-					VecMulf(temp1,-fuv[2]);
-					VECADD(vec,vec,temp1);
-				}
-				else
-					psys_interpolate_face(mvert,mface,mtface,fuv,vec,nor,utan,vtan);
-	
-				break;
+		}
+		else { /* PART_FROM_FACE / PART_FROM_VOLUME */
+			MFace *mface=dm->getFaceData(dm,index,CD_MFACE);
+			MTFace *mtface=0;
+			MVert *mvert=dm->getVertDataArray(dm,CD_MVERT);
+			int uv_index=CustomData_get_active_layer_index(&dm->faceData,CD_MTFACE);
+
+			if(uv_index>=0){
+				CustomDataLayer *layer=&dm->faceData.layers[uv_index];
+				mtface= &((MTFace*)layer->data)[index];
 			}
+
+			if(from==PART_FROM_VOLUME){
+				psys_interpolate_face(mvert,mface,mtface,fuv,vec,temp1,utan,vtan);
+				if(nor)
+					VECCOPY(nor,temp1);
+				Normalize(temp1);
+				VecMulf(temp1,-fuv[2]);
+				VECADD(vec,vec,temp1);
+			}
+			else
+				psys_interpolate_face(mvert,mface,mtface,fuv,vec,nor,utan,vtan);
 		}
 	} else {
 		/* Need to support constructive modifiers, this is a bit more tricky
@@ -1334,10 +1302,10 @@
 }
 static int check_path_length(int k, int p, ParticleCacheKey **cache, ParticleCacheKey *state, float length, float *dvec)
 {
-	static float max_length=1.0, cur_length=0.0;
+	static float max_length = 1.0, cur_length = 0.0;
 
-	if(k){
-		if(cur_length+length>max_length){
+	if(k) {
+		if(cur_length + length > max_length){
 			//if(p<totparent){
 			//	if(k<=(int)cache[totpart+p]->time){
 			//		/* parents need to be calculated fully first so that they don't mess up their children */
@@ -1347,18 +1315,18 @@
 			//	}
 			//}
 			//else{
-			VecMulf(dvec,(max_length-cur_length)/length);
-			VECADD(state->co,(state-1)->co,dvec);
-			cache[p]->col[3]=(float)k;
+			VecMulf(dvec, (max_length - cur_length) / length);
+			VECADD(state->co, (state - 1)->co, dvec);
+			cache[p]->steps = k;
 			/* something over the maximum step value */
 			return k=100000;
 			//}
 		}
-		else{
+		else {
 			cur_length+=length;
 		}
 	}
-	else{/* reset signal */
+	else {/* reset signal */
 		max_length=length;
 		cur_length=0.0;
 	}
@@ -1366,13 +1334,13 @@
 }
 static void finalize_path_length(int p, ParticleCacheKey **cache)
 {
-	ParticleCacheKey *state=cache[p];
+	ParticleCacheKey *state = cache[p];
 	float dvec[3];
-	state+=(int)state->col[3];
+	state += state->steps;
 
-	VECSUB(dvec,state->co,(state-1)->co);
-	VecMulf(dvec,state->col[3]);
-	VECADD(state->co,(state-1)->co,dvec);
+	VECSUB(dvec, state->co, (state - 1)->co);
+	VecMulf(dvec, state->steps);
+	VECADD(state->co, (state - 1)->co, dvec);
 }
 static void offset_child(ChildParticle *cpa, ParticleKey *par, ParticleKey *child, float flat, float radius)
 {
@@ -1417,7 +1385,7 @@
 	ChildParticle *cpa;
 	int p, totparent,totchild=psys->totchild;
 	float co[3], *orcos=0;
-	int from=(part->childtype==PART_CHILD_FACES)?PART_FROM_FACE:PART_FROM_EDGE;
+	int from=PART_FROM_FACE;
 
 	totparent=(int)(totchild*part->parents*0.3);
 
@@ -1460,7 +1428,7 @@
 	float *vg_rough1 = 0, *vg_rough2 = 0, *vg_roughe = 0;
 	float cpa_1st[3];
 
-	int k, i, totparent=0, between=0;
+	int k, i, totparent=0, between=0, edit=0;
 	int steps = (int)pow(2.0,(double)part->draw_step);
 	int totchild = psys->totchild;
 
@@ -1472,13 +1440,13 @@
 		BLI_srandom(31415926 + psys->seed);
 
 	/*---start figuring out what is actually wanted---*/
-	//if(ob==OBACT && G.f & G_PARTICLEEDIT && psys==psys_get_current(ob)){
-	//	if(G.rendering==0 && (psys->edit_path->flag & PSYS_EP_SHOW_CHILD)==0)
-	//		totchild=0;
-	//	edit=1;
-	//}
+	if(ob==OBACT && G.f & G_PARTICLEEDIT && psys==psys_get_current(ob)){
+		if(G.rendering==0 && (psys->edit->flag & PE_SHOW_CHILD)==0)
+			totchild=0;
+		edit=1;
+	}
 
-	if(totchild && part->from!=PART_FROM_PARTICLE && ELEM(part->childtype,PART_CHILD_EDGES,PART_CHILD_FACES)){
+	if(totchild && part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES){
 		totparent=(int)(totchild*part->parents*0.3);
 		/* part->parents could still be 0 so we can't test with totparent */
 		between=1;
@@ -1486,20 +1454,15 @@
 
 	if(G.rendering)
 		steps=(int)pow(2.0,(double)part->ren_step);
-	//else if(part->flag & PART_CHILD_RENDER){
-	//	totchild=0;
-	//}
+	else if(part->flag & PART_CHILD_RENDER){
+		totchild=0;
+	}
 	else{
 		totchild=(int)((float)totchild*(float)part->disp/100.0f);
 		totparent=MIN2(totparent,totchild);
 	}
 
-	/* 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;
-	//else if(baked==0) /* it doesn't make sense to use other types for keyed */
-	//	interpolation=PART_INTER_CUBIC;
-	/*---end figuring out part---*/
+	if(totchild==0) return;
 
 	/* clear out old and create new empty path cache */
 	free_child_path_cache(psys);
@@ -1563,7 +1526,7 @@
 			if(part->childtype == PART_CHILD_FACES)
 				temp_fuv[2] = -(2.0f + part->childspread);
 			cpa_fuv = cpa->fuv;
-			cpa_from = (part->childtype == PART_CHILD_FACES) ? PART_FROM_FACE : PART_FROM_EDGE;
+			cpa_from = PART_FROM_FACE;
 
 			psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,cpa_from,cpa_num,temp_fuv,orco,0,0,0);
 
@@ -2570,25 +2533,14 @@
 	ParticleSettings *part = psys->part;
 	ChildParticle *cpa=psys->child+child_nbr;
 
-	if(ELEM(part->childtype,PART_CHILD_EDGES,PART_CHILD_FACES)){
+	if(part->childtype==PART_CHILD_FACES){
 		float time;
 		int w=0;
-		//if(part->flag&PART_BETWEEN_FACES){
-			//if(cpa->pa[3])
-			//	time=interpolate_particle_value((psys->particles+cpa->pa[0])->time,(psys->particles+cpa->pa[1])->time,
-			//											(psys->particles+cpa->pa[2])->time,(psys->particles+cpa->pa[3])->time,cpa->fuv,1);
-			//else
-				//time=interpolate_particle_value((psys->particles+cpa->pa[0])->time,(psys->particles+cpa->pa[2])->time,
-				//										(psys->particles+cpa->pa[3])->time,0.0,cpa->fuv,1);
-			time=0.0;
-			while(cpa->pa[w]>=0 && w<4){
-				time+=cpa->w[w]*(psys->particles+cpa->pa[w])->time;
-				w++;
-			}
-		//}
-		//else{
-		//	time=(1.0f-cpa->fuv[0])*(psys->particles+cpa->pa[0])->time + cpa->fuv[0]*(psys->particles+cpa->pa[1])->time;
-		//}
+		time=0.0;
+		while(cpa->pa[w]>=0 && w<4){
+			time+=cpa->w[w]*(psys->particles+cpa->pa[w])->time;
+			w++;
+		}
 
 		return (cfra-time)/(part->lifetime*(1.0f-part->randlife*cpa->rand[1]));
 	}
@@ -2603,7 +2555,7 @@
 	ChildParticle *cpa = psys->child + child_nbr;
 	float size, time;
 	
-	if(ELEM(part->childtype,PART_CHILD_EDGES,PART_CHILD_FACES)){
+	if(part->childtype==PART_CHILD_FACES){
 		if(pa_time)
 			time=*pa_time;
 		else
@@ -2754,7 +2706,7 @@
 		
 		cpa=psys->child+p-totpart;
 		
-		if(totchild && part->from!=PART_FROM_PARTICLE && ELEM(part->childtype,PART_CHILD_EDGES,PART_CHILD_FACES)){
+		if(totchild && part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES){
 			totparent=(int)(totchild*part->parents*0.3);
 			/* part->parents could still be 0 so we can't test with totparent */
 			between=1;
@@ -2777,7 +2729,7 @@
 			if(part->childtype == PART_CHILD_FACES)
 				temp_fuv[2] = -(2.0f + part->childspread);
 			cpa_fuv = cpa->fuv;
-			cpa_from = (part->childtype == PART_CHILD_FACES) ? PART_FROM_FACE : PART_FROM_EDGE;
+			cpa_from = PART_FROM_FACE;
 
 			psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,cpa_from,cpa_num,temp_fuv,orco,0,0,0);
 
@@ -2919,7 +2871,7 @@
 	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)){
+		if(part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES){
 			between=1;
 		}
 		else

Modified: branches/particles/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/particle_system.c	2007-10-30 11:18:50 UTC (rev 12436)
+++ branches/particles/source/blender/blenkernel/intern/particle_system.c	2007-10-30 12:51:15 UTC (rev 12437)
@@ -229,8 +229,6 @@
 				+(int)(vec[2]*(size[2]-1)))->flag &= ~PARS_UNEXIST;
 		}
 	}
-	else if(from==PART_FROM_EDGE){
-	}
 	else if(ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)){
 		float co1[3], co2[3];
 
@@ -396,7 +394,7 @@
 	if(from==PART_FROM_CHILD){
 		distr=PART_DISTR_RAND;
 		cpa=psys->child;
-		if(part->from!=PART_FROM_PARTICLE && ELEM(part->childtype,PART_CHILD_EDGES,PART_CHILD_FACES)){

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list