[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16133] trunk/blender/source/blender/ blenkernel/intern/particle_system.c: Boids didn' t get correct fall-off from wind effector.
Janne Karhu
jhkarh at utu.fi
Sat Aug 16 18:29:14 CEST 2008
Revision: 16133
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16133
Author: jhk
Date: 2008-08-16 18:29:12 +0200 (Sat, 16 Aug 2008)
Log Message:
-----------
Boids didn't get correct fall-off from wind effector.
Boids now react to vortex field also.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/particle_system.c
Modified: trunk/blender/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/particle_system.c 2008-08-16 16:21:01 UTC (rev 16132)
+++ trunk/blender/source/blender/blenkernel/intern/particle_system.c 2008-08-16 16:29:12 UTC (rev 16133)
@@ -3748,10 +3748,10 @@
distance = Normalize(dvec);
- if(part->flag & PART_DIE_ON_COL && distance < (epsys->particles+ptn2[p].index)->size){
- *pa_die=1;
- pa->dietime=cfra;
- i=BOID_TOT_RULES;
+ if(part->flag & PART_DIE_ON_COL && distance < (epsys->particles+ptn2[p].index)->size){
+ *pa_die=1;
+ pa->dietime=cfra;
+ i=BOID_TOT_RULES;
break;
}
@@ -3948,27 +3948,44 @@
bvf->Addf(dvec,dvec,bvec);
bvf->Addf(state->co,state->co,dvec);
- /* air speed from wind effectors */
- if(psys->effectors.first){
+ /* air speed from wind and vortex effectors */
+ if(psys->effectors.first) {
ParticleEffectorCache *ec;
- for(ec=psys->effectors.first; ec; ec=ec->next){
- if(ec->type & PSYS_EC_EFFECTOR){
+ for(ec=psys->effectors.first; ec; ec=ec->next) {
+ if(ec->type & PSYS_EC_EFFECTOR) {
Object *eob = ec->ob;
PartDeflect *pd = eob->pd;
+ float direction[3], vec_to_part[3];
+ float falloff;
- if(pd->forcefield==PFIELD_WIND && pd->f_strength!=0.0){
- float distance, wind[3];
- VecCopyf(wind,eob->obmat[2]);
- distance=VecLenf(state->co,eob->obmat[3]);
+ if(pd->f_strength != 0.0f) {
+ VecCopyf(direction, eob->obmat[2]);
+ VecSubf(vec_to_part, state->co, eob->obmat[3]);
- if (distance < 0.001) distance = 0.001f;
+ falloff=effector_falloff(pd, direction, vec_to_part);
- if(pd->flag&PFIELD_USEMAX && distance > pd->maxdist)
- ;
- else{
- Normalize(wind);
- VecMulf(wind,pd->f_strength/(float)pow((double)distance,(double)pd->f_power));
- bvf->Addf(state->co,state->co,wind);
+ switch(pd->forcefield) {
+ case PFIELD_WIND:
+ if(falloff <= 0.0f)
+ ; /* don't do anything */
+ else {
+ Normalize(direction);
+ VecMulf(direction, pd->f_strength * falloff);
+ bvf->Addf(state->co, state->co, direction);
+ }
+ break;
+ case PFIELD_VORTEX:
+ {
+ float distance, mag_vec[3];
+ Crossf(mag_vec, direction, vec_to_part);
+ Normalize(mag_vec);
+
+ distance = VecLength(vec_to_part);
+
+ VecMulf(mag_vec, pd->f_strength * distance * falloff);
+ bvf->Addf(state->co, state->co, mag_vec);
+ break;
+ }
}
}
}
More information about the Bf-blender-cvs
mailing list