Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorLukas Tönne <lukas.toenne@gmail.com>2014-07-02 14:17:43 +0400
committerLukas Tönne <lukas.toenne@gmail.com>2014-07-02 14:20:51 +0400
commit259a4361973c7e1b912b9fcded3ed02bf9ab0b96 (patch)
tree7cb2dba4ef4dedafd0022e5fd0b47d57957b10a0 /source
parent7587e82c288e46ef257e1de12cb0952ad234abff (diff)
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).
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_particle.h2
-rw-r--r--source/blender/blenkernel/intern/particle_system.c26
-rw-r--r--source/blender/editors/physics/particle_edit.c2
3 files changed, 21 insertions, 9 deletions
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 6b8e50494c7..f84a6378fb3 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 221bc2689bb..06ac9db0b16 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 5432f059405..5401cef8351 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))