nice little thing -> have angular response on 'aero'
authorJens Ole Wund <bjornmose@gmx.net>
Sat, 12 Jan 2008 01:26:40 +0000 (01:26 +0000)
committerJens Ole Wund <bjornmose@gmx.net>
Sat, 12 Jan 2008 01:26:40 +0000 (01:26 +0000)
made backward compatible for sure

source/blender/blenkernel/intern/softbody.c
source/blender/makesdna/DNA_object_force.h
source/blender/src/buttons_object.c

index 6fde920ff7a33179beda5bd1a056cbc39eb5a558..a48dc4ae0bdc23a16d086fece8872eb80d26a809 100644 (file)
@@ -1510,14 +1510,20 @@ void scan_for_ext_spring_forces(Object *ob,float timenow)
                                        }
                                        f = Normalize(vel);
                                        f = -0.0001f*f*f*sb->aeroedge;
-                                       /* todo add a nice angle dependant function */
-                                       /* look up one at bergman scheafer */
+                                       /* (todo) add a nice angle dependant function done for now BUT */
+                                       /* still there could be some nice drag/lift function, but who needs it */ 
 
                                        VECSUB(sp, sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos);
                                        Projf(pr,vel,sp);
                                        VECSUB(vel,vel,pr);
                                        Normalize(vel);
-                                       Vec3PlusStVec(bs->ext_force,f,vel);
+                                       if (ob->softflag & OB_SB_AERO_ANGLE){
+                                               Normalize(sp);
+                                               Vec3PlusStVec(bs->ext_force,f*(1.0f-ABS(Inpf(vel,sp))),vel);
+                                       }
+                                       else{ 
+                                               Vec3PlusStVec(bs->ext_force,f,vel); // to keep compatible with 2.45 release files
+                                       }
                                }
                                /* --- springs seeing wind */
                        }
@@ -2252,15 +2258,7 @@ static void softbody_calc_forces(Object *ob, float forcetime, float timenow, int
                float defforce[3];
                do_deflector = sb_detect_aabb_collisionCached(defforce,ob->lay,ob,timenow);
        }
-/*
-       if (do_selfcollision ){ 
-               float ce[3]; 
-               VecMidf(ce,sb->scratch->aabbmax,sb->scratch->aabbmin);
-               for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
-                       bp->octantflag = set_octant_flags(ce,bp->pos,bp->colball);
-               }
-       }
-*/
+
        for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
                /* clear forces  accumulator */
                bp->force[0]= bp->force[1]= bp->force[2]= 0.0;
index 0cee849940baa137852f600925b96c1bf3b4fd46..928fcc4a4e07f2ba17e617352494f1700830012c 100644 (file)
@@ -191,6 +191,7 @@ typedef struct SoftBody {
 #define OB_SB_EDGECOLL  2048
 #define OB_SB_COLLFINAL 4096
 #define OB_SB_PROTECT_CACHE    8192
+#define OB_SB_AERO_ANGLE       16384
 
 /* sb->solverflags */
 #define SBSO_MONITOR    1 
index 18b9ac92ec03435841be4a907e7d0648a5ba9d59..062fc09361b535198ed15442f64bc0fa3f0844df 100644 (file)
@@ -3648,7 +3648,8 @@ static void object_softbodies(Object *ob)
                                uiDefButF(block, NUM, B_DIFF, "E Pull:",        10,30,100,20, &sb->inspring, 0.0,  0.999, 10, 0, "Edge spring stiffness");
                                uiDefButF(block, NUM, B_DIFF, "E Push:",        110,30,100,20, &sb->inpush, 0.0,  0.999, 10, 0, "Edge spring stiffness");
                                uiDefButF(block, NUM, B_DIFF, "E Damp:",        210,30,100,20, &sb->infrict, 0.0,  50.0, 10, 0, "Edge spring friction");
-                               uiDefButS(block, NUM, B_DIFF, "Aero:",     10,10,100,20, &sb->aeroedge,  0.00,  30000.0, 10, 0, "Make edges 'sail'");
+                               uiDefButBitS(block, TOG,OB_SB_AERO_ANGLE,B_SOFTBODY_CHANGE, "N",10,10,20,20, softflag, 0, 0, 0, 0, "New aero(uses angle and lenght)");
+                               uiDefButS(block, NUM, B_DIFF, "Aero:",     30,10,80,20, &sb->aeroedge,  0.00,  30000.0, 10, 0, "Make edges 'sail'");
                                if(ob->type==OB_MESH) {
                                        uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "Bend:", 110,10,100,20, &sb->secondspring, 0.0,  10.0, 10, 0, "Strenght of Springs over 2 Edges");
                                        if (*softflag & OB_SB_QUADS){