[Bf-blender-cvs] [dced56f] master: Fix T44185, Fix T44090: hair texture density working unreliable.

Krzysztof Recko noreply at git.blender.org
Sun May 3 16:22:36 CEST 2015


Commit: dced56f02a42481de167dd45542adf6dae2d039d
Author: Krzysztof Recko
Date:   Sun May 3 16:01:07 2015 +0200
Branches: master
https://developer.blender.org/rBdced56f02a42481de167dd45542adf6dae2d039d

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 78c491e62a5.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D1213

===================================================================

M	source/blender/blenkernel/intern/particle_system.c

===================================================================

diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 5a263e2..2576c45 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -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);




More information about the Bf-blender-cvs mailing list