diff options
-rw-r--r-- | source/blender/blenkernel/BKE_particle.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 22 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 2 |
3 files changed, 18 insertions, 8 deletions
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 59274347e1f..b6be72fadd3 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -376,7 +376,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 ParticleSimulationData *sim, struct ParticleData *pa, int p); +void initialize_particle(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 78db7e67b23..6ae3e2e9d5e 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1540,23 +1540,26 @@ void psys_threads_free(ParticleThread *threads) MEM_freeN(threads); } -/* set particle parameters that don't change during particle's life */ -void initialize_particle(ParticleSimulationData *sim, ParticleData *pa, int p) +static void initialize_particle_texture(ParticleSimulationData *sim, ParticleData *pa, int p) { ParticleSystem *psys = sim->psys; ParticleSettings *part = psys->part; ParticleTexture ptex; - pa->flag &= ~PARS_UNEXIST; - if (part->type != PART_FLUID) { psys_get_texture(sim, pa, &ptex, PAMAP_INIT, 0.f); - + if (ptex.exist < PSYS_FRAND(p+125)) pa->flag |= PARS_UNEXIST; pa->time = (part->type == PART_HAIR) ? 0.f : part->sta + (part->end - part->sta)*ptex.time; } +} + +/* set particle parameters that don't change during particle's life */ +void initialize_particle(ParticleData *pa) +{ + pa->flag &= ~PARS_UNEXIST; pa->hair_index = 0; /* we can't reset to -1 anymore since we've figured out correct index in distribute_particles */ @@ -1572,7 +1575,7 @@ static void initialize_all_particles(ParticleSimulationData *sim) LOOP_PARTICLES { if ((pa->flag & PARS_UNEXIST)==0) - initialize_particle(sim, pa, p); + initialize_particle(pa); if (pa->flag & PARS_UNEXIST) psys->totunexist++; @@ -1984,6 +1987,13 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, psys_get_birth_coordinates(sim, pa, &pa->state, dtime, cfra); + /* Initialize particle settings which depends on texture. + * + * We could only do it now because we'll need to know coordinate + * before sampling the texture. + */ + initialize_particle_texture(sim, pa, p); + if (part->phystype==PART_PHYS_BOIDS && pa->boid) { BoidParticle *bpa = pa->boid; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 5288589b6f4..253a420b88a 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -3458,7 +3458,7 @@ static int brush_add(PEData *data, short number) } pa->size= 1.0f; - initialize_particle(&sim, pa, i); + initialize_particle(pa); reset_particle(&sim, pa, 0.0, 1.0); point->flag |= PEP_EDIT_RECALC; if (pe_x_mirror(ob)) |