Particle charge effector wasn't working properly.
authorJanne Karhu <jhkarh@gmail.com>
Thu, 24 Mar 2011 12:12:54 +0000 (12:12 +0000)
committerJanne Karhu <jhkarh@gmail.com>
Thu, 24 Mar 2011 12:12:54 +0000 (12:12 +0000)
* Probably just forgot this code somewhere a long time ago.

source/blender/blenkernel/intern/effect.c

index f07dd0bc5f429337ad41bc9f2e3c27aff79f0e8d..216dffc1e4aacaf94c76965635d19083f4249f6d 100644 (file)
@@ -361,12 +361,18 @@ void pdEndEffectors(ListBase **effectors)
 
 void pd_point_from_particle(ParticleSimulationData *sim, ParticleData *pa, ParticleKey *state, EffectedPoint *point)
 {
+       ParticleSettings *part = sim->psys->part;
        point->loc = state->co;
        point->vel = state->vel;
        point->index = pa - sim->psys->particles;
        point->size = pa->size;
-       /* TODO: point->charge */
-       point->charge = 1.0f;
+       point->charge = 0.0f;
+       
+       if(part->pd && part->pd->forcefield == PFIELD_CHARGE)
+               point->charge += part->pd->f_strength;
+
+       if(part->pd2 && part->pd2->forcefield == PFIELD_CHARGE)
+               point->charge += part->pd2->f_strength;
 
        point->vel_to_sec = 1.0f;
        point->vel_to_frame = psys_get_timestep(sim);