[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12461] branches/particles/source/blender: last update broke some stuff, some things are fixed here

Campbell Barton cbarton at metavr.com
Sat Nov 3 20:23:13 CET 2007


Revision: 12461
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12461
Author:   campbellbarton
Date:     2007-11-03 20:23:13 +0100 (Sat, 03 Nov 2007)

Log Message:
-----------
last update broke some stuff, some things are fixed here

Modified Paths:
--------------
    branches/particles/source/blender/blenkernel/BKE_particle.h
    branches/particles/source/blender/blenkernel/intern/modifier.c
    branches/particles/source/blender/blenkernel/intern/particle.c
    branches/particles/source/blender/blenkernel/intern/particle_system.c
    branches/particles/source/blender/render/intern/source/convertblender.c

Modified: branches/particles/source/blender/blenkernel/BKE_particle.h
===================================================================
--- branches/particles/source/blender/blenkernel/BKE_particle.h	2007-11-03 18:27:27 UTC (rev 12460)
+++ branches/particles/source/blender/blenkernel/BKE_particle.h	2007-11-03 19:23:13 UTC (rev 12461)
@@ -196,7 +196,7 @@
 
 void copy_particle_key(struct ParticleKey *to, struct ParticleKey *from, int time);
 
-void psys_particle_on_emitter(int deform_only, struct ParticleSystemModifierData *psmd, int distr, int index, float *fuv, float *vec, float *nor, float *utan, float *vtan);
+void psys_particle_on_emitter(int deform_only, struct ParticleSystemModifierData *psmd, int distr, int index, int index_dmcache, float *fuv, float *vec, float *nor, float *utan, float *vtan);
 struct ParticleSystemModifierData *psys_get_modifier(struct Object *ob, struct ParticleSystem *psys);
 
 struct ParticleSettings *psys_new_settings(char *name);
@@ -253,6 +253,8 @@
 void initialize_particle(struct ParticleData *pa, int p, Object *ob, struct ParticleSystem *psys, struct ParticleSystemModifierData *psmd);
 void reset_particle(struct ParticleData *pa, struct ParticleSystem *psys, struct ParticleSystemModifierData *psmd, struct Object *ob, float dtime, float cfra, float *vg_vel, float *vg_tan, float *vg_rot);
 
+int psys_particle_dm_face_lookup(struct DerivedMesh *dm, int index, float *fuv, struct LinkNode *node);
+
 /* particle_edit.c */
 //void pe_free_edit_path(struct ParticleSystem *psys);
 //void pe_iterate_lengths(struct ParticleSystem *psys);

Modified: branches/particles/source/blender/blenkernel/intern/modifier.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/modifier.c	2007-11-03 18:27:27 UTC (rev 12460)
+++ branches/particles/source/blender/blenkernel/intern/modifier.c	2007-11-03 19:23:13 UTC (rev 12461)
@@ -6005,7 +6005,7 @@
 	for(i=0, pa=pars; i<=totpart; i++, pa++){
 
 		if(i!=totpart){
-			psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,part->from,pa->num,pa->fuv,loc0,nor,0,0);
+			psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,part->from,pa->num,-1,pa->fuv,loc0,nor,0,0);
 			Mat4MulVecfl(ob->obmat,loc0);
 
 			state.time=cfra;

Modified: branches/particles/source/blender/blenkernel/intern/particle.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/particle.c	2007-11-03 18:27:27 UTC (rev 12460)
+++ branches/particles/source/blender/blenkernel/intern/particle.c	2007-11-03 19:23:13 UTC (rev 12461)
@@ -808,10 +808,10 @@
 			if (*(oi+node_index) == index) {
 				if ( mface->v4 ) { /* check that this intersects - Its possible this misses :/ - could also check its not between */
 					if (IsectPQ2Df(fuv, osface_node->uv[0], osface_node->uv[1], osface_node->uv[2], osface_node->uv[3])) {
-						return i;
+						return node_index;
 					}
 				} else if (IsectPT2Df(fuv, osface_node->uv[0], osface_node->uv[1], osface_node->uv[2])) {
-					return i;
+					return node_index;
 				}
 			}
 		}
@@ -923,8 +923,8 @@
 			} else {
 				i = index_dmcache;
 			}
+			printf("Index DMCACHE %i\n", index_dmcache);
 			
-			
 			/* Any time this happens, and the face has not been removed,
 			* its a BUG watch out for this error! */
 			if (i==-1) {
@@ -1003,7 +1003,7 @@
 /************************************************/
 /*			Particles on emitter				*/
 /************************************************/
-void psys_particle_on_emitter(int deform_only, ParticleSystemModifierData *psmd, int from, int index, float *fuv, float *vec, float *nor, float *utan, float *vtan){
+void psys_particle_on_emitter(int deform_only, ParticleSystemModifierData *psmd, int from, int index, int index_dmcache, float *fuv, float *vec, float *nor, float *utan, float *vtan){
 	if(psmd){
 		if(psmd->psys->part->distr==PART_DISTR_GRID){
 			if(vec){
@@ -1012,7 +1012,7 @@
 			return;
 		}
 		/* we cant use the num_dmcache */
-		psys_particle_on_dm(psmd->dm,deform_only,from,index, -1,fuv,vec,nor,utan,vtan);
+		psys_particle_on_dm(psmd->dm,deform_only,from,index,index_dmcache,fuv,vec,nor,utan,vtan);
 	}
 	else
 		psys_particle_on_shape(from,index,fuv,vec,nor,utan,vtan);
@@ -1502,7 +1502,7 @@
 	tree=alloc_kdtree(totparent);
 
 	for(p=0,cpa=psys->child,cur=tree; p<totparent; p++,cpa++,cur++){
-		psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,from,cpa->num,cpa->fuv,cur->co,0,0,0);
+		psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,from,cpa->num,-1,cpa->fuv,cur->co,0,0,0);
 
 		cur->nbr=p;
 
@@ -1510,7 +1510,7 @@
 	}
 
 	for(; p<totchild; p++,cpa++){
-		psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,from,cpa->num,cpa->fuv,co,0,0,0);
+		psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,from,cpa->num,-1,cpa->fuv,co,0,0,0);
 
 		cpa->parent=find_nearest_in_kdtree(tree,co);
 	}
@@ -1541,7 +1541,7 @@
 	int k, i, totparent=0, between=0, edit=0;
 	int steps = (int)pow(2.0,(double)part->draw_step);
 	int totchild = psys->totchild;
-
+	int deform_only = modifiers_isDeformedOnly(ob);
 	int cpa_num; short cpa_from;
 
 	if(part->flag & PART_ANIM_BRANCHING)
@@ -1638,7 +1638,7 @@
 			cpa_fuv = cpa->fuv;
 			cpa_from = PART_FROM_FACE;
 
-			psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,cpa_from,cpa_num,temp_fuv,orco,0,0,0);
+			psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,cpa_from,cpa_num,-1,temp_fuv,orco,0,0,0);
 
 			/* we need to save the actual root position of the child for positioning it accurately to the surface of the emitter */
 			VECCOPY(cpa_1st,orco);
@@ -1657,7 +1657,7 @@
 			cpa_num=pa->num;
 			cpa_fuv=pa->fuv;
 
-			psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,cpa_from,cpa_num,cpa_fuv,orco,0,0,0);
+			psys_particle_on_emitter(deform_only, psmd,cpa_from,cpa_num,-1,cpa_fuv,orco,0,0,0);
 		}
 
 		/* correct child ipo timing */
@@ -2617,10 +2617,14 @@
 					texco[1]-=1.0;
 				}
 				else
-					psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,psys->part->from,pa->num,pa->fuv,texco,0,0,0);
+					//psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,psys->part->from,pa->num,pa->fuv,texco,0,0,0);
+					/* <jahka> anyways I think it will be too small a difference to notice, so psys_get_texture should only know about the original mesh structure.. no dm needed anywhere */
+					psys_particle_on_emitter(1, psmd,psys->part->from,pa->num,-1,pa->fuv,texco,0,0,0);
 			}
 			else{
-				psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,psys->part->from,pa->num,pa->fuv,texco,0,0,0);
+				//psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,psys->part->from,pa->num,pa->fuv,texco,0,0,0);
+				/* ditto above */
+				psys_particle_on_emitter(1, psmd,psys->part->from,pa->num,-1,pa->fuv,texco,0,0,0);
 			}
 			externtex(mtex, texco, &value, rgba, rgba+1, rgba+2, rgba+3);
 
@@ -2893,7 +2897,7 @@
 			cpa_fuv = cpa->fuv;
 			cpa_from = PART_FROM_FACE;
 
-			psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,cpa_from,cpa_num,temp_fuv,orco,0,0,0);
+			psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,cpa_from,cpa_num,-1,temp_fuv,orco,0,0,0);
 
 			/* we need to save the actual root position of the child for positioning it accurately to the surface of the emitter */
 			VECCOPY(cpa_1st,orco);
@@ -2925,7 +2929,7 @@
 			cpa_num=pa->num;
 			cpa_fuv=pa->fuv;
 
-			psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,cpa_from,cpa_num,cpa_fuv,orco,0,0,0);
+			psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,cpa_from,cpa_num,-1,cpa_fuv,orco,0,0,0);
 		}
 
 		/* correct child ipo timing */

Modified: branches/particles/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/particle_system.c	2007-11-03 18:27:27 UTC (rev 12460)
+++ branches/particles/source/blender/blenkernel/intern/particle_system.c	2007-11-03 19:23:13 UTC (rev 12461)
@@ -189,23 +189,24 @@
 		}
 		
 		/* cache the faces! */
-		if (psys->totpart != totface) {
-			printf("Wow, somthings wrong\n");
-		} else {
-			for(p=0,pa=psys->particles; p<psys->totpart; p++,pa++) {
-				pa->num_dmcache = psys_particle_dm_face_lookup(dm, p, pa->fuv, node_array[p]);
-			}
+
+
+		for(p=0,pa=psys->particles; p<psys->totpart; p++,pa++) {
+			//i = pa->num;
+			//if (i<totface) // should never happen
+			pa->num_dmcache = psys_particle_dm_face_lookup(dm, p, pa->fuv, node_array[pa->num]);
 		}
+
 		//for (i=0; i < totface; i++) {
 		//	i = psys_particle_dm_face_lookup(dm, node_array[], fuv, (LinkNode*)NULL);
 		//}
+		MEM_freeN(node);
+		MEM_freeN(node_array);
 		
 	} else {
 		/* set the num_dmcache to an invalid value, just incase */
 		/* TODO */
 	}
-	if (node) MEM_freeN(node);
-	if (node_array) MEM_freeN(node_array);
 }
 
 static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys)
@@ -455,47 +456,7 @@
 		error("cant paint with the current modifier stack, disable distructive modifiers");
 		return;
 	}
-
-#if 0
-	if (!deform_only && from == PART_FROM_FACE) {
-		/* Will use later to speed up subsurf/derivedmesh */
 	
-		int tot_dm_face = dm__->getNumFaces(dm__);
-		int totface = me->totface;
-		int *origindex = DM_get_face_data_layer(dm__, CD_ORIGINDEX);
-		int i, oi;
-		LinkNode *node, **node_array;
-		
-		node= MEM_callocN(sizeof(LinkNode)*tot_dm_face, "faceindicies");
-		node_array = MEM_callocN(sizeof(LinkNode *)*totface, "faceindicies");
-		
-		for (i=0; i < tot_dm_face; i++, origindex++, node++) {
-			oi = *origindex;
-			node->link = (void *)i; // or use the index?
-			if (node_array[oi]) {
-				/* prepend */
-				node->next = node_array[oi];
-				node_array[oi] = node;
-			} else {
-				node_array[oi] = node;
-			}
-		}
-		
-		/* cache the faces! */
-		for (i=0; i < totface; i++) {
-			i = psys_particle_dm_face_lookup(dm, node_array[], fuv, (LinkNode*)NULL);
-		}
-		
-	} else {
-		/* set the num_dmcache to an invalid value, just incase */
-		/* TODO */
-	}
-#endif
-	
-	
-	
-	printf("distribute_particles_on_dm\n");
-	
 	BLI_srandom(31415926 + psys->seed);
 	
 	if(from==PART_FROM_CHILD){
@@ -1204,7 +1165,11 @@
 
 	for(p=0, pa=psys->particles; p<totpart; p++, pa++)
 		initialize_particle(pa,p,ob,psys,psmd);
-
+	
+	/* store the derived mesh face index for each particle */
+	if(psys->part->from==PART_FROM_FACE)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list