Bug fix: Verlet integration didn't work properly with moving particle emitters.

Thanks for mcreamsurfer for reporting and Farsthary for the patch!
This commit is contained in:
Janne Karhu 2009-12-02 20:53:28 +00:00
parent 63fc267929
commit 47b457f19e

@ -2267,12 +2267,13 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra
EffectedPoint epoint; EffectedPoint epoint;
ParticleKey states[5], tkey; ParticleKey states[5], tkey;
float timestep = psys_get_timestep(sim); float timestep = psys_get_timestep(sim);
float force[3],impulse[3],dx[4][3],dv[4][3]; float force[3],impulse[3],dx[4][3],dv[4][3],oldpos[3];
float dtime=dfra*timestep, time, pa_mass=part->mass, fac, fra=sim->psys->cfra; float dtime=dfra*timestep, time, pa_mass=part->mass, fac, fra=sim->psys->cfra;
int i, steps=1; int i, steps=1;
/* maintain angular velocity */ /* maintain angular velocity */
VECCOPY(pa->state.ave,pa->prev_state.ave); VECCOPY(pa->state.ave,pa->prev_state.ave);
VECCOPY(oldpos,pa->state.co);
if(part->flag & PART_SIZEMASS) if(part->flag & PART_SIZEMASS)
pa_mass*=pa->size; pa_mass*=pa->size;
@ -2399,7 +2400,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra
VECADDFAC(pa->state.vel,pa->state.vel,force,dtime); VECADDFAC(pa->state.vel,pa->state.vel,force,dtime);
VECADDFAC(pa->state.co,pa->state.co,pa->state.vel,dtime); VECADDFAC(pa->state.co,pa->state.co,pa->state.vel,dtime);
VECSUB(pa->state.vel,pa->state.co,pa->prev_state.co); VECSUB(pa->state.vel,pa->state.co,oldpos);
mul_v3_fl(pa->state.vel,1.0f/dtime); mul_v3_fl(pa->state.vel,1.0f/dtime);
break; break;
} }