diff options
author | Janne Karhu <jhkarh@gmail.com> | 2010-12-15 20:05:34 +0300 |
---|---|---|
committer | Janne Karhu <jhkarh@gmail.com> | 2010-12-15 20:05:34 +0300 |
commit | 6b2b56c35eaf1ea8d2b0d0edd2412288f0e67e19 (patch) | |
tree | 6149ab8b1d83bf4856c535eca1c823ae637b6791 /source/blender/blenkernel/intern/smoke.c | |
parent | 2c55dd96adee33962b2a618e7678ed61c07d1446 (diff) |
Fix for [#25218] No smoke is emitted when particle system starts and ends on same frame
* Depsgraph wasn't updated properly for smoke flow collision object dependencies.
* Smoke also wasn't properly using the actual emission frame of the flow particles.
* There was a lot of bloated logic in some parts of particle code so this fix turned into a small scale cleanup operation.
** As a result particle updating and cache usage should be a bit more stable too.
Diffstat (limited to 'source/blender/blenkernel/intern/smoke.c')
-rw-r--r-- | source/blender/blenkernel/intern/smoke.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 1833cc4eeac..08871cfeec7 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -973,9 +973,9 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) if(sfs && sfs->psys && sfs->psys->part && sfs->psys->part->type==PART_EMITTER) // is particle system selected { + ParticleSimulationData sim; ParticleSystem *psys = sfs->psys; ParticleSettings *part=psys->part; - ParticleData *pa = NULL; int p = 0; float *density = smoke_get_density(sds->fluid); float *bigdensity = smoke_turbulence_get_density(sds->wt); @@ -995,6 +995,10 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) */ float *temp_emission_map = NULL; + sim.scene = scene; + sim.ob = otherobj; + sim.psys = psys; + // initialize temp emission map if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW)) { @@ -1007,19 +1011,26 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) } // mostly copied from particle code - for(p=0, pa=psys->particles; p<psys->totpart; p++, pa++) - { - int cell[3]; - size_t i = 0; - size_t index = 0; - int badcell = 0; - if(pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN)==0) continue; - else if(pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0) continue; - else if(pa->flag & (PARS_UNEXIST+PARS_NO_DISP)) continue; + for(p=0; p<psys->totpart; p++) + { + int cell[3]; + size_t i = 0; + size_t index = 0; + int badcell = 0; + ParticleKey state; + + if(psys->particles[p].flag & (PARS_NO_DISP|PARS_UNEXIST)) + continue; + + state.time = smd->time; + + if(psys_get_particle_state(&sim, p, &state, 0) == 0) + continue; + // VECCOPY(pos, pa->state.co); // mul_m4_v3(ob->imat, pos); // 1. get corresponding cell - get_cell(smd->domain->p0, smd->domain->res, smd->domain->dx, pa->state.co, cell, 0); + get_cell(smd->domain->p0, smd->domain->res, smd->domain->dx, state.co, cell, 0); // check if cell is valid (in the domain boundary) for(i = 0; i < 3; i++) { @@ -1045,9 +1056,9 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) // Uses particle velocity as initial velocity for smoke if(sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY && (psys->part->phystype != PART_PHYS_NO)) { - velocity_x[index] = pa->state.vel[0]*sfs->vel_multi; - velocity_y[index] = pa->state.vel[1]*sfs->vel_multi; - velocity_z[index] = pa->state.vel[2]*sfs->vel_multi; + velocity_x[index] = state.vel[0]*sfs->vel_multi; + velocity_y[index] = state.vel[1]*sfs->vel_multi; + velocity_z[index] = state.vel[2]*sfs->vel_multi; } } else if(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) // outflow |