Commit: 259a4361973c7e1b912b9fcded3ed02bf9ab0b96
Author: Lukas Tönne
Date:   Wed Jul 2 12:17:43 2014 +0200
https://developer.blender.org/rB259a4361973c7e1b912b9fcded3ed02bf9ab0b96

Fix T40815: Particle birth times not initialized correctly.

In rB78c491e the `initialize_particle` function was split into 2 parts for 
particle texture initialization.
The texture init part however also initializes birth times, which is now 
missing in the main init function
in some cases (notably when setting start/end directly without a subsequent 
time step).

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

M       source/blender/blenkernel/BKE_particle.h
M       source/blender/blenkernel/intern/particle_system.c
M       source/blender/editors/physics/particle_edit.c

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

diff --git a/source/blender/blenkernel/BKE_particle.h 
b/source/blender/blenkernel/BKE_particle.h
index 6b8e504..f84a637 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -403,7 +403,7 @@ void psys_particle_on_dm(struct DerivedMesh *dm, int from, 
int index, int index_
                          float orco[3], float ornor[3]);
 
 /* particle_system.c */
-void initialize_particle(struct ParticleData *pa);
+void initialize_particle(struct ParticleSimulationData *sim, struct 
ParticleData *pa);
 void psys_calc_dmcache(struct Object *ob, struct DerivedMesh *dm, struct 
ParticleSystem *psys);
 int psys_particle_dm_face_lookup(struct Object *ob, struct DerivedMesh *dm, 
int index, const float fw[4], struct LinkNode *node);
 
diff --git a/source/blender/blenkernel/intern/particle_system.c 
b/source/blender/blenkernel/intern/particle_system.c
index 221bc26..06ac9db 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -1546,20 +1546,32 @@ static void 
initialize_particle_texture(ParticleSimulationData *sim, ParticleDat
        ParticleSettings *part = psys->part;
        ParticleTexture ptex;
 
-       if (part->type != PART_FLUID) {
-               psys_get_texture(sim, pa, &ptex, PAMAP_INIT, 0.f);
-
+       psys_get_texture(sim, pa, &ptex, PAMAP_INIT, 0.f);
+       
+       switch (part->type) {
+       case PART_EMITTER:
                if (ptex.exist < psys_frand(psys, p+125))
                        pa->flag |= PARS_UNEXIST;
-
-               pa->time = (part->type == PART_HAIR) ? 0.f : part->sta + 
(part->end - part->sta)*ptex.time;
+               pa->time = part->sta + (part->end - part->sta)*ptex.time;
+               break;
+       case PART_HAIR:
+               if (ptex.exist < psys_frand(psys, p+125))
+                       pa->flag |= PARS_UNEXIST;
+               pa->time = 0.f;
+               break;
+       case PART_FLUID:
+               break;
        }
 }
 
 /* set particle parameters that don't change during particle's life */
-void initialize_particle(ParticleData *pa)
+void initialize_particle(ParticleSimulationData *sim, ParticleData *pa)
 {
+       ParticleSettings *part = sim->psys->part;
+       float birth_time = (float)(pa - sim->psys->particles) / 
(float)sim->psys->totpart;
+       
        pa->flag &= ~PARS_UNEXIST;
+       pa->time = part->sta + (part->end - part->sta) * birth_time;
 
        pa->hair_index = 0;
        /* we can't reset to -1 anymore since we've figured out correct index 
in distribute_particles */
@@ -1575,7 +1587,7 @@ static void 
initialize_all_particles(ParticleSimulationData *sim)
 
        LOOP_PARTICLES {
                if ((pa->flag & PARS_UNEXIST)==0)
-                       initialize_particle(pa);
+                       initialize_particle(sim, pa);
 
                if (pa->flag & PARS_UNEXIST)
                        psys->totunexist++;
diff --git a/source/blender/editors/physics/particle_edit.c 
b/source/blender/editors/physics/particle_edit.c
index 5432f05..5401cef 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -3487,7 +3487,7 @@ static int brush_add(PEData *data, short number)
                        }
                        
                        pa->size= 1.0f;
-                       initialize_particle(pa);
+                       initialize_particle(&sim, pa);
                        reset_particle(&sim, pa, 0.0, 1.0);
                        point->flag |= PEP_EDIT_RECALC;
                        if (pe_x_mirror(ob))

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to