diff options
author | Janne Karhu <jhkarh@gmail.com> | 2008-09-18 21:19:40 +0400 |
---|---|---|
committer | Janne Karhu <jhkarh@gmail.com> | 2008-09-18 21:19:40 +0400 |
commit | f7113fd267864a081b7e4640dd14f4fca835a5a4 (patch) | |
tree | 4ce50d386a0e960b1b4073b37cce5afa0909aa6a | |
parent | 6b7b81220808203c9a778df3b4585a77a8096f10 (diff) |
Reactor particles were born with incorrect timing. Some changes made could effect normal particles too, but after many tests I didn't notice any adverse effects. Be sure to poke me hard if there are some though :)
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index a0c4bd91da4..07b709efcbe 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2110,22 +2110,18 @@ static void react_to_events(ParticleSystem *psys, int pa_num) for(re=psys->reactevents.first; re; re=re->next){ birth=0; if(part->from==PART_FROM_PARTICLE){ - if(pa->num==re->pa_num){ + if(pa->num==re->pa_num && pa->alive==PARS_UNBORN){ if(re->event==PART_EVENT_NEAR){ ParticleData *tpa = re->psys->particles+re->pa_num; float pa_time=tpa->time + pa->foffset*tpa->lifetime; - if(re->time > pa_time){ - pa->alive=PARS_ALIVE; + if(re->time >= pa_time){ pa->time=pa_time; pa->dietime=pa->time+pa->lifetime; } } else{ - if(pa->alive==PARS_UNBORN){ - pa->alive=PARS_ALIVE; - pa->time=re->time; - pa->dietime=pa->time+pa->lifetime; - } + pa->time=re->time; + pa->dietime=pa->time+pa->lifetime; } } } @@ -2133,7 +2129,6 @@ static void react_to_events(ParticleSystem *psys, int pa_num) dist=VecLenf(pa->state.co, re->state.co); if(dist <= re->size){ if(pa->alive==PARS_UNBORN){ - pa->alive=PARS_ALIVE; pa->time=re->time; pa->dietime=pa->time+pa->lifetime; birth=1; @@ -3127,6 +3122,10 @@ static void deflect_particle(Object *pob, ParticleSystemModifierData *psmd, Part if(through == 0 && (part->flag & PART_DIE_ON_COL || pd->flag & PDEFLE_KILL_PART)) { pa->alive = PARS_DYING; pa->dietime = pa->state.time + (cfra - pa->state.time) * dt; + + /* we have to add this for dying particles too so that reactors work correctly */ + VECADDFAC(co, co, col.nor, (through ? -0.0001f : 0.0001f)); + VECCOPY(state->co, co); VecLerpf(state->vel, pa->state.vel, state->vel, dt); QuatInterpol(state->rot, pa->state.rot, state->rot, dt); @@ -4061,9 +4060,11 @@ static void dynamics_step(Object *ob, ParticleSystem *psys, ParticleSystemModifi pa_dfra = dfra; pa_dtime = dtime; + /* we need to calculate this once again because reactions might have changed pa->time */ + birthtime = pa->time + pa->loop * pa->lifetime; dietime = birthtime + pa->lifetime; - if(birthtime < cfra && birthtime >= psys->cfra){ + if(birthtime <= cfra && birthtime >= psys->cfra){ /* particle is born some time between this and last step*/ pa->alive = PARS_ALIVE; pa_dfra = cfra - birthtime; @@ -4103,8 +4104,6 @@ static void dynamics_step(Object *ob, ParticleSystem *psys, ParticleSystemModifi } } - push_reaction(ob,psys,p,PART_EVENT_NEAR,key); - if(pa->alive == PARS_DYING){ push_reaction(ob,psys,p,PART_EVENT_DEATH,key); @@ -4124,6 +4123,8 @@ static void dynamics_step(Object *ob, ParticleSystem *psys, ParticleSystemModifi } else key->time=cfra; + + push_reaction(ob,psys,p,PART_EVENT_NEAR,key); } } } |