The zblur plugin (aka as DoF) integrated in render. Compared to patch
[blender.git] / source / blender / src / buttons_editing.c
index 6bb4c647901ec2847bd5bfc6dbb27129015b6823..c55574d97915216243799134c32ca05ef883cbed 100644 (file)
@@ -656,7 +656,7 @@ static void editing_panel_mesh_type(Object *ob, Mesh *me)
        uiBlock *block;
        float val;
        /* Hope to support more than two subsurf algorithms */
-       char subsurfmenu[]="Subsurf Type%t|Catmull-Clark%x0|CCGSubSurf%x2|Simple Subdiv.%x1";
+       char subsurfmenu[]="Subsurf Type%t|Catmull-Clark%x0|Simple Subdiv.%x1";
 
        block= uiNewBlock(&curarea->uiblocks, "editing_panel_mesh_type", UI_EMBOSS, UI_HELV, curarea->win);
        if( uiNewPanel(curarea, block, "Mesh", "Editing", 320, 0, 318, 204)==0) return;
@@ -1095,21 +1095,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 +1120,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 +1344,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 +1379,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 ******************************** */
 
@@ -1402,17 +1420,17 @@ static void editing_panel_mball_type(Object *ob, MetaBall *mb)
        mb= ob->data;
 
        uiBlockBeginAlign(block);
-       uiDefButF(block, NUM, B_RECALCMBALL, "Wiresize:",       470,178,250,19, &mb->wiresize, 0.05, 1.0, 0, 0, "Polygonization resolution in 3d window");
-       uiDefButF(block, NUM, 0, "Rendersize:",                 470,158,250,19, &mb->rendersize, 0.05, 1.0, 0, 0, "Polygonization resolution in rendering");
-       uiDefButF(block, NUM, B_RECALCMBALL, "Threshold:", 470,138,250,19, &mb->thresh, 0.0001, 5.0, 0, 0, "Defines influence of meta elements");
+       uiDefButF(block, NUM, B_RECALCMBALL, "Wiresize:", 470,178,250,19, &mb->wiresize, 0.05, 1.0, 1, 0, "Polygonization resolution in 3d window");
+       uiDefButF(block, NUM, 0, "Rendersize:", 470,158,250,19, &mb->rendersize, 0.05, 1.0, 1, 0, "Polygonization resolution in rendering");
+       uiDefButF(block, NUM, B_RECALCMBALL, "Threshold:", 470,138,250,19, &mb->thresh, 0.0001, 5.0, 1, 0, "Defines influence of meta elements");
 
        uiBlockBeginAlign(block);
        uiBlockSetCol(block, TH_BUT_SETTING1);
-       uiDefBut(block, LABEL, 0, "Update:",            471,108,120,19, 0, 0, 0, 0, 0, "");
+       uiDefBut(block, LABEL, 0, "Update:", 471,108,120,19, 0, 0, 0, 0, 0, "");
        uiDefButS(block, ROW, B_DIFF, "Always", 471, 85, 120, 19, &mb->flag, 0.0, 0.0, 0, 0, "While editing, always updates");
-       uiDefButS(block, ROW, B_DIFF, "Half Res",       471, 65, 120, 19, &mb->flag, 0.0, 1.0, 0, 0, "While editing, updates in half resolution");
-       uiDefButS(block, ROW, B_DIFF, "Fast",           471, 45, 120, 19, &mb->flag, 0.0, 2.0, 0, 0, "While editing, updates without polygonization");
-       uiDefButS(block, ROW, B_DIFF, "Never",          471, 25, 120, 19, &mb->flag, 0.0, 3.0, 0, 0, "While editing, doesn't update");
+       uiDefButS(block, ROW, B_DIFF, "Half Res", 471, 65, 120, 19, &mb->flag, 0.0, 1.0, 0, 0, "While editing, updates in half resolution");
+       uiDefButS(block, ROW, B_DIFF, "Fast", 471, 45, 120, 19, &mb->flag, 0.0, 2.0, 0, 0, "While editing, updates without polygonization");
+       uiDefButS(block, ROW, B_DIFF, "Never", 471, 25, 120, 19, &mb->flag, 0.0, 3.0, 0, 0, "While editing, doesn't update");
 
 }
 
@@ -1426,22 +1444,22 @@ static void editing_panel_mball_tools(Object *ob, MetaBall *mb)
 
        if(ob==G.obedit && lastelem) {
                uiBlockBeginAlign(block);
-               uiDefButF(block, NUM, B_RECALCMBALL, "Stiffness:", 750,178,250,19, &lastelem->s, 0.0, 10.0, 0, 0, "Stiffness for active meta");
+               uiDefButF(block, NUM, B_RECALCMBALL, "Stiffness:", 750,178,250,19, &lastelem->s, 0.0, 10.0, 1, 0, "Stiffness for active meta");
                if(lastelem->type!=MB_BALL)
-               uiDefButF(block, NUM, B_RECALCMBALL, "dx:",             750,158,250,19, &lastelem->expx, 0.0, 20.0, 0, 0, "X size for active meta");
+               uiDefButF(block, NUM, B_RECALCMBALL, "dx:", 750,158,250,19, &lastelem->expx, 0.0, 20.0, 1, 0, "X size for active meta");
                if((lastelem->type!=MB_BALL)&&(lastelem->type!=MB_TUBE))
-               uiDefButF(block, NUM, B_RECALCMBALL, "dy:",             750,138,250,19, &lastelem->expy, 0.0, 20.0, 0, 0, "Y size for active meta");
+               uiDefButF(block, NUM, B_RECALCMBALL, "dy:", 750,138,250,19, &lastelem->expy, 0.0, 20.0, 1, 0, "Y size for active meta");
 
                if((lastelem->type==MB_CUBE)||(lastelem->type==MB_ELIPSOID))
-               uiDefButF(block, NUM, B_RECALCMBALL, "dz:",             750,118,250,19, &lastelem->expz, 0.0, 20.0, 0, 0, "Z size for active meta");
+               uiDefButF(block, NUM, B_RECALCMBALL, "dz:", 750,118,250,19, &lastelem->expz, 0.0, 20.0, 1, 0, "Z size for active meta");
                uiBlockEndAlign(block);
 
-               uiDefButS(block, ROW, B_RECALCMBALL, "Ball",                    753,83,60,19, &lastelem->type, 1.0, 0.0, 0, 0, "Draw active meta as Ball");
+               uiDefButS(block, ROW, B_RECALCMBALL, "Ball", 753,83,60,19, &lastelem->type, 1.0, 0.0, 0, 0, "Draw active meta as Ball");
                uiBlockBeginAlign(block);
-               uiDefButS(block, ROW, B_RECALCMBALL, "Tube",                    753,62,60,19, &lastelem->type, 1.0, 4.0, 0, 0, "Draw active meta as Ball");
-               uiDefButS(block, ROW, B_RECALCMBALL, "Plane",                   814,62,60,19, &lastelem->type, 1.0, 5.0, 0, 0, "Draw active meta as Plane");
-               uiDefButS(block, ROW, B_RECALCMBALL, "Elipsoid",                876,62,60,19, &lastelem->type, 1.0, 6.0, 0, 0, "Draw active meta as Ellipsoid");
-               uiDefButS(block, ROW, B_RECALCMBALL, "Cube",                    938,62,60,19, &lastelem->type, 1.0, 7.0, 0, 0, "Draw active meta as Cube");
+               uiDefButS(block, ROW, B_RECALCMBALL, "Tube", 753,62,60,19, &lastelem->type, 1.0, 4.0, 0, 0, "Draw active meta as Ball");
+               uiDefButS(block, ROW, B_RECALCMBALL, "Plane", 814,62,60,19, &lastelem->type, 1.0, 5.0, 0, 0, "Draw active meta as Plane");
+               uiDefButS(block, ROW, B_RECALCMBALL, "Elipsoid", 876,62,60,19, &lastelem->type, 1.0, 6.0, 0, 0, "Draw active meta as Ellipsoid");
+               uiDefButS(block, ROW, B_RECALCMBALL, "Cube", 938,62,60,19, &lastelem->type, 1.0, 7.0, 0, 0, "Draw active meta as Cube");
                uiBlockEndAlign(block);
 
                uiBlockBeginAlign(block);
@@ -1469,6 +1487,7 @@ void do_latticebuts(unsigned short event)
                if(ob) {
                        if(ob==G.obedit) resizelattice(editLatt);
                        else resizelattice(ob->data);
+                       ob->softflag |= OB_SB_REDO;
                }
                allqueue(REDRAWVIEW3D, 0);
                break;
@@ -1819,14 +1838,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){
@@ -2164,6 +2183,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;
@@ -2263,52 +2325,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.)");