[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59021] trunk/blender/source/blender/ render/intern/source/pointdensity.c: Fix #36394: rendering a point density texture with a hair particle system did

Brecht Van Lommel brechtvanlommel at pandora.be
Thu Aug 8 17:36:03 CEST 2013


Revision: 59021
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59021
Author:   blendix
Date:     2013-08-08 15:36:03 +0000 (Thu, 08 Aug 2013)
Log Message:
-----------
Fix #36394: rendering a point density texture with a hair particle system did
not work correct, the positions would change over time and child particles did
not render.

Modified Paths:
--------------
    trunk/blender/source/blender/render/intern/source/pointdensity.c

Modified: trunk/blender/source/blender/render/intern/source/pointdensity.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/pointdensity.c	2013-08-08 09:47:47 UTC (rev 59020)
+++ trunk/blender/source/blender/render/intern/source/pointdensity.c	2013-08-08 15:36:03 UTC (rev 59021)
@@ -107,6 +107,7 @@
 {
 	DerivedMesh* dm;
 	ParticleKey state;
+	ParticleCacheKey *cache;
 	ParticleSimulationData sim= {NULL};
 	ParticleData *pa=NULL;
 	float cfra = BKE_scene_frame_get(re->scene);
@@ -153,44 +154,62 @@
 
 	for (i=0, pa=psys->particles; i < total_particles; i++, pa++) {
 
-		state.time = cfra;
-		if (psys_get_particle_state(&sim, i, &state, 0)) {
-			
-			copy_v3_v3(partco, state.co);
-			
-			if (pd->psys_cache_space == TEX_PD_OBJECTSPACE)
-				mul_m4_v3(ob->imat, partco);
-			else if (pd->psys_cache_space == TEX_PD_OBJECTLOC) {
-				sub_v3_v3(partco, ob->loc);
-			}
-			else {
-				/* TEX_PD_WORLDSPACE */
-			}
-			
-			BLI_bvhtree_insert(pd->point_tree, i, partco, 1);
-			
-			if (data_used & POINT_DATA_VEL) {
-				pd->point_data[i*3 + 0] = state.vel[0];
-				pd->point_data[i*3 + 1] = state.vel[1];
-				pd->point_data[i*3 + 2] = state.vel[2];
-			}
+		if (psys->part->type == PART_HAIR) {
+			/* hair particles */
+			if (i < psys->totpart && psys->pathcache)
+				cache = psys->pathcache[i];
+			else if (i >= psys->totpart && psys->childcache)
+				cache = psys->childcache[i - psys->totpart];
+			else
+				continue;
+
+			cache += cache->steps; /* use endpoint */
+
+			copy_v3_v3(state.co, cache->co);
+			zero_v3(state.vel);
+			state.time = 0.0f;
+		}
+		else {
+			/* emitter particles */
+			state.time = cfra;
+
+			if (!psys_get_particle_state(&sim, i, &state, 0))
+				continue;
+
 			if (data_used & POINT_DATA_LIFE) {
-				float pa_time;
-				
 				if (i < psys->totpart) {
-					pa_time = (cfra - pa->time)/pa->lifetime;
+					state.time = (cfra - pa->time)/pa->lifetime;
 				}
 				else {
 					ChildParticle *cpa= (psys->child + i) - psys->totpart;
 					float pa_birthtime, pa_dietime;
 					
-					pa_time = psys_get_child_time(psys, cpa, cfra, &pa_birthtime, &pa_dietime);
+					state.time = psys_get_child_time(psys, cpa, cfra, &pa_birthtime, &pa_dietime);
 				}
-				
-				pd->point_data[offset + i] = pa_time;
-				
 			}
 		}
+
+		copy_v3_v3(partco, state.co);
+		
+		if (pd->psys_cache_space == TEX_PD_OBJECTSPACE)
+			mul_m4_v3(ob->imat, partco);
+		else if (pd->psys_cache_space == TEX_PD_OBJECTLOC) {
+			sub_v3_v3(partco, ob->loc);
+		}
+		else {
+			/* TEX_PD_WORLDSPACE */
+		}
+		
+		BLI_bvhtree_insert(pd->point_tree, i, partco, 1);
+		
+		if (data_used & POINT_DATA_VEL) {
+			pd->point_data[i*3 + 0] = state.vel[0];
+			pd->point_data[i*3 + 1] = state.vel[1];
+			pd->point_data[i*3 + 2] = state.vel[2];
+		}
+		if (data_used & POINT_DATA_LIFE) {
+			pd->point_data[offset + i] = state.time;
+		}
 	}
 	
 	BLI_bvhtree_balance(pd->point_tree);




More information about the Bf-blender-cvs mailing list