Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-08-08 19:36:03 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-08-08 19:36:03 +0400
commitaf807bd24d8be85988a8239bbfa26daeea5633e9 (patch)
treeaa60a8793d452d154cebe30a1f60d0733bc9d7cc
parenta6c4c6dbc6bf1257088192469f0a33b01308f91b (diff)
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.
-rw-r--r--source/blender/render/intern/source/pointdensity.c75
1 files changed, 47 insertions, 28 deletions
diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c
index b5ef96f9229..d4d6bfa5b7f 100644
--- a/source/blender/render/intern/source/pointdensity.c
+++ b/source/blender/render/intern/source/pointdensity.c
@@ -107,6 +107,7 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa
{
DerivedMesh* dm;
ParticleKey state;
+ ParticleCacheKey *cache;
ParticleSimulationData sim= {NULL};
ParticleData *pa=NULL;
float cfra = BKE_scene_frame_get(re->scene);
@@ -153,44 +154,62 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa
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);