diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-05-04 18:34:32 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-05-04 18:34:32 +0300 |
commit | dc7d07753f537a89068dd770a7b264f8cbbb6d47 (patch) | |
tree | 5580a1dde4a2a878543442b9039840fe2b0d8c1e /source/blender/blenkernel/intern/particle_system.c | |
parent | 920aa5e7d2da91805acb8e2c2963fd908f873eeb (diff) | |
parent | 1227e5c3d1ee20e9af57984a261b1d51d48c0263 (diff) |
Merge branch 'master' into gooseberry
Conflicts:
source/blender/editors/space_sequencer/sequencer_draw.c
Diffstat (limited to 'source/blender/blenkernel/intern/particle_system.c')
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index acff7515f98..78eefe66046 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -298,7 +298,7 @@ int psys_get_child_number(Scene *scene, ParticleSystem *psys) else nbr= psys->part->child_nbr; - return get_render_child_particle_number(&scene->r, nbr); + return get_render_child_particle_number(&scene->r, nbr, psys->renderdata != NULL); } int psys_get_tot_child(Scene *scene, ParticleSystem *psys) @@ -560,17 +560,24 @@ static void initialize_all_particles(ParticleSimulationData *sim) ParticleSystem *psys = sim->psys; PARTICLE_P; + LOOP_PARTICLES { + initialize_particle(sim, pa); + } +} + +static void free_unexisting_particles(ParticleSimulationData *sim) +{ + ParticleSystem *psys = sim->psys; + PARTICLE_P; + psys->totunexist = 0; LOOP_PARTICLES { - if ((pa->flag & PARS_UNEXIST)==0) - initialize_particle(sim, pa); - - if (pa->flag & PARS_UNEXIST) + if (pa->flag & PARS_UNEXIST) { psys->totunexist++; + } } - /* Free unexisting particles. */ if (psys->totpart && psys->totunexist == psys->totpart) { if (psys->particles->boid) MEM_freeN(psys->particles->boid); @@ -4087,6 +4094,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) initialize_all_particles(sim); /* reset only just created particles (on startframe all particles are recreated) */ reset_all_particles(sim, 0.0, cfra, oldtotpart); + free_unexisting_particles(sim); if (psys->fluid_springs) { MEM_freeN(psys->fluid_springs); @@ -4433,6 +4441,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) { PARTICLE_P; float disp = psys_get_current_display_percentage(psys); + bool free_unexisting = false; /* Particles without dynamics haven't been reset yet because they don't use pointcache */ if (psys->recalc & PSYS_RECALC_RESET) @@ -4442,6 +4451,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) free_keyed_keys(psys); distribute_particles(&sim, part->from); initialize_all_particles(&sim); + free_unexisting = true; /* flag for possible explode modifiers after this system */ sim.psmd->flag |= eParticleSystemFlag_Pars; @@ -4460,6 +4470,10 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) pa->flag &= ~PARS_NO_DISP; } + /* free unexisting after reseting particles */ + if (free_unexisting) + free_unexisting_particles(&sim); + if (part->phystype == PART_PHYS_KEYED) { psys_count_keyed_targets(&sim); set_keyed_keys(&sim); |