Little tweaks so 0 wind results in 0 noise, also removed double-mass dependancy in...
authorDaniel Genrich <daniel.genrich@gmx.net>
Mon, 18 Aug 2008 19:32:21 +0000 (19:32 +0000)
committerDaniel Genrich <daniel.genrich@gmx.net>
Mon, 18 Aug 2008 19:32:21 +0000 (19:32 +0000)
source/blender/blenkernel/BKE_effect.h
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/implicit.c

index 3b4c3198179c1467a80b80f80c4dc4270dde5138..cc1c8c1d708be0e60a9bab92c494865607e78a1e 100644 (file)
@@ -66,7 +66,7 @@ void                  pdEndEffectors(struct ListBase *lb);
 void                   pdDoEffectors(struct ListBase *lb, float *opco, float *force, float *speed, float cur_time, float loc_time, unsigned int flags);
 
 /* required for particle_system.c */
-void do_physical_effector(short type, float force_val, float distance, float falloff, float size, float damp, float *eff_velocity, float *vec_to_part, float *velocity, float *field, int planar, struct RNG *rng, float noise);
+void do_physical_effector(short type, float force_val, float distance, float falloff, float size, float damp, float *eff_velocity, float *vec_to_part, float *velocity, float *field, int planar, struct RNG *rng, float noise_factor);
 float effector_falloff(struct PartDeflect *pd, float *eff_velocity, float *vec_to_part);
 
 
index 1ab8ab757ecb9daa49f82e0f9947a7cc3482e634..890e488efcdf65b0b019e8ff6d9538c8da3a76b1 100644 (file)
@@ -315,12 +315,12 @@ float effector_falloff(PartDeflect *pd, float *eff_velocity, float *vec_to_part)
        return falloff;
 }
 
-void do_physical_effector(short type, float force_val, float distance, float falloff, float size, float damp, float *eff_velocity, float *vec_to_part, float *velocity, float *field, int planar, struct RNG *rng, float noise)
+void do_physical_effector(short type, float force_val, float distance, float falloff, float size, float damp, float *eff_velocity, float *vec_to_part, float *velocity, float *field, int planar, struct RNG *rng, float noise_factor)
 {
        float mag_vec[3]={0,0,0};
        float temp[3], temp2[3];
        float eff_vel[3];
-       float wind = 0;
+       float noise = 0;
 
        VecCopyf(eff_vel,eff_velocity);
        Normalize(eff_vel);
@@ -329,11 +329,11 @@ void do_physical_effector(short type, float force_val, float distance, float fal
                case PFIELD_WIND:
                        VECCOPY(mag_vec,eff_vel);
                        
-                       // add wind noise here
-                       if(noise> 0.0f)
-                               wind = wind_func(rng, noise);
-
-                       VecMulf(mag_vec,(force_val+wind)*falloff);
+                       // add wind noise here, only if we have wind
+                       if((noise_factor> 0.0f) && (force_val > FLT_EPSILON))
+                               noise = wind_func(rng, noise_factor);
+                       
+                       VecMulf(mag_vec,(force_val+noise)*falloff);
                        VecAddf(field,field,mag_vec);
                        break;
 
index 995ea666380335b7a699c0d644db13cf03856e4b..47853363e4b8d915669cc89ed35424b763908e42 100644 (file)
@@ -1452,6 +1452,7 @@ void cloth_calc_force(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVec
                        float triunnormal[3]={0,0,0}; // not-normalized-triangle normal
                        float tmp[3]={0,0,0};
                        float factor = (mfaces[i].v4) ? 0.25 : 1.0 / 3.0;
+                       factor *= 0.02;
                        
                        // calculate face normal
                        if(mfaces[i].v4)
@@ -1465,24 +1466,24 @@ void cloth_calc_force(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVec
                        // add wind from v1
                        VECCOPY(tmp, trinormal);
                        VecMulf(tmp, calculateVertexWindForce(winvec[mfaces[i].v1], triunnormal));
-                       VECADDS(lF[mfaces[i].v1], lF[mfaces[i].v1], tmp, factor*verts[mfaces[i].v1].mass);
+                       VECADDS(lF[mfaces[i].v1], lF[mfaces[i].v1], tmp, factor);
                        
                        // add wind from v2
                        VECCOPY(tmp, trinormal);
                        VecMulf(tmp, calculateVertexWindForce(winvec[mfaces[i].v2], triunnormal));
-                       VECADDS(lF[mfaces[i].v2], lF[mfaces[i].v2], tmp, factor*verts[mfaces[i].v2].mass);
+                       VECADDS(lF[mfaces[i].v2], lF[mfaces[i].v2], tmp, factor);
                        
                        // add wind from v3
                        VECCOPY(tmp, trinormal);
                        VecMulf(tmp, calculateVertexWindForce(winvec[mfaces[i].v3], triunnormal));
-                       VECADDS(lF[mfaces[i].v3], lF[mfaces[i].v3], tmp, factor*verts[mfaces[i].v3].mass);
+                       VECADDS(lF[mfaces[i].v3], lF[mfaces[i].v3], tmp, factor);
                        
                        // add wind from v4
                        if(mfaces[i].v4)
                        {
                                VECCOPY(tmp, trinormal);
                                VecMulf(tmp, calculateVertexWindForce(winvec[mfaces[i].v4], triunnormal));
-                               VECADDS(lF[mfaces[i].v4], lF[mfaces[i].v4], tmp, factor*verts[mfaces[i].v4].mass);
+                               VECADDS(lF[mfaces[i].v4], lF[mfaces[i].v4], tmp, factor);
                        }
                }
                del_lfvector(winvec);