diff options
Diffstat (limited to 'source/blender/blenkernel/intern/effect.c')
-rw-r--r-- | source/blender/blenkernel/intern/effect.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 5d8401d7a43..ab69196e8b6 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -29,6 +29,11 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/blenkernel/intern/effect.c + * \ingroup bke + */ + + #include <stddef.h> #include "BLI_storage.h" /* _LARGEFILE_SOURCE */ @@ -356,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); @@ -484,7 +495,7 @@ static float wind_func(struct RNG *rng, float strength) float ret; float sign = 0; - sign = ((float)random > 64.0) ? 1.0: -1.0; // dividing by 2 is not giving equal sign distribution + sign = ((float)random > 64.0f) ? 1.0f: -1.0f; // dividing by 2 is not giving equal sign distribution ret = sign*((float)random / force)*strength/128.0f; @@ -506,7 +517,7 @@ static float falloff_func(float fac, int usemin, float mindist, int usemax, floa if(!usemin) mindist = 0.0; - return pow((double)1.0+fac-mindist, (double)-power); + return pow((double)(1.0f+fac-mindist), (double)(-power)); } static float falloff_func_dist(PartDeflect *pd, float fac) @@ -642,7 +653,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin sim.psys= eff->psys; /* TODO: time from actual previous calculated frame (step might not be 1) */ - state.time = cfra - 1.0; + state.time = cfra - 1.0f; ret = psys_get_particle_state(&sim, *efd->index, &state, 0); /* TODO */ @@ -676,13 +687,16 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin /* use z-axis as normal*/ normalize_v3_v3(efd->nor, ob->obmat[2]); - /* for vortex the shape chooses between old / new force */ if(eff->pd && eff->pd->shape == PFIELD_SHAPE_PLANE) { - /* efd->loc is closes point on effector xy-plane */ float temp[3], translate[3]; sub_v3_v3v3(temp, point->loc, ob->obmat[3]); project_v3_v3v3(translate, temp, efd->nor); - add_v3_v3v3(efd->loc, ob->obmat[3], translate); + + /* for vortex the shape chooses between old / new force */ + if(eff->pd->forcefield == PFIELD_VORTEX) + add_v3_v3v3(efd->loc, ob->obmat[3], translate); + else /* normally efd->loc is closest point on effector xy-plane */ + sub_v3_v3v3(efd->loc, point->loc, translate); } else { VECCOPY(efd->loc, ob->obmat[3]); @@ -691,7 +705,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin if(real_velocity) { VECCOPY(efd->vel, ob->obmat[3]); - where_is_object_time(eff->scene, ob, cfra - 1.0); + where_is_object_time(eff->scene, ob, cfra - 1.0f); sub_v3_v3v3(efd->vel, efd->vel, ob->obmat[3]); } @@ -917,10 +931,10 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected case PFIELD_LENNARDJ: fac = pow((efd->size + point->size) / efd->distance, 6.0); - fac = - fac * (1.0 - fac) / efd->distance; + fac = - fac * (1.0f - fac) / efd->distance; /* limit the repulsive term drastically to avoid huge forces */ - fac = ((fac>2.0) ? 2.0 : fac); + fac = ((fac>2.0f) ? 2.0f : fac); mul_v3_fl(force, strength * fac); break; |