[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29245] branches/render25: Render Branch: temporarily revert commit 29079 from trunk with particle

Brecht Van Lommel brecht at blender.org
Sat Jun 5 18:04:13 CEST 2010


Revision: 29245
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29245
Author:   blendix
Date:     2010-06-05 18:04:13 +0200 (Sat, 05 Jun 2010)

Log Message:
-----------
Render Branch: temporarily revert commit 29079 from trunk with particle
path changes. This is causing two problems (reported in tracker):

* hair doesn't move when transforming e.g. an armature parent
  of the mesh emitting the hair.
* particle duplis on hair (for feathers) are not rendering.

Modified Paths:
--------------
    branches/render25/release/scripts/ui/properties_particle.py
    branches/render25/source/blender/blenkernel/BKE_particle.h
    branches/render25/source/blender/blenkernel/intern/particle.c
    branches/render25/source/blender/blenkernel/intern/particle_system.c
    branches/render25/source/blender/editors/physics/particle_edit.c
    branches/render25/source/blender/editors/space_view3d/drawobject.c
    branches/render25/source/blender/render/intern/source/object_particle.c

Modified: branches/render25/release/scripts/ui/properties_particle.py
===================================================================
--- branches/render25/release/scripts/ui/properties_particle.py	2010-06-05 16:03:01 UTC (rev 29244)
+++ branches/render25/release/scripts/ui/properties_particle.py	2010-06-05 16:04:13 UTC (rev 29245)
@@ -725,6 +725,12 @@
             sub = split.column()
             sub.prop(part, "velocity_length")
         elif part.ren_as == 'PATH':
+
+            if part.type != 'HAIR' and part.physics_type != 'KEYED' and (psys.point_cache.baked is False):
+                box = layout.box()
+                box.label(text="Baked or keyed particles needed for correct rendering.")
+                return
+
             sub.prop(part, "render_strand")
             subsub = sub.column()
             subsub.active = (part.render_strand is False)
@@ -899,6 +905,11 @@
 
         path = (part.ren_as == 'PATH' and part.draw_as == 'RENDER') or part.draw_as == 'PATH'
 
+        if path and part.type != 'HAIR' and part.physics_type != 'KEYED' and psys.point_cache.baked is False:
+            box = layout.box()
+            box.label(text="Baked or keyed particles needed for correct drawing.")
+            return
+
         row = layout.row()
         row.prop(part, "display", slider=True)
         if part.draw_as != 'RENDER' or part.ren_as == 'HALO':

Modified: branches/render25/source/blender/blenkernel/BKE_particle.h
===================================================================
--- branches/render25/source/blender/blenkernel/BKE_particle.h	2010-06-05 16:03:01 UTC (rev 29244)
+++ branches/render25/source/blender/blenkernel/BKE_particle.h	2010-06-05 16:04:13 UTC (rev 29245)
@@ -256,11 +256,9 @@
 void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3], float zvec[3], float center[3]);
 
 /* particle_system.c */
-void psys_update_path_cache(struct ParticleSimulationData *sim, float cfra);
 struct ParticleSystem *psys_get_target_system(struct Object *ob, struct ParticleTarget *pt);
 void psys_count_keyed_targets(struct ParticleSimulationData *sim);
 void psys_update_particle_tree(struct ParticleSystem *psys, float cfra);
-void psys_update_children(struct ParticleSimulationData *sim);
 
 void psys_make_temp_pointcache(struct Object *ob, struct ParticleSystem *psys);
 void psys_get_pointcache_start_end(struct Scene *scene, ParticleSystem *psys, int *sfra, int *efra);

Modified: branches/render25/source/blender/blenkernel/intern/particle.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/particle.c	2010-06-05 16:03:01 UTC (rev 29244)
+++ branches/render25/source/blender/blenkernel/intern/particle.c	2010-06-05 16:04:13 UTC (rev 29245)
@@ -433,7 +433,7 @@
 		}
 	}
 }
-void psys_free_child_path_cache(ParticleSystem *psys)
+static void free_child_path_cache(ParticleSystem *psys)
 {
 	psys_free_path_cache_buffers(psys->childcache, &psys->childcachebufs);
 	psys->childcache = NULL;
@@ -451,7 +451,7 @@
 		psys->pathcache= NULL;
 		psys->totcached= 0;
 
-		psys_free_child_path_cache(psys);
+		free_child_path_cache(psys);
 	}
 }
 void psys_free_children(ParticleSystem *psys)
@@ -462,7 +462,7 @@
 		psys->totchild=0;
 	}
 
-	psys_free_child_path_cache(psys);
+	free_child_path_cache(psys);
 }
 void psys_free_particles(ParticleSystem *psys)
 {
@@ -1037,7 +1037,6 @@
 	ParticleKey *kkey[2];
 
 	PointCache *cache;
-	PTCacheMem *pm;
 
 	PTCacheEditPoint *epoint;
 	PTCacheEditKey *ekey[2];
@@ -1046,74 +1045,31 @@
 	int bspline;
 } ParticleInterpolationData;
 /* Assumes pointcache->mem_cache exists, so for disk cached particles call psys_make_temp_pointcache() before use */
-/* It uses ParticleInterpolationData->pm to store the current memory cache frame so it's thread safe. */
-static void get_pointcache_keys_for_time(Object *ob, PointCache *cache, PTCacheMem **cur, int index, float t, ParticleKey *key1, ParticleKey *key2)
+static void get_pointcache_keys_for_time(Object *ob, PointCache *cache, int index, float t, ParticleKey *key1, ParticleKey *key2)
 {
-	static PTCacheMem *pm = NULL;
+	static PTCacheMem *pm = NULL; /* not thread safe */
 
 	if(index < 0) { /* initialize */
-		*cur = cache->mem_cache.first;
+		pm = cache->mem_cache.first;
 
-		if(*cur)
-			*cur = (*cur)->next;
+		if(pm)
+			pm = pm->next;
 	}
 	else {
-		if(*cur) {
-			while(*cur && (*cur)->next && (float)(*cur)->frame < t)
-				*cur = (*cur)->next;
+		if(pm) {
+			while(pm && pm->next && (float)pm->frame < t)
+				pm = pm->next;
 
-			pm = *cur;
-
 			BKE_ptcache_make_particle_key(key2, pm->index_array ? pm->index_array[index] - 1 : index, pm->data, (float)pm->frame, 1);
-			if(pm->prev->index_array && pm->prev->index_array[index] == 0)
-				copy_particle_key(key1, key2, 1);
-			else
-				BKE_ptcache_make_particle_key(key1, pm->prev->index_array ? pm->prev->index_array[index] - 1 : index, pm->prev->data, (float)pm->prev->frame, 1);
+			BKE_ptcache_make_particle_key(key1, pm->prev->index_array ? pm->prev->index_array[index] - 1 : index, pm->prev->data, (float)pm->prev->frame, 1);
 		}
 		else if(cache->mem_cache.first) {
-			pm = cache->mem_cache.first;
-			BKE_ptcache_make_particle_key(key2, pm->index_array ? pm->index_array[index] - 1 : index, pm->data, (float)pm->frame, 1);
+			PTCacheMem *pm2 = cache->mem_cache.first;
+			BKE_ptcache_make_particle_key(key2, pm2->index_array ? pm2->index_array[index] - 1 : index, pm2->data, (float)pm2->frame, 1);
 			copy_particle_key(key1, key2, 1);
 		}
 	}
 }
-static int get_pointcache_times_for_particle(PointCache *cache, int index, float *start, float *end)
-{
-	PTCacheMem *pm;
-	int ret = 0;
-
-	for(pm=cache->mem_cache.first; pm; pm=pm->next) {
-		if(pm->index_array) {
-			if(pm->index_array[index]) {
-				*start = pm->frame;
-				ret++;
-				break;
-			}
-		}
-		else {
-			*start = pm->frame;
-			ret++;
-			break;
-		}
-	}
-
-	for(pm=cache->mem_cache.last; pm; pm=pm->prev) {
-		if(pm->index_array) {
-			if(pm->index_array[index]) {
-				*end = pm->frame;
-				ret++;
-				break;
-			}
-		}
-		else {
-			*end = pm->frame;
-			ret++;
-			break;
-		}
-	}
-
-	return ret == 2;
-}
 static void init_particle_interpolation(Object *ob, ParticleSystem *psys, ParticleData *pa, ParticleInterpolationData *pind)
 {
 
@@ -1135,15 +1091,10 @@
 		pind->dietime = (key + pa->totkey - 1)->time;
 	}
 	else if(pind->cache) {
-		float start, end;
-		get_pointcache_keys_for_time(ob, pind->cache, &pind->pm, -1, 0.0f, NULL, NULL);
+		get_pointcache_keys_for_time(ob, pind->cache, -1, 0.0f, NULL, NULL);
+
 		pind->birthtime = pa ? pa->time : pind->cache->startframe;
 		pind->dietime = pa ? pa->dietime : pind->cache->endframe;
-
-		if(get_pointcache_times_for_particle(pind->cache, pa - psys->particles, &start, &end)) {
-			pind->birthtime = MAX2(pind->birthtime, start);
-			pind->dietime = MIN2(pind->dietime, end);
-		}
 	}
 	else {
 		HairKey *key = pa->hair;
@@ -1273,7 +1224,7 @@
 		memcpy(keys + 2, pind->kkey[1], sizeof(ParticleKey));
 	}
 	else if(pind->cache) {
-		get_pointcache_keys_for_time(NULL, pind->cache, &pind->pm, p, real_t, keys+1, keys+2);
+		get_pointcache_keys_for_time(NULL, pind->cache, p, real_t, keys+1, keys+2);
 	}
 	else {
 		hair_to_particle(keys + 1, pind->hkey[0]);
@@ -2721,7 +2672,7 @@
 	}
 	else {
 		/* clear out old and create new empty path cache */
-		psys_free_child_path_cache(sim->psys);
+		free_child_path_cache(sim->psys);
 		sim->psys->childcache= psys_alloc_path_cache_buffers(&sim->psys->childcachebufs, totchild, ctx->steps+1);
 		sim->psys->totchildcache = totchild;
 	}
@@ -2792,7 +2743,7 @@
 	int keyed, baked;
 
 	/* we don't have anything valid to create paths from so let's quit here */
-	if((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || psys->pointcache)==0)
+	if((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || psys->pointcache->flag & PTCACHE_BAKED)==0)
 		return;
 
 	if(psys_in_edit_mode(sim->scene, psys))
@@ -2802,7 +2753,7 @@
 	BLI_srandom(psys->seed);
 
 	keyed = psys->flag & PSYS_KEYED;
-	baked = !hair_dm && psys->pointcache->mem_cache.first;
+	baked = !hair_dm && psys->pointcache->flag & PTCACHE_BAKED;
 
 	/* clear out old and create new empty path cache */
 	psys_free_path_cache(psys, psys->edit);
@@ -3199,7 +3150,7 @@
 
 	edit->totcached = totpart;
 
-	if(psys) {
+	if(psys && psys->part->type == PART_HAIR) {
 		ParticleSimulationData sim = {scene, ob, psys, psys_get_modifier(ob, psys), NULL};
 		psys_cache_child_paths(&sim, cfra, 1);
 	}

Modified: branches/render25/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/particle_system.c	2010-06-05 16:03:01 UTC (rev 29244)
+++ branches/render25/source/blender/blenkernel/intern/particle_system.c	2010-06-05 16:04:13 UTC (rev 29245)
@@ -3075,18 +3075,66 @@
 /*			Hair								*/
 /************************************************/
 /* check if path cache or children need updating and do it if needed */
-void psys_update_path_cache(ParticleSimulationData *sim, float cfra)
+static void psys_update_path_cache(ParticleSimulationData *sim, float cfra)
 {
 	ParticleSystem *psys = sim->psys;
 	ParticleSettings *part = psys->part;
-	
-	/* only hair, keyed and baked stuff can have paths */
-	if(part->type==PART_HAIR || psys->flag&PSYS_KEYED || psys->pointcache->mem_cache.first) {
+	ParticleEditSettings *pset = &sim->scene->toolsettings->particle;
+	int distr=0, alloc=0, skip=0;
+
+	if((psys->part->childtype && psys->totchild != get_psys_tot_child(sim->scene, psys)) || psys->recalc&PSYS_RECALC_RESET)
+		alloc=1;
+
+	if(alloc || psys->recalc&PSYS_RECALC_CHILD || (psys->vgroup[PSYS_VG_DENSITY] && (sim->ob && sim->ob->mode & OB_MODE_WEIGHT_PAINT)))
+		distr=1;
+
+	if(distr){
+		if(alloc)
+			realloc_particles(sim, sim->psys->totpart);
+
+		if(get_psys_tot_child(sim->scene, psys)) {
+			/* don't generate children while computing the hair keys */
+			if(!(psys->part->type == PART_HAIR) || (psys->flag & PSYS_HAIR_DONE)) {
+				distribute_particles(sim, PART_FROM_CHILD);
+
+				if(part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES && part->parents!=0.0)
+					psys_find_parents(sim);
+			}
+		}
+		else
+			psys_free_children(psys);
+	}
+
+	if((part->type==PART_HAIR || psys->flag&PSYS_KEYED || psys->pointcache->flag & PTCACHE_BAKED)==0)
+		skip = 1; /* only hair, keyed and baked stuff can have paths */

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list