Bug fix: particles emitted from a moving emitter exploded with verlet integration
authorJanne Karhu <jhkarh@gmail.com>
Mon, 28 Mar 2011 08:08:59 +0000 (08:08 +0000)
committerJanne Karhu <jhkarh@gmail.com>
Mon, 28 Mar 2011 08:08:59 +0000 (08:08 +0000)
* Verlet integration didn't like moving emitters, so now the first step for newborn particles with verlet is actually done with euler integration.

source/blender/blenkernel/intern/particle_system.c

index 088ab78ce47ef088f95c95e268c80681d238a6b2..19d4ed598ee7e6ccbe805bd472e949e98ae8a7fa 100644 (file)
@@ -2063,10 +2063,15 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d
        float force[3],acceleration[3],impulse[3],dx[4][3],dv[4][3],oldpos[3];
        float pa_mass= (part->flag & PART_SIZEMASS ? part->mass * pa->size : part->mass);
        int i, steps=1;
-       
+       int integrator = part->integrator;
+
        copy_v3_v3(oldpos, pa->state.co);
+       
+       /* Verlet integration behaves strangely with moving emitters, so do first step with euler. */
+       if(pa->prev_state.time < 0.f && integrator == PART_INT_VERLET)
+               integrator = PART_INT_EULER;
 
-       switch(part->integrator){
+       switch(integrator){
                case PART_INT_EULER:
                        steps=1;
                        break;
@@ -2100,7 +2105,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d
                /* calculate next state */
                add_v3_v3(states[i].vel, impulse);
 
-               switch(part->integrator){
+               switch(integrator){
                        case PART_INT_EULER:
                                madd_v3_v3v3fl(pa->state.co, states->co, states->vel, dtime);
                                madd_v3_v3v3fl(pa->state.vel, states->vel, acceleration, dtime);