forked from bartvdbraak/blender
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).
This commit is contained in:
parent
7587e82c28
commit
259a436197
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
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++;
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user