Added baking for softbodies.
[blender.git] / source / blender / src / buttons_editing.c
index 4312e413de7e4c3343baaf8374209d8a741b5019..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"
@@ -1095,21 +1096,23 @@ void do_curvebuts(unsigned short event)
                }
                /* fallthrough */
        case B_MAKEDISP:
-               if(ob->type==OB_FONT) text_to_curve(ob, 0);
-               makeDispList(ob);
-               if(ob!=G.obedit) { // subsurf with linked dupli will crash
-                       /* we need signal to send to other users of same data to recalc... */
-                       base= FIRSTBASE;
-                       while(base) {
-                               if(base->lay & G.vd->lay) {
-                                       if(base->object->data==ob->data && base->object!=ob)
-                                               makeDispList(base->object);
+               if(G.vd) {
+                       if(ob->type==OB_FONT) text_to_curve(ob, 0);
+                       makeDispList(ob);
+                       if(ob!=G.obedit) { // subsurf with linked dupli will crash
+                               /* we need signal to send to other users of same data to recalc... */
+                               base= FIRSTBASE;
+                               while(base) {
+                                       if(base->lay & G.vd->lay) {
+                                               if(base->object->data==ob->data && base->object!=ob)
+                                                       makeDispList(base->object);
+                                       }
+                                       base= base->next;
                                }
-                               base= base->next;
                        }
+                       allqueue(REDRAWVIEW3D, 0);
+                       allqueue(REDRAWINFO, 1);        /* 1, because header->win==0! */
                }
-               allqueue(REDRAWVIEW3D, 0);
-               allqueue(REDRAWINFO, 1);        /* 1, because header->win==0! */
                break;
 
        case B_SUBDIVCURVE:
@@ -1118,8 +1121,7 @@ void do_curvebuts(unsigned short event)
        case B_SPINNURB:
                /* bad bad bad!!! use brackets!!! In case you wondered:
                  {==,!=} goes before & goes before || */
-               if( (G.obedit==0) ||
-                   (G.obedit->type!=OB_SURF) ||
+               if( (G.obedit==NULL) || (G.obedit->type!=OB_SURF) || (G.vd==NULL) ||
                        ((G.obedit->lay & G.vd->lay) == 0) ) return;
                spinNurb(0, 0);
                countall();
@@ -1343,10 +1345,10 @@ static void editing_panel_camera_type(Object *ob, Camera *cam)
 
        uiDefButF(block, NUM,REDRAWVIEW3D, "DrawSize:", 470,90,160,20, &cam->drawsize, 0.1*grid, 10.0, 10, 0, "Specify the drawsize of the camera");
 
-       uiDefButS(block, TOG, REDRAWVIEW3D, "Ortho", 470,49,61,40, &cam->type, 0, 0, 0, 0, "Render orthogonally");
+       uiDefButS(block, TOG, REDRAWVIEW3D, "Ortho",            470,29,61,60, &cam->type, 0, 0, 0, 0, "Render orthogonally");
        uiBlockBeginAlign(block);
-       uiDefButS(block, TOG|BIT|0,REDRAWVIEW3D, "ShowLimits", 533,69,97,20, &cam->flag, 0, 0, 0, 0, "Draw the field of view");
-       uiDefButS(block, TOG|BIT|1,REDRAWVIEW3D, "Show Mist", 533,49,97,20, &cam->flag, 0, 0, 0, 0, "Draw a line that indicates the mist area");
+       uiDefButS(block, TOG|BIT|0,REDRAWVIEW3D, "ShowLimits", 533,59,97,30, &cam->flag, 0, 0, 0, 0, "Draw the field of view");
+       uiDefButS(block, TOG|BIT|1,REDRAWVIEW3D, "Show Mist",  533,29,97,30, &cam->flag, 0, 0, 0, 0, "Draw a line that indicates the mist area");
        uiBlockEndAlign(block);
 }
 
@@ -1378,6 +1380,23 @@ static void editing_panel_camera_yafraydof(Object *ob, Camera *cam)
 
 }
 
+/* **************************** CAMERA *************************** */
+
+void do_cambuts(unsigned short event)
+{
+       Object *ob;
+       Camera *cam;
+       
+       ob= OBACT;
+       if (ob==0) return;
+       cam= ob->data;
+
+       switch(event) {
+       case 0:
+               ;
+               break;
+       }
+}
 
 /* *************************** MBALL ******************************** */
 
@@ -1820,14 +1839,14 @@ static void editing_panel_armature_bones(Object *ob, bArmature *arm)
 
                        uiDefBut(block, LABEL, 0, "child of", bx+107,by,73,18, NULL, 0.0, 0.0, 0.0, 0.0, "");
 
-                       boneString = malloc((BLI_countlist(&G.edbo) * 64)+64);
+                       boneString = MEM_mallocN((BLI_countlist(&G.edbo) * 64)+64, "Bone str");
                        build_bonestring (boneString, curBone);
 
                        curBone->parNr = editbone_to_parnr(curBone->parent);
                        but = uiDefButI(block, MENU,REDRAWVIEW3D, boneString, bx+180,by,120,18, &curBone->parNr, 0.0, 0.0, 0.0, 0.0, "Parent");
                        uiButSetFunc(but, parnr_to_editbone_cb, curBone, NULL);
 
-                       free(boneString);
+                       MEM_freeN(boneString);
 
                        /* IK to parent flag */
                        if (curBone->parent){
@@ -2165,6 +2184,49 @@ static void editing_panel_mesh_tools1(Object *ob, Mesh *me)
 
 }
 
+char *get_vertexgroup_menustr(Object *ob)
+{
+       bDeformGroup *dg;
+       int defCount, min, index;
+       char (*qsort_ptr)[32] = NULL;
+       char *s, *menustr;
+       
+       defCount=BLI_countlist(&ob->defbase);
+       
+       if (!defCount) min=0;
+       else min=1;
+       
+       if (defCount > 0) {
+               /*
+                * This will hold the group names temporarily
+                * so we can sort them
+                */
+               qsort_ptr = MEM_callocN (defCount * sizeof (qsort_ptr[0]),
+                                                                "qsort_ptr");
+               for (index = 1, dg = ob->defbase.first; dg; index++, dg=dg->next) {
+                       snprintf (qsort_ptr[index - 1], sizeof (qsort_ptr[0]),
+                                         "%s%%x%d|", dg->name, index);
+               }
+               
+               qsort (qsort_ptr, defCount, sizeof (qsort_ptr[0]),
+                          ( int (*)(const void *, const void *) ) strcmp);
+       }
+       
+       s= menustr = MEM_callocN((32 * defCount)+30, "menustr");        // plus 30 for when defCount==0
+       if(defCount) {
+               for (index = 0; index < defCount; index++) {
+                       int cnt= sprintf (s, "%s", qsort_ptr[index]);
+                       if (cnt>0) s+= cnt;
+               }
+       }
+       else strcpy(menustr, "No Vertex Groups in Object");
+       
+       if (qsort_ptr)
+               MEM_freeN (qsort_ptr);
+       
+       return menustr;
+}
+
 static void editing_panel_links(Object *ob)
 {
        uiBlock *block;
@@ -2264,52 +2326,20 @@ static void editing_panel_links(Object *ob)
                uiBut *but;
                int     defCount;
                bDeformGroup    *defGroup;
-               char *s, *menustr;
-               bDeformGroup *dg;
-               int min, index;
-               char (*qsort_ptr)[32] = NULL;
-
+       
                uiDefBut(block, LABEL,0,"Vertex Groups",
                                 143,153,130,20, 0, 0, 0, 0, 0, "");
 
                defCount=BLI_countlist(&ob->defbase);
 
-               if (!defCount) min=0;
-               else min=1;
-
-               if (defCount > 0) {
-                       /*
-                        * This will hold the group names temporarily
-                        * so we can sort them
-                        */
-                       qsort_ptr = MEM_callocN (defCount * sizeof (qsort_ptr[0]),
-                                                                        "qsort_ptr");
-                       for (index = 1, dg = ob->defbase.first; dg; index++, dg=dg->next) {
-                               snprintf (qsort_ptr[index - 1], sizeof (qsort_ptr[0]),
-                                                 "%s%%x%d|", dg->name, index);
-                       }
-
-                       qsort (qsort_ptr, defCount, sizeof (qsort_ptr[0]),
-                                  ( int (*)(const void *, const void *) ) strcmp);
-               }
-
-               s= menustr = MEM_callocN((32 * defCount)+20, "menustr");
-               for (index = 0; index < defCount; index++) {
-                       int cnt= sprintf (s, "%s", qsort_ptr[index]);
-                       if (cnt>0) s+= cnt;
-               }
-
-               if (qsort_ptr)
-                 MEM_freeN (qsort_ptr);
-
                uiBlockBeginAlign(block);
-               if (defCount)
-                       uiDefButS(block, MENU, REDRAWBUTSEDIT, menustr,
-                                         143, 132,18,21, &ob->actdef, min, defCount, 0, 0,
-                                         "Browses available vertex groups");
-
-               MEM_freeN (menustr);
-
+               if (defCount) {
+                       char *menustr= get_vertexgroup_menustr(ob);
+                       
+                       uiDefButS(block, MENU, REDRAWBUTSEDIT, menustr, 143, 132,18,21, &ob->actdef, 1, defCount, 0, 0, "Browses available vertex groups");
+                       MEM_freeN (menustr);
+               }
+               
                if (ob->actdef){
                        defGroup = BLI_findlink(&ob->defbase, ob->actdef-1);
                        but= uiDefBut(block, TEX,REDRAWBUTSEDIT,"",             161,132,140-18,21, defGroup->name, 0, 32, 0, 0, "Displays current vertex group name. Click to change. (Match bone name for deformation.)");