Added baking for softbodies.
authorTon Roosendaal <ton@blender.org>
Mon, 2 May 2005 13:28:13 +0000 (13:28 +0000)
committerTon Roosendaal <ton@blender.org>
Mon, 2 May 2005 13:28:13 +0000 (13:28 +0000)
Works as follows;
- press the 'show bake settings' button (no space left... :)
- define start/end frame for bake, and an interval step.
  The baked result interpolates nicely (Bspline, 4 keys) so in general a
  step size of 2 or 3 still gives OK results.
- Press "BAKE". This will do a full animation + playback. Press ESC if it
  you don't want it.

Once Baked, the BAKE button becomes a FREE BAKE. As reminder the softbody
buttons get blocked with error() menu.

This saves OK in a file. Renders any frame, including fields and moblur.
You can also set a "Timeoffs" for the softbody. And yes, this should be
in the NLA once... :)

NOTE! With this commit, files saved with the old (first commit) version by
Jens Ole won't read the settings back... he stored all sofbody variables in
Object, which was moved to a new struct when I did my first commit on SB
(over a month ago)

Also note that I moved particle deflecting & softbody to a new include.

21 files changed:
source/blender/blenkernel/intern/deform.c
source/blender/blenkernel/intern/displist.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/ipo.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/softbody.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/include/butspace.h
source/blender/makesdna/DNA_object_force.h [new file with mode: 0644]
source/blender/makesdna/DNA_object_types.h
source/blender/makesdna/intern/makesdna.c
source/blender/python/api2_2x/Object.c
source/blender/renderconverter/intern/convertBlenderScene.c
source/blender/src/buttons_editing.c
source/blender/src/buttons_object.c
source/blender/src/drawobject.c
source/blender/src/editobject.c
source/blender/src/interface.c
source/blender/src/space.c
source/blender/src/vpaint.c

index 61eb514292b36688da9089611e4dae720195c4c7..226a1d602b7685a07fd4a12615855a17edab6930 100644 (file)
@@ -46,6 +46,7 @@
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
+#include "DNA_object_force.h"
 #include "DNA_scene_types.h"
 
 #include "BKE_curve.h"
index 54fffdac28f96acefb667fea4c40f80bad51c41d..26b05381e1b74ab69a8b2e10a82b7fe301e881e9 100644 (file)
@@ -52,6 +52,7 @@
 #include "DNA_listBase.h"
 #include "DNA_lamp_types.h"
 #include "DNA_object_types.h"
+#include "DNA_object_force.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_scene_types.h"
index 137feb88046fa20587e8667739b42e405eda7b47..ac28caec12b87a9dd4ffbc1b072dedf5923ac174 100644 (file)
@@ -39,6 +39,7 @@
 #include "DNA_listBase.h"
 #include "DNA_effect_types.h"
 #include "DNA_object_types.h"
+#include "DNA_object_force.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_material_types.h"
index 63db6820085b5ad9c7c5ee53faa2d413dc38329a..e8043692950577a28955a61287ad88a9c7f679ae 100644 (file)
 #include "DNA_texture_types.h"
 #include "DNA_material_types.h"
 #include "DNA_object_types.h"
+#include "DNA_object_force.h"
 #include "DNA_mesh_types.h"
 #include "DNA_curve_types.h"
 #include "DNA_ipo_types.h"
 #include "DNA_action_types.h"
+
 #include "BLI_blenlib.h"
 #include "BLI_arithb.h"
 
index 8f0fe7971839188b2b2a500319f2cc84c90512bd..69f21018562bcdb82d2f1852984c27c954493cf6 100644 (file)
@@ -56,6 +56,7 @@
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
+#include "DNA_object_force.h"
 #include "DNA_oops_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
index 0b78ead13c8023b9e264bec15ae1413352f07d90..ec60e341c33feff0c85f35f9558e687c5be6a7bd 100644 (file)
@@ -60,6 +60,8 @@ variables on the UI for now
 /* types */
 #include "DNA_curve_types.h"
 #include "DNA_object_types.h"
+#include "DNA_object_force.h"  /* here is the softbody struct */
+#include "DNA_key_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_lattice_types.h"
@@ -71,6 +73,7 @@ variables on the UI for now
 #include "BKE_displist.h"
 #include "BKE_effect.h"
 #include "BKE_global.h"
+#include "BKE_key.h"
 #include "BKE_object.h"
 #include "BKE_softbody.h"
 #include "BKE_utildefines.h"
@@ -261,6 +264,22 @@ static void renew_softbody(Object *ob, int totpoint, int totspring)
        }
 }
 
+static void free_softbody_baked(SoftBody *sb)
+{
+       SBVertex *key;
+       int k;
+       
+       for(k=0; k<sb->totkey; k++) {
+               key= *(sb->keys + k);
+               if(key) MEM_freeN(key);
+       }
+       if(sb->keys) MEM_freeN(sb->keys);
+       
+       sb->keys= NULL;
+       sb->totkey= 0;
+       
+}
+
 /* only frees internal data */
 static void free_softbody_intern(SoftBody *sb)
 {
@@ -283,6 +302,8 @@ static void free_softbody_intern(SoftBody *sb)
                sb->totpoint= sb->totspring= 0;
                sb->bpoint= NULL;
                sb->bspring= NULL;
+               
+               free_softbody_baked(sb);
        }
 }
 
@@ -752,7 +773,7 @@ static void mesh_update_softbody(Object *ob)
        int a;
        
        /* possible after a file read... */
-       if(ob->soft->totpoint!=me->totvert) sbObjectToSoftbody(ob);
+       if(ob->soft->bpoint==NULL) sbObjectToSoftbody(ob);
        
        if(me->totvert) {
        
@@ -951,7 +972,7 @@ static void lattice_update_softbody(Object *ob)
        totvert= lt->pntsu*lt->pntsv*lt->pntsw;
        
        /* possible after a file read... */
-       if(ob->soft->totpoint!=totvert) sbObjectToSoftbody(ob);
+       if(ob->soft->bpoint==NULL) sbObjectToSoftbody(ob);
        
        for(a= totvert, bp= lt->def, bop= ob->soft->bpoint; a>0; a--, bp++, bop++) {
                VECCOPY(bop->origS, bop->origE);
@@ -999,7 +1020,110 @@ static void object_update_softbody(Object *ob)
        
 }
 
+/* return 1 if succesfully baked and applied step */
+static int softbody_baked_step(Object *ob, float framenr)
+{
+       SoftBody *sb= ob->soft;
+       SBVertex *key0, *key1, *key2, *key3;
+       BodyPoint *bp;
+       float data[4], sfra, efra, cfra, dfra, fac;     // start, end, current, delta 
+       int ofs1, a;
+
+       /* precondition check */
+       if(sb==NULL || sb->keys==NULL || sb->totkey==0) return 0;
+       /* so we got keys, but no bodypoints... even without simul we need it for the bake */
+       if(sb->bpoint==NULL) sb->bpoint= MEM_callocN( sb->totpoint*sizeof(BodyPoint), "bodypoint");
+       
+       /* convert cfra time to system time */
+       sfra= (float)sb->sfra;
+       cfra= bsystem_time(ob, NULL, framenr, 0.0);
+       efra= (float)sb->efra;
+       dfra= (float)sb->interval;
 
+       /* offset in keys array */
+       ofs1= floor( (cfra-sfra)/dfra );
+
+       if(ofs1 < 0) {
+               key0=key1=key2=key3= *sb->keys;
+       }
+       else if(ofs1 >= sb->totkey-1) {
+               key0=key1=key2=key3= *(sb->keys+sb->totkey-1);
+       }
+       else {
+               key1= *(sb->keys+ofs1);
+               key2= *(sb->keys+ofs1+1);
+
+               if(ofs1>0) key0= *(sb->keys+ofs1-1);
+               else key0= key1;
+               if(ofs1<sb->totkey-1) key3= *(sb->keys+ofs1+1);
+               else key3= key2;
+       }
+       
+       sb->ctime= cfra;        // needed?
+       
+       /* timing */
+       fac= ((cfra-sfra)/dfra) - (float)ofs1;
+       CLAMP(fac, 0.0, 1.0);
+       set_four_ipo(fac, data, KEY_BSPLINE);
+       
+       for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++, key0++, key1++, key2++, key3++) {
+               bp->pos[0]= data[0]*key0->vec[0] +  data[1]*key1->vec[0] + data[2]*key2->vec[0] + data[3]*key3->vec[0];
+               bp->pos[1]= data[0]*key0->vec[1] +  data[1]*key1->vec[1] + data[2]*key2->vec[1] + data[3]*key3->vec[1];
+               bp->pos[2]= data[0]*key0->vec[2] +  data[1]*key1->vec[2] + data[2]*key2->vec[2] + data[3]*key3->vec[2];
+       }
+       
+       softbody_to_object(ob);
+       
+       return 1;
+}
+
+/* only gets called after succesfully doing softbody_step */
+/* already checked for OB_SB_BAKE flag */
+static void softbody_baked_add(Object *ob, float framenr)
+{
+       SoftBody *sb= ob->soft;
+       SBVertex *key;
+       BodyPoint *bp;
+       float sfra, efra, cfra, dfra, fac1;     // start, end, current, delta 
+       int ofs1, a;
+       
+       /* convert cfra time to system time */
+       sfra= (float)sb->sfra;
+       cfra= bsystem_time(ob, NULL, framenr, 0.0);
+       efra= (float)sb->efra;
+       dfra= (float)sb->interval;
+       
+       if(sb->totkey==0) {
+               if(sb->sfra >= sb->efra) return;                // safety, UI or py setting allows
+               if(sb->interval<1) sb->interval= 1;             // just be sure
+               
+               sb->totkey= 1 + (int)(ceil( (efra-sfra)/dfra ) );
+               sb->keys= MEM_callocN( sizeof(void *)*sb->totkey, "sb keys");
+       }
+       
+       /* now find out if we have to store a key */
+       
+       /* offset in keys array */
+       if(cfra==efra) {
+               ofs1= sb->totkey-1;
+               fac1= 0.0;
+       }
+       else {
+               ofs1= floor( (cfra-sfra)/dfra );
+               fac1= ((cfra-sfra)/dfra) - (float)ofs1;
+       }       
+       if( fac1 < 1.0/dfra ) {
+               
+               key= *(sb->keys+ofs1);
+               if(key == NULL) {
+                       *(sb->keys+ofs1)= key= MEM_mallocN(sb->totpoint*sizeof(SBVertex), "softbody key");
+                       
+                       for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++, key++) {
+                               VECCOPY(key->vec, bp->pos);
+                       }
+               }
+       }
+}
 
 /* ************ Object level, exported functions *************** */
 
@@ -1025,6 +1149,10 @@ SoftBody *sbNew(void)
        sb->inspring= 0.5;
        sb->infrict= 0.5; 
        
+       sb->interval= 10;
+       sb->sfra= G.scene->r.sfra;
+       sb->efra= G.scene->r.efra;
+       
        return sb;
 }
 
@@ -1098,10 +1226,14 @@ void sbObjectStep(Object *ob, float framenr)
           vertices in lattice (ton) */
        if(G.moving) return;
        
+       /* baking works with global time */
+       if(!(ob->softflag & OB_SB_BAKEDO) )
+               if(softbody_baked_step(ob, framenr) ) return;
+       
        /* remake softbody if: */
        if( (ob->softflag & OB_SB_REDO) ||              // signal after weightpainting
                (ob->soft==NULL) ||                                     // just to be nice we allow full init
-               (ob->soft->totpoint==0) )                       // after reading new file, or acceptable as signal to refresh
+               (ob->soft->bpoint==NULL) )                      // after reading new file, or acceptable as signal to refresh
                        sbObjectToSoftbody(ob);
        
        sb= ob->soft;
@@ -1113,12 +1245,12 @@ void sbObjectStep(Object *ob, float framenr)
        for(base= G.scene->base.first; base; base= base->next) {
                base->object->sumohandle= NULL;
        }
-       
+
        /* checking time: */
        ctime= bsystem_time(ob, NULL, framenr, 0.0);
        dtime= ctime - sb->ctime;
                // bail out for negative or for large steps
-       if(dtime<0.0 || dtime >= 9.9*G.scene->r.framelen) { // note: what is G.scene->r.framelen for ? (BM)
+       if(dtime<0.0 || dtime >= 9.9*G.scene->r.framelen) { // G.scene->r.framelen corrects for frame-mapping, so this is actually 10 frames for UI
                sbObjectReset(ob);
                return;
        }
@@ -1246,5 +1378,6 @@ void sbObjectStep(Object *ob, float framenr)
                }
        }
        
+       if(ob->softflag & OB_SB_BAKEDO) softbody_baked_add(ob, framenr);
 }
 
index a3d9e0e1202f5f2d85cf0fffca35b67f5600db1b..32bd71c9c9f40f8fcad8178524e57424569daf0a 100644 (file)
 
 #include "nla.h"
 
+#include "DNA_action_types.h"
+#include "DNA_armature_types.h"
 #include "DNA_ID.h"
-#include "DNA_packedFile_types.h"
-#include "DNA_property_types.h"
 #include "DNA_actuator_types.h"
+#include "DNA_camera_types.h"
 #include "DNA_controller_types.h"
-#include "DNA_sensor_types.h"
-#include "DNA_sdna_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_sequence_types.h"
+#include "DNA_constraint_types.h"
+#include "DNA_curve_types.h"
+#include "DNA_effect_types.h"
+#include "DNA_fileglobal_types.h"
+#include "DNA_group_types.h"
+#include "DNA_ipo_types.h"
 #include "DNA_ika_types.h"
-#include "DNA_camera_types.h"
-#include "DNA_lattice_types.h"
-#include "DNA_texture_types.h"
+#include "DNA_image_types.h"
 #include "DNA_key_types.h"
-#include "DNA_meta_types.h"
+#include "DNA_lattice_types.h"
 #include "DNA_lamp_types.h"
-#include "DNA_object_types.h"
-#include "DNA_world_types.h"
-#include "DNA_ipo_types.h"
+#include "DNA_meta_types.h"
+#include "DNA_material_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
-#include "DNA_image_types.h"
-#include "DNA_material_types.h"
-#include "DNA_curve_types.h"
-#include "DNA_vfont_types.h"
-#include "DNA_effect_types.h"
+#include "DNA_nla_types.h"
+#include "DNA_object_types.h"
+#include "DNA_object_force.h"
+#include "DNA_oops_types.h"
+#include "DNA_object_force.h"
+#include "DNA_packedFile_types.h"
+#include "DNA_property_types.h"
 #include "DNA_text_types.h"
 #include "DNA_view3d_types.h"
 #include "DNA_screen_types.h"
+#include "DNA_sensor_types.h"
+#include "DNA_sdna_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_sequence_types.h"
 #include "DNA_sound_types.h"
 #include "DNA_space_types.h"
-#include "DNA_oops_types.h"
-#include "DNA_group_types.h"
+#include "DNA_texture_types.h"
 #include "DNA_userdef_types.h"
-#include "DNA_fileglobal_types.h"
-#include "DNA_constraint_types.h"
-#include "DNA_action_types.h"
-#include "DNA_armature_types.h"
-#include "DNA_nla_types.h"
+#include "DNA_vfont_types.h"
+#include "DNA_world_types.h"
 
 #include "MEM_guardedalloc.h"
 #include "BLI_blenlib.h"
@@ -2289,8 +2291,9 @@ static void direct_link_object(FileData *fd, Object *ob)
        bController *cont;
        bActuator *act;
        ObHook *hook;
+       int a;
        
-       ob->disp.first=ob->disp.last= 0;
+       ob->disp.first=ob->disp.last= NULL;
 
        ob->pose= newdataadr(fd, ob->pose);
        direct_link_pose(fd, ob->pose);
@@ -2320,10 +2323,18 @@ static void direct_link_object(FileData *fd, Object *ob)
        ob->pd= newdataadr(fd, ob->pd);
        ob->soft= newdataadr(fd, ob->soft);
        if(ob->soft) {
-               SoftBody *sb= ob->soft;         // init all stuff so it gets rebuilt nicely
-               sb->totpoint= sb->totspring= 0;
-               sb->bpoint= NULL; 
+               SoftBody *sb= ob->soft;         
+               
+               sb->bpoint= NULL;       // init pointers so it gets rebuilt nicely
                sb->bspring= NULL;
+               
+               sb->keys= newdataadr(fd, sb->keys);
+               test_pointer_array(fd, (void **)&sb->keys);
+               if(sb->keys) {
+                       for(a=0; a<sb->totkey; a++) {
+                               sb->keys[a]= newdataadr(fd, sb->keys[a]);
+                       }
+               }
        }
        
        link_list(fd, &ob->prop);
@@ -4689,27 +4700,17 @@ static void do_versions(Main *main)
                        }
                }
                
-               /* temporal copy */
+               /* softbody init new vars */
                for(ob= main->object.first; ob; ob= ob->id.next) {
-                       if(ob->softflag && ob->soft==NULL) {
-                               SoftBody *sb;
-                               ob->soft=sb= sbNew();
-                               
-                               sb->goalspring= ob->sb_goalspring; 
-                               sb->goalfrict= ob->sb_goalfrict;  
-                               sb->inspring= ob->sb_inspring;   
-                               sb->infrict= ob->sb_infrict;  
-                               sb->nodemass= ob->sb_nodemass;
-                               sb->grav= ob->sb_grav;   
-                               sb->mingoal= ob->sb_mingoal;  
-                               sb->maxgoal= ob->sb_maxgoal;
-                               sb->mediafrict= ob->sb_mediafrict; 
-                               sb->rklimit= ob->softtime;
-                               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->interval==0) {
+                                       ob->soft->interval= 2;
+                                       ob->soft->sfra= 1;
+                                       ob->soft->efra= 100;
+                               }
                        }
                        if(ob->soft && ob->soft->vertgroup==0) {
                                bDeformGroup *locGroup = get_named_vertexgroup(ob, "SOFTGOAL");
index 00b29f32127dff5255d1fd996153f7e5216d410c..419897706fd8cbe942d8fc58899b259adc887431 100644 (file)
@@ -100,44 +100,45 @@ Important to know is that 'streaming' has been added to files, for Blender Publi
 
 #include "nla.h" //  __NLA is defined
 
-#include "DNA_packedFile_types.h"
-#include "DNA_sdna_types.h"
-#include "DNA_property_types.h"
-#include "DNA_sensor_types.h"
-#include "DNA_controller_types.h"
+#include "DNA_armature_types.h"
+#include "DNA_action_types.h"
 #include "DNA_actuator_types.h"
-#include "DNA_effect_types.h"
-#include "DNA_object_types.h"
-#include "DNA_userdef_types.h"
-#include "DNA_vfont_types.h"
-#include "DNA_ipo_types.h"
+#include "DNA_controller_types.h"
 #include "DNA_curve_types.h"
+#include "DNA_constraint_types.h"
 #include "DNA_camera_types.h"
+#include "DNA_effect_types.h"
+#include "DNA_group_types.h"
+#include "DNA_image_types.h"
+#include "DNA_ika_types.h"
+#include "DNA_ipo_types.h"
+#include "DNA_fileglobal_types.h"
+#include "DNA_key_types.h"
+#include "DNA_lattice_types.h"
+#include "DNA_listBase.h" /* for Listbase, the type of samples, ...*/
+#include "DNA_lamp_types.h"
 #include "DNA_meta_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_material_types.h"
-#include "DNA_lattice_types.h"
-#include "DNA_armature_types.h"
-#include "DNA_sequence_types.h"
-#include "DNA_ika_types.h"
-#include "DNA_group_types.h"
+#include "DNA_nla_types.h"
+#include "DNA_object_types.h"
+#include "DNA_object_force.h"
 #include "DNA_oops_types.h"
+#include "DNA_packedFile_types.h"
+#include "DNA_property_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_sdna_types.h"
+#include "DNA_sequence_types.h"
+#include "DNA_sensor_types.h"
 #include "DNA_space_types.h"
 #include "DNA_screen_types.h"
-#include "DNA_view3d_types.h"
-#include "DNA_lamp_types.h"
-#include "DNA_fileglobal_types.h"
 #include "DNA_sound_types.h"
 #include "DNA_texture_types.h"
 #include "DNA_text_types.h"
-#include "DNA_image_types.h"
-#include "DNA_key_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_constraint_types.h"
-#include "DNA_listBase.h" /* for Listbase, the type of samples, ...*/
-#include "DNA_action_types.h"
-#include "DNA_nla_types.h"
+#include "DNA_view3d_types.h"
+#include "DNA_vfont_types.h"
+#include "DNA_userdef_types.h"
 
 #include "MEM_guardedalloc.h" // MEM_freeN
 #include "BLI_blenlib.h"
@@ -661,6 +662,7 @@ static void write_objects(WriteData *wd, ListBase *idbase)
 {
        Object *ob;
        ObHook *hook;
+       int a;
        
        ob= idbase->first;
        while(ob) {
@@ -684,6 +686,15 @@ static void write_objects(WriteData *wd, ListBase *idbase)
                        
                        writestruct(wd, DATA, "PartDeflect", 1, ob->pd);
                        writestruct(wd, DATA, "SoftBody", 1, ob->soft);
+                       if(ob->soft) {
+                               SoftBody *sb= ob->soft;
+                               if(sb->keys) {
+                                       writedata(wd, DATA, sizeof(void *)*sb->totkey, sb->keys);
+                                       for(a=0; a<sb->totkey; a++) {
+                                               writestruct(wd, DATA, "SBVertex", sb->totpoint, sb->keys[a]);
+                                       }
+                               }
+                       }
                        
                        for(hook= ob->hooks.first; hook; hook= hook->next) {
                                writestruct(wd, DATA, "ObHook", 1, hook);
index 755b5c127fa5b44e65ba013ee91451dfb00ba7b6..443b97430fac502f3762c675c6cc16bc1ca2b0d5 100644 (file)
@@ -221,8 +221,10 @@ void test_idbutton_cb(void *namev, void *arg2_unused);
 #define B_RELKEY               1415
 #define B_CURVECHECK   1416
 
-#define B_SOFTBODY_CHANGE      1420
-#define B_SOFTBODY_DEL_VG      1421
+#define B_SOFTBODY_CHANGE              1420
+#define B_SOFTBODY_DEL_VG              1421
+#define B_SOFTBODY_BAKE                        1422
+#define B_SOFTBODY_BAKE_FREE   1423
 
        /* this has MAX_EFFECT settings! Next free define is 1450... */
 #define B_SELEFFECT    1430    
diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h
new file mode 100644 (file)
index 0000000..59ea0cd
--- /dev/null
@@ -0,0 +1,126 @@
+/**
+ *
+ * $Id:  
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License.  See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2004-2005 by Blender Foundation
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+#ifndef DNA_OBJECT_FORCE_H
+#define DNA_OBJECT_FORCE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+       
+typedef struct PartDeflect {
+       short deflect;          /* Deflection flag - does mesh deflect particles*/
+       short forcefield;       /* Force field type, do the vertices attract / repel particles ? */
+       short flag;                     /* general settings flag */
+       short pad;
+       
+       float pdef_damp;        /* Damping factor for particle deflection       */
+       float pdef_rdamp;       /* Random element of damping for deflection     */
+       float pdef_perm;        /* Chance of particle passing through mesh      */
+
+       float f_strength;       /* The strength of the force (+ or - )       */
+       float f_power;          /* The power law - real gravitation is 2 (square)  */
+       float maxdist;          /* if indicated, use this maximum */
+       
+       float pdef_sbdamp;      /* Damping factor for softbody deflection       */
+       float pdef_sbift;       /* inner face thickness for softbody deflection */
+       float pdef_sboft;       /* outer face thickness for softbody deflection */
+} PartDeflect;
+
+
+typedef struct SBVertex {
+       float vec[4];
+} SBVertex;
+
+typedef struct SoftBody {
+       /* dynamic data */
+       int totpoint, totspring;
+       struct BodyPoint *bpoint;               /* not saved in file */
+       struct BodySpring *bspring;             /* not saved in file */
+       float ctime;                                    /* last time calculated */
+       
+       /* part of UI: */
+       
+       /* general options */
+       float nodemass;         /* softbody mass of *vertex* */
+       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 */
+       
+       /* goal */
+       float goalspring;       /* softbody goal springs */
+       float goalfrict;        /* softbody goal springs friction */
+       float mingoal;          /* quick limits for goal */
+       float maxgoal;
+       float defgoal;          /* default goal for vertices without vgroup */
+       short vertgroup;        /* index starting at 1 */
+       short pad1;
+       
+       /* springs */
+       float inspring;         /* softbody inner springs */
+       float infrict;          /* softbody inner springs friction */
+       
+       /* baking */
+       short sfra, efra;
+       short interval, pad2;
+       
+       SBVertex **keys;                        /* array of size totpointkey */
+       int totpointkey, totkey;        /* if totpointkey != totpoint or totkey!- (efra-sfra)/interval -> free keys */
+       
+} SoftBody;
+
+/* pd->forcefield:  Effector Fields types */
+#define PFIELD_FORCE   1
+#define PFIELD_VORTEX  2
+#define PFIELD_MAGNET  3
+#define PFIELD_WIND            4
+
+/* pd->flag: various settings */
+#define PFIELD_USEMAX  1
+
+/* ob->softflag */
+#define OB_SB_ENABLE   1
+#define OB_SB_GOAL             2
+#define OB_SB_EDGES            4
+#define OB_SB_QUADS            8
+#define OB_SB_POSTDEF  16
+#define OB_SB_REDO             32
+#define OB_SB_BAKESET  64
+#define OB_SB_BAKEDO   128
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
index d04e342de212940ec224a550daffc1e0079d0461..ea49d73cd04a8d0875c19cb4a39e38f10e677dde 100644 (file)
@@ -51,8 +51,8 @@ struct BoundBox;
 struct Path;
 struct Material;
 struct bConstraintChannel;
-struct BodyPoint;
-struct BodySpring;
+struct PartDeflect;
+struct SoftBody;
 
 typedef struct bDeformGroup {
        struct bDeformGroup *next, *prev;
@@ -79,62 +79,6 @@ typedef struct LBuf {
        struct Object **ob;
 } LBuf;
 
-typedef struct PartDeflect {
-       short deflect;          /* Deflection flag - does mesh deflect particles*/
-       short forcefield;       /* Force field type, do the vertices attract / repel particles ? */
-       short flag;                     /* general settings flag */
-       short pad;
-       
-       float pdef_damp;        /* Damping factor for particle deflection       */
-       float pdef_rdamp;       /* Random element of damping for deflection     */
-       float pdef_perm;        /* Chance of particle passing through mesh      */
-
-       float f_strength;       /* The strength of the force (+ or - )       */
-       float f_power;          /* The power law - real gravitation is 2 (square)  */
-       float maxdist;          /* if indicated, use this maximum */
-       
-       float pdef_sbdamp;      /* Damping factor for softbody deflection       */
-       float pdef_sbift;       /* inner face thickness for softbody deflection */
-       float pdef_sboft;       /* outer face thickness for softbody deflection */
-} PartDeflect;
-
-/* pd->forcefield:  Effector Fields types */
-#define PFIELD_FORCE   1
-#define PFIELD_VORTEX  2
-#define PFIELD_MAGNET  3
-#define PFIELD_WIND            4
-
-/* pd->flag: various settings */
-#define PFIELD_USEMAX  1
-
-
-typedef struct SoftBody {
-       /* dynamic data */
-       int totpoint, totspring;
-       struct BodyPoint *bpoint;               /* not saved in file */
-       struct BodySpring *bspring;             /* not saved in file */
-       float ctime;                                    /* last time calculated */
-       
-       /* part of UI: */
-       float nodemass;         /* softbody mass of *vertex* */
-       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;
-       
-       float inspring;         /* softbody inner springs */
-       float infrict;          /* softbody inner springs friction */
-       
-       float defgoal;          /* default goal for vertices without vgroup */
-       
-} SoftBody;
 
 typedef struct Object {
        ID id;
@@ -239,28 +183,15 @@ typedef struct Object {
        ListBase nlastrips;
        ListBase hooks;
        
-       PartDeflect *pd;                /* particle deflector/attractor/collision data */
-       struct SoftBody *soft;  /* if exists, saved in file */
+       struct PartDeflect *pd;         /* particle deflector/attractor/collision data */
+       struct SoftBody *soft;          /* if exists, saved in file */
        struct Life *life;
 
        LBuf lbuf;
        LBuf port;
-
+       
        float toonedge, smoothresh;     /* smoothresh is phong interpolation ray_shadow correction in render */
-/* this stuff MUST NOT be here
-   is here for softbody devel purpose 
-*/
-       float sb_goalspring; /* softbody goal springs */
-       float sb_goalfrict;   /* softbody goal springs friction */
-       float sb_inspring;       /* softbody inner springs */
-       float sb_infrict;   /* softbody inner springs friction */
-       float sb_nodemass;       /* softbody mass of *vertex* */
-       float sb_grav;      /* softbody amount of gravitaion to apply */
-       float sb_mingoal;   /* quick limits for goal */
-       float sb_maxgoal;
-       float sb_mediafrict;   /* friction to env */
-       float sb_pad1;        /* free */
-    
+  
 } Object;
 
 typedef struct ObHook {
@@ -433,13 +364,7 @@ extern Object workob;
 #define OB_ADDACT              1024
 #define OB_SHOWCONT            2048
 
-/* ob->softflag */
-#define OB_SB_ENABLE   1
-#define OB_SB_GOAL             2
-#define OB_SB_EDGES            4
-#define OB_SB_QUADS            8
-#define OB_SB_POSTDEF  16
-#define OB_SB_REDO             32
+/* ob->softflag in DNA_object_force.h */
 
 #ifdef __cplusplus
 }
index 14ccba59e98d085803d7ae871c86a556f08ec8df..b550d18bdb27ed8f9cc2c44d8c871a01646125b9 100644 (file)
@@ -95,6 +95,7 @@ char *includefiles[] = {
        "DNA_meshdata_types.h",
        "DNA_lattice_types.h",  
        "DNA_object_types.h",
+       "DNA_object_force.h",
        "DNA_world_types.h",
        "DNA_radio_types.h",
        "DNA_scene_types.h",
@@ -1109,6 +1110,7 @@ int main(int argc, char ** argv)
 #include "DNA_meshdata_types.h"
 #include "DNA_lattice_types.h" 
 #include "DNA_object_types.h"
+#include "DNA_object_force.h"
 #include "DNA_world_types.h"
 #include "DNA_radio_types.h"
 #include "DNA_scene_types.h"
index 63f97f8824907c82503c4e26927e69f760cee0e3..d07633a51858a9ac1a4e539c4be9434c823fc96f 100644 (file)
 #include "NLA.h"
 #include "logic.h"
 #include <blendef.h>
+
 #include <DNA_scene_types.h>
 #include <DNA_mesh_types.h>
 #include <DNA_curve_types.h>
+#include "DNA_object_force.h"
 #include <DNA_property_types.h>
+
 #include <BSE_edit.h>
+
 #include <BKE_property.h>
 #include <BKE_mball.h>
 #include <BKE_font.h>
 #include <BKE_softbody.h>
+
 #include <BIF_editview.h>
 #include <BSE_editipo.h>
 
index c3db05c169890fe4f142013a039e985acf9f22f4..744b568aaac31efedd3f97f4b9c1caf8abffdf54 100644 (file)
 #include "BLI_rand.h"
 #include "BLI_memarena.h"
 
-#include "DNA_scene_types.h"
-#include "DNA_lamp_types.h"
+#include "DNA_armature_types.h"
 #include "DNA_camera_types.h"
 #include "DNA_material_types.h"
 #include "DNA_curve_types.h"
-#include "DNA_texture_types.h"
-#include "DNA_lattice_types.h"
 #include "DNA_effect_types.h"
 #include "DNA_ika_types.h"
-#include "DNA_armature_types.h"
-#include "DNA_object_types.h"
-#include "DNA_view3d_types.h"
+#include "DNA_lamp_types.h"
+#include "DNA_lattice_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_meta_types.h"
+#include "DNA_object_types.h"
+#include "DNA_object_force.h"
+#include "DNA_scene_types.h"
+#include "DNA_texture_types.h"
+#include "DNA_view3d_types.h"
 
 #include "BKE_anim.h"
 #include "BKE_armature.h"
index c55574d97915216243799134c32ca05ef883cbed..d48d933f99b2f761e592e74027215a71ce34fb12 100644 (file)
@@ -67,6 +67,7 @@
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
+#include "DNA_object_force.h"
 #include "DNA_radio_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_texture_types.h"
index cdc947da3831d3b061029f5353ced29de1b6ae4d..13383864f11ae833daa4edd42a9dd479a3df77c7 100644 (file)
@@ -40,6 +40,7 @@
 #endif
 
 #include "MEM_guardedalloc.h"
+
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
 #include "DNA_scene_types.h"
@@ -53,6 +54,7 @@
 #include "BLI_arithb.h"
 
 #include "BSE_filesel.h"
+#include "BSE_headerbuttons.h"
 
 #include "BIF_gl.h"
 #include "BIF_graphics.h"
@@ -94,6 +96,7 @@
 #include "DNA_meta_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_object_types.h"
+#include "DNA_object_force.h"
 #include "DNA_radio_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_sound_types.h"
@@ -1101,6 +1104,51 @@ void object_panel_hooks(Object *ob)
        uiDefBut(block, BUT, B_CLR_HOOK, "Clear offset",                160,80,150,19, NULL, 0.0, 0.0, 0, 0, "Recalculate and clear offset (transform) of hook");
 }
 
+static void softbody_bake(Object *ob)
+{
+       SoftBody *sb= ob->soft;
+       ScrArea *sa;
+       int cfrao= CFRA;
+       unsigned short event=0;
+       short val;
+       
+       CFRA= sb->sfra;
+       sbObjectToSoftbody(ob);
+       ob->softflag |= OB_SB_BAKEDO;
+       
+       curarea->win_swap= WIN_BACK_OK;         // clean swapbuffers
+       
+       for(; CFRA <= sb->efra; CFRA++) {
+               set_timecursor(CFRA);
+               
+               update_for_newframe_muted();
+               
+               for(sa= G.curscreen->areabase.first; sa; sa= sa->next) {
+                       if(sa->spacetype == SPACE_VIEW3D) {
+                               scrarea_do_windraw(sa);
+                       }
+               }
+               screen_swapbuffers();
+               
+               while(qtest()) {
+                       
+                       event= extern_qread(&val);
+                       if(event==ESCKEY) break;
+               }
+               if(event==ESCKEY) break;
+       }
+       
+       if(event==ESCKEY) sbObjectToSoftbody(ob);       // clears all
+       
+       /* restore */
+       waitcursor(0);
+       ob->softflag &= ~OB_SB_BAKEDO;
+       CFRA= cfrao;
+       update_for_newframe_muted();
+       allqueue(REDRAWVIEW3D, 0);
+       allqueue(REDRAWBUTSOBJECT, 0);
+}
+
 
 void do_object_panels(unsigned short event)
 {
@@ -1207,6 +1255,16 @@ void do_object_panels(unsigned short event)
                        allqueue(REDRAWVIEW3D, 0);
                }
                break;
+       case B_SOFTBODY_BAKE:
+               ob= OBACT;
+               if(ob && ob->soft) softbody_bake(ob);
+               break;
+       case B_SOFTBODY_BAKE_FREE:
+               ob= OBACT;
+               if(ob && ob->soft) sbObjectToSoftbody(ob);
+               allqueue(REDRAWBUTSOBJECT, 0);
+               allqueue(REDRAWVIEW3D, 0);
+               break;
                
        default:
                if(event>=B_SELEFFECT && event<B_SELEFFECT+MAX_EFFECT) {
@@ -1480,6 +1538,7 @@ static void object_panel_deflectors(Object *ob)
        }
 }
 
+
 /* Panel for softbodies */
 
 static void object_softbodies(Object *ob)
@@ -1508,52 +1567,75 @@ static void object_softbodies(Object *ob)
                        }
                }
                
-               /* GENERAL STUFF */
-               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,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);
-               
-               /* GOAL STUFF */
-               uiBlockBeginAlign(block);
-               uiDefButBitS(block, TOG, OB_SB_GOAL, B_DIFF, "Use Goal",        10,100,130,20, &ob->softflag, 0, 0, 0, 0, "Define forces for vertices to stick to animated position");
+               uiDefButBitS(block, TOG, OB_SB_BAKESET, REDRAWBUTSOBJECT, "Bake settings",      180,200,130,20, &ob->softflag, 0, 0, 0, 0, "To convert simulation into baked (cached) result");
                
-               menustr= get_vertexgroup_menustr(ob);
-               defCount=BLI_countlist(&ob->defbase);
-               if(defCount==0) sb->vertgroup= 0;
-               uiDefButS(block, MENU, B_SOFTBODY_CHANGE, menustr,              140,100,20,20, &sb->vertgroup, 0, defCount, 0, 0, "Browses available vertex groups");
+               if(sb->keys) uiSetButLock(1, "SoftBody is baked, free it first");
                
-               if(sb->vertgroup) {
-                       bDeformGroup *defGroup = BLI_findlink(&ob->defbase, sb->vertgroup-1);
-                       if(defGroup)
-                               uiDefBut(block, BUT, B_DIFF, defGroup->name,    160,100,130,20, NULL, 0.0, 0.0, 0, 0, "Name of current vertex group");
-                       else
-                               uiDefBut(block, BUT, B_DIFF, "(no group)",      160,100,130,20, NULL, 0.0, 0.0, 0, 0, "Vertex Group doesn't exist anymore");
-                       uiDefIconBut(block, BUT, B_SOFTBODY_DEL_VG, ICON_X, 290,100,20,20, 0, 0, 0, 0, 0, "Disable use of vertex group");
+               if(ob->softflag & OB_SB_BAKESET) {
+                       uiBlockBeginAlign(block);
+                       uiDefButS(block, NUM, B_DIFF, "Start:",                 10, 170,100,20, &sb->sfra, 1.0, 10000.0, 10, 0, "Start frame for baking");
+                       uiDefButS(block, NUM, B_DIFF, "End:",                   110, 170,100,20, &sb->efra, 1.0, 10000.0, 10, 0, "End frame for baking");
+                       uiDefButS(block, NUM, B_DIFF, "Interval:",              210, 170,100,20, &sb->interval, 1.0, 10.0, 10, 0, "Interval in frames between baked keys");
+                       
+                       uiClearButLock();
+                       
+                       uiBlockBeginAlign(block);
+                       if(sb->keys) {
+                               char str[128];
+                               uiDefIconTextBut(block, BUT, B_SOFTBODY_BAKE_FREE, ICON_X, "FREE BAKE", 10, 120,300,20, NULL, 0.0, 0.0, 0, 0, "Free baked result");
+                               sprintf(str, "Stored %d vertices %d keys %.3f MB", sb->totpoint, sb->totkey, ((float)16*sb->totpoint*sb->totkey)/(1024.0*1024.0));
+                               uiDefBut(block, LABEL, 0, str, 10, 100,300,20, NULL, 0.0, 0.0, 00, 0, "");
+                       }
+                       else                            
+                               uiDefBut(block, BUT, B_SOFTBODY_BAKE, "BAKE",   10, 120,300,20, NULL, 0.0, 0.0, 10, 0, "Start baking. Press ESC to exit without baking");
                }
                else {
-                       uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "Goal:",       160,100,150,20, &sb->defgoal, 0.0, 1.0, 10, 0, "Default Goal (vertex target position) value, when no Vertex Group used");
-               }
-               MEM_freeN (menustr);
-
-               uiDefButF(block, NUM, B_DIFF, "GSpring:",       10,80,150,20, &sb->goalspring, 0.0, 0.999, 10, 0, "Goal (vertex target position) Spring Constant");
-               uiDefButF(block, NUM, B_DIFF, "GFrict:",        160,80,150,20, &sb->goalfrict  , 0.0, 10.0, 10, 0, "Goal (vertex target position) Friction Constant");
-               uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "GMin:",               10,60,150,20, &sb->mingoal, 0.0, 1.0, 10, 0, "Min Goal bound");
-               uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "GMax:",               160,60,150,20, &sb->maxgoal, 0.0, 1.0, 10, 0, "Max Goal bound");
-               uiBlockEndAlign(block);
-               
-               /* EDGE SPRING STUFF */
-               uiBlockBeginAlign(block);
-               uiDefButBitS(block, TOG, OB_SB_EDGES, B_SOFTBODY_CHANGE, "Use Edges",           10,30,150,20, &ob->softflag, 0, 0, 0, 0, "Use Robust 2nd order solver");
-               uiDefButBitS(block, TOG, OB_SB_QUADS, B_SOFTBODY_CHANGE, "Stiff Quads",         160,30,150,20, &ob->softflag, 0, 0, 0, 0, "Sets object to have diagonal springs on 4-gons");
-               uiDefButF(block, NUM, B_DIFF, "ESpring:",       10,10,150,20, &sb->inspring, 0.0,  0.999, 10, 0, "Edge Spring Constant");
-               uiDefButF(block, NUM, B_DIFF, "EFrict:",        160,10,150,20, &sb->infrict, 0.0,  10.0, 10, 0, "Edge Friction Constant");
-               uiBlockEndAlign(block);
+                       /* GENERAL STUFF */
+                       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,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);
+                       
+                       /* GOAL STUFF */
+                       uiBlockBeginAlign(block);
+                       uiDefButBitS(block, TOG, OB_SB_GOAL, B_DIFF, "Use Goal",        10,100,130,20, &ob->softflag, 0, 0, 0, 0, "Define forces for vertices to stick to animated position");
+                       
+                       menustr= get_vertexgroup_menustr(ob);
+                       defCount=BLI_countlist(&ob->defbase);
+                       if(defCount==0) sb->vertgroup= 0;
+                       uiDefButS(block, MENU, B_SOFTBODY_CHANGE, menustr,              140,100,20,20, &sb->vertgroup, 0, defCount, 0, 0, "Browses available vertex groups");
+                       
+                       if(sb->vertgroup) {
+                               bDeformGroup *defGroup = BLI_findlink(&ob->defbase, sb->vertgroup-1);
+                               if(defGroup)
+                                       uiDefBut(block, BUT, B_DIFF, defGroup->name,    160,100,130,20, NULL, 0.0, 0.0, 0, 0, "Name of current vertex group");
+                               else
+                                       uiDefBut(block, BUT, B_DIFF, "(no group)",      160,100,130,20, NULL, 0.0, 0.0, 0, 0, "Vertex Group doesn't exist anymore");
+                               uiDefIconBut(block, BUT, B_SOFTBODY_DEL_VG, ICON_X, 290,100,20,20, 0, 0, 0, 0, 0, "Disable use of vertex group");
+                       }
+                       else {
+                               uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "Goal:",       160,100,150,20, &sb->defgoal, 0.0, 1.0, 10, 0, "Default Goal (vertex target position) value, when no Vertex Group used");
+                       }
+                       MEM_freeN (menustr);
 
+                       uiDefButF(block, NUM, B_DIFF, "GSpring:",       10,80,150,20, &sb->goalspring, 0.0, 0.999, 10, 0, "Goal (vertex target position) Spring Constant");
+                       uiDefButF(block, NUM, B_DIFF, "GFrict:",        160,80,150,20, &sb->goalfrict  , 0.0, 10.0, 10, 0, "Goal (vertex target position) Friction Constant");
+                       uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "GMin:",               10,60,150,20, &sb->mingoal, 0.0, 1.0, 10, 0, "Min Goal bound");
+                       uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "GMax:",               160,60,150,20, &sb->maxgoal, 0.0, 1.0, 10, 0, "Max Goal bound");
+                       uiBlockEndAlign(block);
+                       
+                       /* EDGE SPRING STUFF */
+                       uiBlockBeginAlign(block);
+                       uiDefButBitS(block, TOG, OB_SB_EDGES, B_SOFTBODY_CHANGE, "Use Edges",           10,30,150,20, &ob->softflag, 0, 0, 0, 0, "Use Robust 2nd order solver");
+                       uiDefButBitS(block, TOG, OB_SB_QUADS, B_SOFTBODY_CHANGE, "Stiff Quads",         160,30,150,20, &ob->softflag, 0, 0, 0, 0, "Sets object to have diagonal springs on 4-gons");
+                       uiDefButF(block, NUM, B_DIFF, "ESpring:",       10,10,150,20, &sb->inspring, 0.0,  0.999, 10, 0, "Edge Spring Constant");
+                       uiDefButF(block, NUM, B_DIFF, "EFrict:",        160,10,150,20, &sb->infrict, 0.0,  10.0, 10, 0, "Edge Friction Constant");
+                       uiBlockEndAlign(block);
+               }
        }
        uiBlockEndAlign(block);
 
index 957d4e988d262ec78408cf2041974cdb0940cdd7..2debd4aee676604e1cf8518309e24808b49e054e 100644 (file)
@@ -58,6 +58,7 @@
 #include "DNA_meshdata_types.h"
 #include "DNA_meta_types.h"
 #include "DNA_object_types.h"
+#include "DNA_object_force.h"
 #include "DNA_space_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
index 89f21c471c572dcc0f7d589c496f11804a5dc1e0..9af2580c26b0316f292ca79a33185d5ec3e233ea 100644 (file)
@@ -73,6 +73,7 @@
 #include "DNA_meshdata_types.h"
 #include "DNA_meta_types.h"
 #include "DNA_object_types.h"
+#include "DNA_object_force.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_texture_types.h"
index d206b3bd860625478243f0278fc9a4dab9bd6479..734361a47e301b794b45f5888ed4a7ab685a219e 100644 (file)
@@ -542,6 +542,7 @@ void uiTextBoundsBlock(uiBlock *block, int addval)
 void uiBoundsBlock(uiBlock *block, int addval)
 {
        uiBut *bt;
+       int xof;
        
        if(block->buttons.first==NULL) {
                if(block->panel) {
@@ -571,10 +572,15 @@ void uiBoundsBlock(uiBlock *block, int addval)
                block->maxy += addval;
        }
 
-       block->safety.xmin= block->minx-40;
-       block->safety.ymin= block->miny-40;
-       block->safety.xmax= block->maxx+40;
-       block->safety.ymax= block->maxy+40;
+       /* hardcoded exception... but that one is annoying with larger safety */ 
+       bt= block->buttons.first;
+       if(bt && strncmp(bt->str, "ERROR", 5)==0) xof= 10;
+       else xof= 40;
+       
+       block->safety.xmin= block->minx-xof;
+       block->safety.ymin= block->miny-xof;
+       block->safety.xmax= block->maxx+xof;
+       block->safety.ymax= block->maxy+xof;
 }
 
 static void ui_positionblock(uiBlock *block, uiBut *but)
index 813ec2d749ee5b3a25132492b9cd99da1ca666e8..dadfbf0f0b23bb3997434082b2ed84f4590926ca 100644 (file)
@@ -4487,7 +4487,7 @@ void allqueue(unsigned short event, short val)
                /* dependency check.maybe not final pos */
                if (sa->spacetype==SPACE_VIEW3D) {
                        if (G.scene->dagisvalid == 0) {
-                               fprintf(stderr,"building dag \n");
+//                             fprintf(stderr,"building dag \n");
                                G.scene->theDag = build_dag(G.scene, DAG_RL_ALL_BUT_DATA_MASK);
                                G.scene->dagisvalid = 1;
                        }
index 35704851d743d441e926b74d4378ed4c35fb3300..8d711054a512e0f418ff96133c3d81f28ef3a5a7 100644 (file)
@@ -54,6 +54,7 @@
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
+#include "DNA_object_force.h"
 #include "DNA_screen_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_view3d_types.h"