Softbody: added "time" button, to control speed for wriggling. Low values
authorTon Roosendaal <ton@blender.org>
Wed, 20 Apr 2005 16:55:04 +0000 (16:55 +0000)
committerTon Roosendaal <ton@blender.org>
Wed, 20 Apr 2005 16:55:04 +0000 (16:55 +0000)
make it slower, higher values faster.

Monkey: accidentally got inverted normals for they eye again. :)

source/blender/blenkernel/intern/softbody.c
source/blender/blenloader/intern/readfile.c
source/blender/makesdna/DNA_object_types.h
source/blender/src/buttons_object.c
source/blender/src/editmesh_add.c

index ab5e50d944037499b383dbc2a25c1b9e478e5bf1..42e2145fcdfddd7403022de769a19c0a6116538a 100644 (file)
@@ -115,7 +115,6 @@ static float sb_fric_force_scale(Object *ob)
 static float sb_time_scale(Object *ob)
 // defining the frames to *real* time relation
 {
-/*
        SoftBody *sb= ob->soft; // is supposed to be there
        if (sb){
                return(sb->physics_speed); //hrms .. this could be IPO as well :) 
@@ -123,13 +122,12 @@ static float sb_time_scale(Object *ob)
                // 1 approx = a unit 1 pendulum at g = 9.8 [earth conditions]  has period 65 frames
         // theory would give a 50 frames period .. so there must be something inaccurate .. looking for that (BM) 
        }
-*/
        return (1.0f);
-/* 
-this would be frames/sec independant timing assuming 25 fps is default
-but does not work very well with NLA
-       return (25.0f/G.scene->r.frs_sec)
-*/
+       /* 
+       this would be frames/sec independant timing assuming 25 fps is default
+       but does not work very well with NLA
+               return (25.0f/G.scene->r.frs_sec)
+       */
 }
 /*--- frame based timing ---*/
 
@@ -1024,6 +1022,7 @@ SoftBody *sbNew(void)
        sb->mediafrict= 0.5; 
        sb->nodemass= 1.0;
        sb->grav= 0.0; 
+       sb->physics_speed= 1.0;
        
        sb->goalspring= 0.5; 
        sb->goalfrict= 0.0; 
index f2db3d25621729faa86296faa14f861e8331a524..38b88d0ccf4e23d23618206e6b2991e0f2520221 100644 (file)
@@ -4223,8 +4223,6 @@ static void do_versions(Main *main)
                        ma->param[1]= 0.1;
                        ma->param[2]= 0.1;
                        ma->param[3]= 0.05;
-                       ma->rms=0.1;
-                       ma->darkness=1.0;
                }
                // patch for old wrong max view2d settings, allows zooming out more
                for (sc= main->screen.first; sc; sc= sc->id.next) {
@@ -4687,10 +4685,12 @@ static void do_versions(Main *main)
                                sb->maxgoal= ob->sb_maxgoal;
                                sb->mediafrict= ob->sb_mediafrict; 
                                sb->rklimit= ob->softtime;
-                               sb->defgoal= 0.7;
-                               
                                ob->softflag |= OB_SB_GOAL|OB_SB_EDGES;
                        }
+                       if(ob->soft) {
+                               if(ob->soft->defgoal==0.0) ob->soft->defgoal= 0.7;
+                               if(ob->soft->physics_speed==0.0) ob->soft->physics_speed= 1.0;
+                       }
                        if(ob->soft && ob->soft->vertgroup==0) {
                                bDeformGroup *locGroup = get_named_vertexgroup(ob, "SOFTGOAL");
                                if(locGroup){
index 2998e1f9d684b2288fd27190ce006fd75c730f1f..d04e342de212940ec224a550daffc1e0079d0461 100644 (file)
@@ -120,13 +120,14 @@ typedef struct SoftBody {
        float grav;                     /* softbody amount of gravitaion to apply */
        float mediafrict;       /* friction to env */
        float rklimit;          /* error limit for ODE solver */
+       float physics_speed;/* user control over simulation speed */
        
        float goalspring;       /* softbody goal springs */
        float goalfrict;        /* softbody goal springs friction */
        float mingoal;          /* quick limits for goal */
        float maxgoal;
-       short vertgroup;                /* index starting at 1 */
-       short pad1, pad2, pad3;
+       short vertgroup;        /* index starting at 1 */
+       short pad1;
        
        float inspring;         /* softbody inner springs */
        float infrict;          /* softbody inner springs friction */
index ceaeff9221b76e5870794a5f70048964be563387..ed4b1337ab4099223c9df2d48638985854bb691b 100644 (file)
@@ -1509,8 +1509,9 @@ static void object_softbodies(Object *ob)
                uiBlockBeginAlign(block);
                uiDefButF(block, NUM, B_DIFF, "Friction:",              10, 170,150,20, &sb->mediafrict, 0.0, 10.0, 10, 0, "General Friction for point movements");
                uiDefButF(block, NUM, B_DIFF, "Mass:",                  160, 170,150,20, &sb->nodemass , 0.001, 50.0, 10, 0, "Point Mass, the heavier the slower");
-               uiDefButF(block, NUM, B_DIFF, "Grav:",                  10,150,150,20, &sb->grav , 0.0, 10.0, 10, 0, "Apply gravitation to point movement");
-               uiDefButF(block, NUM, B_DIFF, "RKL:",                   160,150,150,20, &sb->rklimit , 0.01, 1.0, 10, 0, "Runge-Kutta ODE solver error limit");
+               uiDefButF(block, NUM, B_DIFF, "Grav:",                  10,150,100,20, &sb->grav , 0.0, 10.0, 10, 0, "Apply gravitation to point movement");
+               uiDefButF(block, NUM, B_DIFF, "RKL:",                   110,150,100,20, &sb->rklimit , 0.01, 1.0, 10, 0, "Runge-Kutta ODE solver error limit");
+               uiDefButF(block, NUM, B_DIFF, "Time:",                  210,150,100,20, &sb->physics_speed , 0.01, 100.0, 10, 0, "Tweak timing for physics to control frequency and speed");
                uiDefButBitS(block, TOG, OB_SB_POSTDEF, B_DIFF, "PostDef",      10,130,300,20, &ob->softflag, 0, 0, 0, 0, "Apply Soft AFTER Deform");
                uiBlockEndAlign(block);
                
index e37382a3d38b92189affc7ee0410aa12fdb5aeec..b61f02a5032b3f8e1ed18d4d69512dca6bc24f61 100644 (file)
@@ -829,20 +829,19 @@ void add_primitiveMesh(int type)
                MEM_freeN(tv);
 
                /* and now do imat */
-               eve= em->verts.first;
-               while(eve) {
+               for(eve= em->verts.first; eve; eve= eve->next) {
                        if(eve->f & SELECT) {
                                VecAddf(eve->co,eve->co,cent);
                                Mat3MulVecfl(imat,eve->co);
                        }
-                       eve= eve->next;
                }
+               recalc_editnormals();
        }
        
        // simple selection flush OK, based on fact it's a single model
        EM_select_flush(); // flushes vertex -> edge -> face selection
        
-       if(type!=0 && type!=10) righthandfaces(1);
+       if(type!=0 && type!=10 && type!=13) righthandfaces(1);  // otherwise monkey has eyes in wrong direction...
        countall();
 
        allqueue(REDRAWINFO, 1);        /* 1, because header->win==0! */