Fix T44185, Fix T44090: hair texture density working unreliable.
"Unexisting" particles must be freed after the unexist flag has been set,
which was no longer the case after 78c491e62a
.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D1213
This commit is contained in:
@@ -559,17 +559,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);
|
||||
@@ -3790,6 +3797,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);
|
||||
@@ -4136,6 +4144,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)
|
||||
@@ -4145,6 +4154,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;
|
||||
@@ -4163,6 +4173,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);
|
||||
|
Reference in New Issue
Block a user