Added baking for softbodies.
[blender.git] / source / blender / src / buttons_editing.c
index 33021c7d17f6d702f7c1aff0dfe6aa41f0177a00..d48d933f99b2f761e592e74027215a71ce34fb12 100644 (file)
@@ -40,7 +40,6 @@
 #endif
 
 #ifdef WIN32
-#include "BLI_winstuff.h"
 #ifndef snprintf
 #define snprintf _snprintf
 #endif
@@ -68,9 +67,9 @@
 #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_sound_types.h"
 #include "DNA_texture_types.h"
 #include "DNA_userdef_types.h"
 #include "DNA_vfont_types.h"
@@ -96,8 +95,8 @@
 #include "BIF_editdeform.h"
 #include "BIF_editfont.h"
 #include "BIF_editmesh.h"
-#include "BIF_editsound.h"
 #include "BIF_interface.h"
+#include "BIF_meshtools.h"
 #include "BIF_mywindow.h"
 #include "BIF_renderwin.h"
 #include "BIF_resources.h"
 #include "BKE_constraint.h"
 #include "BKE_curve.h"
 #include "BKE_displist.h"
+#include "BKE_DerivedMesh.h"
 #include "BKE_effect.h"
 #include "BKE_font.h"
 #include "BKE_ika.h"
 #include "BKE_mball.h"
 #include "BKE_mesh.h"
 #include "BKE_object.h"
-#include "BKE_sound.h"
 #include "BKE_texture.h"
 #include "BKE_utildefines.h"
 
 #include "BDR_editface.h"
 #include "BDR_editobject.h"
 #include "BDR_vpaint.h"
+#include "BDR_unwrapper.h"
 
 #include "BSE_drawview.h"
 #include "BSE_editipo.h"
 #include "LOD_DependKludge.h"
 #include "LOD_decimation.h"
 
+#include "RE_renderconverter.h"                // make_sticky
+
 #include "butspace.h" // own module
 
 static int decim_faces=0;
@@ -164,6 +166,10 @@ short uv_calc_mapdir= 1, uv_calc_mapalign= 1, facesel_draw_edges= 0;
 
 extern ListBase editNurb;
 
+
+/* *************************** static functions prototypes ****************** */
+void validate_editbonebutton(EditBone *);
+
 /* *************************** MESH DECIMATE ******************************** */
 
 /* should be removed from this c file (ton) */
@@ -206,8 +212,8 @@ static void decimate_faces(void)
        me= ob->data;
 
        /* add warning for vertex col and tfaces */
-       if(me->tface || me->mcol || me->dvert) {
-               if(okee("This will remove UV coordinates, vertexcolors, and deform weights")==0) return;
+       if(me->tface || me->mcol || me->dvert || me->medge) {
+               if(okee("This will remove UV coordinates, vertexcolors, deform weights and edge data")==0) return;
                if(me->tface) MEM_freeN(me->tface);
                if(me->mcol) MEM_freeN(me->mcol);
                if(me->dvert) free_dverts(me->dvert, me->totvert);
@@ -260,7 +266,6 @@ static void decimate_faces(void)
 
        if(LOD_LoadMesh(&lod) ) {
                if( LOD_PreprocessMesh(&lod) ) {
-                       DispList *dl;
                        DispListMesh *dlm;
                        MFace *mfaceint;
 
@@ -271,11 +276,11 @@ static void decimate_faces(void)
                        }
 
                        /* ok, put back the stuff in a displist */
-                       freedisplist(&(ob->disp));
-                       dl= MEM_callocN(sizeof(DispList), "disp");
-                       BLI_addtail(&ob->disp, dl);
-                       dl->type= DL_MESH;
-                       dlm=dl->mesh= MEM_callocN(sizeof(DispListMesh), "dispmesh");
+                       if (me->decimated) {
+                               displistmesh_free(me->decimated);
+                       }
+
+                       dlm= me->decimated= MEM_callocN(sizeof(DispListMesh), "dispmesh");
                        dlm->mvert= MEM_callocN(lod.vertex_num*sizeof(MVert), "mvert");
                        dlm->mface= MEM_callocN(lod.face_num*sizeof(MFace), "mface");
                        dlm->totvert= lod.vertex_num;
@@ -316,8 +321,14 @@ static void decimate_cancel(void)
 
        ob= OBACT;
        if(ob) {
-               freedisplist(&ob->disp);
-               makeDispList(ob);
+               if (ob->type==OB_MESH) {
+                       Mesh *me = ob->data;
+                       
+                       if (me->decimated) {
+                               displistmesh_free(me->decimated);
+                               me->decimated = NULL;
+                       }
+               }
        }
        allqueue(REDRAWVIEW3D, 0);
 }
@@ -325,9 +336,6 @@ static void decimate_cancel(void)
 static void decimate_apply(void)
 {
        Object *ob;
-       DispList *dl;
-       DispListMesh *dlm;
-       Mesh *me;
        MFace *mface;
        MFace *mfaceint;
        int a;
@@ -335,11 +343,11 @@ static void decimate_apply(void)
        if(G.obedit) return;
 
        ob= OBACT;
-       if(ob) {
-               dl= ob->disp.first;
-               if(dl && dl->mesh) {
-                       dlm= dl->mesh;
-                       me= ob->data;
+       if(ob && ob->type==OB_MESH) {
+               Mesh *me = ob->data;
+
+               if (me->decimated) {
+                       DispListMesh *dlm= me->decimated;
 
                        // vertices
                        if(me->mvert) MEM_freeN(me->mvert);
@@ -347,6 +355,11 @@ static void decimate_apply(void)
                        dlm->mvert= NULL;
                        me->totvert= dlm->totvert;
 
+                       // edges
+                       if(me->medge) MEM_freeN(me->medge);
+                       me->medge = NULL;
+                       me->totedge = 0;
+
                        // faces
                        if(me->mface) MEM_freeN(me->mface);
                        me->mface= MEM_callocN(dlm->totface*sizeof(MFace), "mface");
@@ -360,18 +373,20 @@ static void decimate_apply(void)
                                test_index_mface(mface, 3);
                        }
 
-                       freedisplist(&ob->disp);
+                       displistmesh_free(me->decimated);
+                       me->decimated= NULL;
 
                        G.obedit= ob;
                        make_editMesh();
                        load_editMesh();
-                       free_editMesh();
+                       free_editMesh(G.editMesh);
                        G.obedit= NULL;
                        tex_space_mesh(me);
 
                        if (mesh_uses_displist(me)) {
                                makeDispList(ob);
                        }
+                       BIF_undo_push("Apply decimation");
                }
                else error("Not a decimated Mesh");
        }
@@ -382,7 +397,7 @@ static void decimate_apply(void)
 void do_common_editbuts(unsigned short event) // old name, is a mix of object and editing events.... 
 {
        EditMesh *em = G.editMesh;
-       EditVlak *evl;
+       EditFace *efa;
        Base *base;
        Object *ob;
        Mesh *me;
@@ -398,16 +413,16 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
        case B_MATWICH:
                if(G.obedit && G.obedit->actcol>0) {
                        if(G.obedit->type == OB_MESH) {
-                               evl= em->faces.first;
-                               while(evl) {
-                                       if( vlakselectedAND(evl, 1) ) {
-                                               if(index== -1) index= evl->mat_nr;
-                                               else if(index!=evl->mat_nr) {
+                               efa= em->faces.first;
+                               while(efa) {
+                                       if(efa->f & SELECT) {
+                                               if(index== -1) index= efa->mat_nr;
+                                               else if(index!=efa->mat_nr) {
                                                        error("Mixed colors");
                                                        return;
                                                }
                                        }
-                                       evl= evl->next;
+                                       efa= efa->next;
                                }
                        }
                        else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) {
@@ -432,25 +447,28 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
        case B_MATNEW:
                new_material_to_objectdata((G.scene->basact) ? (G.scene->basact->object) : 0);
                scrarea_queue_winredraw(curarea);
+               BIF_undo_push("New material");
+               allqueue(REDRAWBUTSSHADING, 0);
                allqueue(REDRAWVIEW3D_Z, 0);
+               allqueue(REDRAWOOPS, 0);
                break;
        case B_MATDEL:
                delete_material_index();
                scrarea_queue_winredraw(curarea);
+               BIF_undo_push("Delete material index");
+               allqueue(REDRAWBUTSSHADING, 0);
                allqueue(REDRAWVIEW3D_Z, 0);
+               allqueue(REDRAWOOPS, 0);
                break;
        case B_MATASS:
                if(G.obedit && G.obedit->actcol>0) {
                        if(G.obedit->type == OB_MESH) {
-                               undo_push_mesh("Assign material index");
-                               evl= em->faces.first;
-                               while(evl) {
-                                       if( vlakselectedAND(evl, 1) )
-                                               evl->mat_nr= G.obedit->actcol-1;
-                                       evl= evl->next;
+                               efa= em->faces.first;
+                               while(efa) {
+                                       if(efa->f & SELECT)
+                                               efa->mat_nr= G.obedit->actcol-1;
+                                       efa= efa->next;
                                }
-                               allqueue(REDRAWVIEW3D_Z, 0);
-                               makeDispList(G.obedit);
                        }
                        else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) {
                                nu= editNurb.first;
@@ -460,6 +478,9 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
                                        nu= nu->next;
                                }
                        }
+                       allqueue(REDRAWVIEW3D_Z, 0);
+                       makeDispList(G.obedit);
+                       BIF_undo_push("Assign material index");
                }
                break;
        case B_MATSEL:
@@ -510,6 +531,7 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
                                        }
                                        nu= nu->next;
                                }
+                               BIF_undo_push("Select material index");
                                allqueue(REDRAWVIEW3D, 0);
                        }
                }
@@ -543,7 +565,7 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
                }
                break;
        case B_DOCENTRE:
-               docentre();
+               docentre(0);
                break;
        case B_DOCENTRENEW:
                docentre_new();
@@ -555,31 +577,27 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
        case B_SETSOLID:
                if(G.obedit) {
                        if(G.obedit->type == OB_MESH) {
-                               evl= em->faces.first;
-                               if (event == B_SETSMOOTH) undo_push_mesh("Set Smooth");
-                               else if (event==B_SETSOLID) undo_push_mesh("Set Solid");
-                               while(evl) {
-                                       if( vlakselectedAND(evl, 1) ) {
-                                               if(event==B_SETSMOOTH) evl->flag |= ME_SMOOTH;
-                                               else evl->flag &= ~ME_SMOOTH;
+                               efa= em->faces.first;
+                               while(efa) {
+                                       if(efa->f & SELECT) {
+                                               if(event==B_SETSMOOTH) efa->flag |= ME_SMOOTH;
+                                               else efa->flag &= ~ME_SMOOTH;
                                        }
-                                       evl= evl->next;
+                                       efa= efa->next;
                                }
-
-                               makeDispList(G.obedit);
-                               allqueue(REDRAWVIEW3D, 0);
                        }
                        else {
                                nu= editNurb.first;
                                while(nu) {
                                        if(isNurbsel(nu)) {
-                                               if(event==B_SETSMOOTH) nu->flag |= ME_SMOOTH;
-                                               else nu->flag &= ~ME_SMOOTH;
+                                               if(event==B_SETSMOOTH) nu->flag |= CU_SMOOTH;
+                                               else nu->flag &= ~CU_SMOOTH;
                                        }
                                        nu= nu->next;
                                }
-                               
                        }
+                       makeDispList(G.obedit);
+                       allqueue(REDRAWVIEW3D, 0);
                }
                else {
                        base= FIRSTBASE;
@@ -598,12 +616,16 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
                                                        else nu->flag &= ~ME_SMOOTH;
                                                        nu= nu->next;
                                                }
+                                               makeDispList(base->object);
                                        }
                                }
                                base= base->next;
                        }
                        allqueue(REDRAWVIEW3D, 0);
                }
+               if(event == B_SETSMOOTH) BIF_undo_push("Set Smooth");
+               else BIF_undo_push("Set Solid");
+
                break;
 
        default:
@@ -641,17 +663,17 @@ static void editing_panel_mesh_type(Object *ob, Mesh *me)
        if( uiNewPanel(curarea, block, "Mesh", "Editing", 320, 0, 318, 204)==0) return;
 
        uiBlockBeginAlign(block);
-       uiDefButS(block, TOG|BIT|5, REDRAWVIEW3D, "Auto Smooth",10,180,154,19, &me->flag, 0, 0, 0, 0, "Treats all faces with angles less than Degr: as 'smooth' during render");
+       uiDefButS(block, TOG|BIT|5, REDRAWVIEW3D, "Auto Smooth",10,180,154,19, &me->flag, 0, 0, 0, 0, "Treats all set-smoothed faces with angles less than Degr: as 'smooth' during render");
        uiDefButS(block, NUM, B_DIFF, "Degr:",                          10,160,154,19, &me->smoothresh, 1, 80, 0, 0, "Defines maximum angle between face normals that 'Auto Smooth' will operate on");
 
        uiBlockBeginAlign(block);
        uiBlockSetCol(block, TH_BUT_SETTING1);
-       uiDefButS(block, TOG|BIT|7, B_MAKEDISP, "SubSurf",      10,134,70,19, &me->flag, 0, 0, 0, 0, "Treats the active object as a Subdivision Surface");
-       uiDefButS(block, MENU, B_MAKEDISP, subsurfmenu,         80,134,84,19, &(me->subsurftype), 0, 0, 0, 0, "Selects type of Subsurf algorithm.");
+       uiDefButS(block, TOG|BIT|7, B_SUBSURFTYPE, "SubSurf",   10,134,70,19, &me->flag, 0, 0, 0, 0, "Treats the active object as a Subdivision Surface");
+       uiDefButS(block, MENU, B_SUBSURFTYPE, subsurfmenu,              80,134,84,19, &(me->subsurftype), 0, 0, 0, 0, "Selects type of Subsurf algorithm.");
        uiBlockSetCol(block, TH_AUTO);
-       uiDefButS(block, NUM, B_MAKEDISP, "Subdiv:",            10, 114,110,19, &me->subdiv, 0, 6, 0, 0, "Defines the level of subdivision to display in real time interactively");
+       uiDefButS(block, NUM, B_SUBSURFTYPE, "Subdiv:",         10, 114,110,19, &me->subdiv, 0, 6, 0, 0, "Defines the level of subdivision to display in real time interactively");
        uiDefButS(block, NUM, B_DIFF, "",                               120,114, 44, 19, &me->subdivr, 0, 6, 0, 0, "Defines the level of subdivision to apply during rendering");
-       uiDefButS(block, TOG|BIT|8, B_MAKEDISP, "Optimal",      10, 94,154,19, &me->flag, 0, 0, 0, 0, "Only draws optimal wireframe");
+       uiDefButS(block, TOG|BIT|8, B_SUBSURFTYPE, "Optimal",   10, 94,154,19, &me->flag, 0, 0, 0, 0, "Only draws optimal wireframe");
 
        uiBlockBeginAlign(block);
 
@@ -675,7 +697,6 @@ static void editing_panel_mesh_type(Object *ob, Mesh *me)
                uiDefBut(block, BUT, B_MAKE_TFACES, "Make",             80,30,84,19, 0, 0, 0, 0, 0, "Enables the active object's faces for UV coordinate mapping");
        }
        else uiDefBut(block, BUT, B_DEL_TFACES, "Delete",       80,30,84,19, 0, 0, 0, 0, 0, "Deletes UV coordinates for active object's faces");
-       uiBlockEndAlign(block);
 
        if(me->msticky) val= 1.0; else val= 0.0;
        uiDefBut(block, LABEL, 0, "Sticky",                             10,10,70,20, 0, val, 0, 0, 0, "");
@@ -684,15 +705,16 @@ static void editing_panel_mesh_type(Object *ob, Mesh *me)
        }
        else uiDefBut(block, BUT, B_DELSTICKY, "Delete",        80,10,84,19, 0, 0, 0, 0, 0, "Deletes Sticky texture coordinates");
 
+       uiBlockEndAlign(block);
 
        /* decimator */
        if(G.obedit==NULL) {
                int tottria= decimate_count_tria(ob);
-               DispList *dl;
+               Mesh *me = ob->data;
 
-               // wacko, wait for new displist system (ton)
-               if( (dl=ob->disp.first) && dl->mesh);
-               else decim_faces= tottria;
+               if (!me->decimated) {
+                       decim_faces= tottria;
+               }
 
                uiBlockBeginAlign(block);
                uiBlockSetCol(block, TH_BUT_SETTING1);
@@ -823,6 +845,7 @@ static void load_buts_vfont(char *name)
 
        text_to_curve(OBACT, 0);
        makeDispList(OBACT);
+       BIF_undo_push("Load vector font");
        allqueue(REDRAWVIEW3D, 0);
        allqueue(REDRAWBUTSEDIT, 0);
 }
@@ -895,6 +918,7 @@ void do_fontbuts(unsigned short event)
                                cu->vfont= vf;
                                text_to_curve(ob, 0);
                                makeDispList(ob);
+                               BIF_undo_push("Set vector font");
                                allqueue(REDRAWVIEW3D, 0);
                                allqueue(REDRAWBUTSEDIT, 0);
                        }
@@ -1062,20 +1086,33 @@ void do_curvebuts(unsigned short event)
                        allqueue(REDRAWVIEW3D, 0);
                }
                break;
+       case B_SUBSURFTYPE:
+                       /* Icky, find better system */
+               if(ob->type==OB_MESH && G.obedit && ob->data==G.obedit->data) {
+                       if(G.editMesh->derived) {
+                               G.editMesh->derived->release(G.editMesh->derived);
+                               G.editMesh->derived= NULL;
+                       }
+               }
+               /* fallthrough */
        case B_MAKEDISP:
-               if(ob->type==OB_FONT) text_to_curve(ob, 0);
-               makeDispList(ob);
-               /* 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:
@@ -1084,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();
@@ -1152,25 +1188,23 @@ static void editing_panel_curve_tools(Object *ob, Curve *cu)
        if(ob->type==OB_CURVE) {
                uiDefBut(block, LABEL, 0, "Convert",    463,173,72, 18, 0, 0, 0, 0, 0, "");
                uiBlockBeginAlign(block);
-               uiDefBut(block, BUT,B_CONVERTPOLY,"Poly",               467,152,72, 18, 0, 0, 0, 0, 0, "");
-               uiDefBut(block, BUT,B_CONVERTBEZ,"Bezier",      467,132,72, 18, 0, 0, 0, 0, 0, "");
-               uiDefBut(block, BUT,B_CONVERTBSPL,"Bspline",    467,112,72, 18, 0, 0, 0, 0, 0, "");
-               uiDefBut(block, BUT,B_CONVERTCARD,"Cardinal",   467,92,72, 18, 0, 0, 0, 0, 0, "");
-               uiDefBut(block, BUT,B_CONVERTNURB,"Nurb",               467,72,72, 18, 0, 0, 0, 0, 0, "");
+               uiDefBut(block, BUT,B_CONVERTPOLY,"Poly",               467,152,72, 18, 0, 0, 0, 0, 0, "Converts selected into regular Polygon vertices");
+               uiDefBut(block, BUT,B_CONVERTBEZ,"Bezier",              467,132,72, 18, 0, 0, 0, 0, 0, "Converts selected to Bezier triples");
+               uiDefBut(block, BUT,B_CONVERTNURB,"Nurb",               467,112,72, 18, 0, 0, 0, 0, 0, "Converts selected to Nurbs Points");
        }
        uiBlockBeginAlign(block);
-       uiDefBut(block, BUT,B_UNIFU,"Uniform U",        565,152,102, 18, 0, 0, 0, 0, 0, "");
-       uiDefBut(block, BUT,B_UNIFV,"V",                        670,152,50, 18, 0, 0, 0, 0, 0, "");
-       uiDefBut(block, BUT,B_ENDPU,"Endpoint U",       565,132,102, 18, 0, 0, 0, 0, 0, "");
-       uiDefBut(block, BUT,B_ENDPV,"V",                        670,132,50, 18, 0, 0, 0, 0, 0, "");
-       uiDefBut(block, BUT,B_BEZU,"Bezier U",          565,112,102, 18, 0, 0, 0, 0, 0, "");
-       uiDefBut(block, BUT,B_BEZV,"V",                         670,112,50, 18, 0, 0, 0, 0, 0, "");
+       uiDefBut(block, BUT,B_UNIFU,"Uniform U",        565,152,102, 18, 0, 0, 0, 0, 0, "Nurbs only; interpolated result doesn't go to end points in U");
+       uiDefBut(block, BUT,B_UNIFV,"V",                        670,152,50, 18, 0, 0, 0, 0, 0, "Nurbs only; interpolated result doesn't go to end points in V");
+       uiDefBut(block, BUT,B_ENDPU,"Endpoint U",       565,132,102, 18, 0, 0, 0, 0, 0, "Nurbs only; interpolated result is forced to end points in U");
+       uiDefBut(block, BUT,B_ENDPV,"V",                        670,132,50, 18, 0, 0, 0, 0, 0, "Nurbs only; interpolated result is forced to end points in V");
+       uiDefBut(block, BUT,B_BEZU,"Bezier U",          565,112,102, 18, 0, 0, 0, 0, 0, "Nurbs only; make knots array mimic a Bezier in U");
+       uiDefBut(block, BUT,B_BEZV,"V",                         670,112,50, 18, 0, 0, 0, 0, 0, "Nurbs only; make knots array mimic a Bezier in V");
        uiBlockEndAlign(block);
 
-       uiDefBut(block, BUT,B_SETWEIGHT,"Set Weight",   465,11,95,49, 0, 0, 0, 0, 0, "");
+       uiDefBut(block, BUT,B_SETWEIGHT,"Set Weight",   465,11,95,49, 0, 0, 0, 0, 0, "Nurbs only; set weight for select points");
 
        uiBlockBeginAlign(block);
-       uiDefButF(block, NUM,0,"Weight:",               565,36,102,22, &editbutweight, 0.01, 100.0, 10, 0, "");
+       uiDefButF(block, NUM,0,"Weight:",               565,36,102,22, &editbutweight, 0.01, 100.0, 10, 0, "The weight you can assign");
        uiDefBut(block, BUT,B_SETW1,"1.0",              670,36,50,22, 0, 0, 0, 0, 0, "");
        uiDefBut(block, BUT,B_SETW2,"sqrt(2)/4",565,11,55,20, 0, 0, 0, 0, 0, "");
        uiDefBut(block, BUT,B_SETW3,"0.25",             620,11,45,20, 0, 0, 0, 0, 0, "");
@@ -1183,13 +1217,13 @@ static void editing_panel_curve_tools(Object *ob, Curve *cu)
                if(nu) {
                        uiBlockBeginAlign(block);
                        sp= &(nu->orderu);
-                       uiDefButS(block, NUM, B_SETORDER, "Order U:", 565,90,102, 19, sp, 2.0, 6.0, 0, 0, "");
+                       uiDefButS(block, NUM, B_SETORDER, "Order U:", 565,90,102, 19, sp, 2.0, 6.0, 0, 0, "Nurbs only; the amount of control points involved");
                        sp= &(nu->orderv);
-                       uiDefButS(block, NUM, B_SETORDER, "V:",         670,90,50, 19, sp, 2.0, 6.0, 0, 0, "");
+                       uiDefButS(block, NUM, B_SETORDER, "V:",         670,90,50, 19, sp, 2.0, 6.0, 0, 0, "Nurbs only; the amount of control points involved");
                        sp= &(nu->resolu);
-                       uiDefButS(block, NUM, B_MAKEDISP, "Resol U:", 565,70,102, 19, sp, 1.0, 128.0, 0, 0, "");
+                       uiDefButS(block, NUM, B_MAKEDISP, "Resol U:", 565,70,102, 19, sp, 1.0, 1024.0, 0, 0, "The amount of new points interpolated per control vertex pair");
                        sp= &(nu->resolv);
-                       uiDefButS(block, NUM, B_MAKEDISP, "V:",         670,70,50, 19, sp, 1.0, 128.0, 0, 0, "");
+                       uiDefButS(block, NUM, B_MAKEDISP, "V:",         670,70,50, 19, sp, 1.0, 1024.0, 0, 0, "The amount of new points interpolated per control vertex pair");
                }
        }
 
@@ -1203,9 +1237,9 @@ static void editing_panel_curve_tools1(Object *ob, Curve *cu)
        block= uiNewBlock(&curarea->uiblocks, "editing_panel_curve_tools1", UI_EMBOSS, UI_HELV, curarea->win);
        if(uiNewPanel(curarea, block, "Curve Tools1", "Editing", 960, 0, 318, 204)==0) return;
 
-       uiDefBut(block, BUT, B_SUBDIVCURVE, "Subdivide", 400,180,150,20, 0, 0, 0, 0, 0, "");
+       uiDefBut(block, BUT, B_SUBDIVCURVE, "Subdivide", 400,180,150,20, 0, 0, 0, 0, 0, "Subdivide selected");
        if(ob->type==OB_SURF) {
-               uiDefBut(block, BUT, B_SPINNURB, "Spin",         400,160,150,20, 0, 0, 0, 0, 0, "");
+               uiDefBut(block, BUT, B_SPINNURB, "Spin",         400,160,150,20, 0, 0, 0, 0, 0, "Spin selected 360 degrees");
        }
        uiBlockBeginAlign(block);
        uiDefBut(block, BUT,B_HIDE,             "Hide",                 400,120,150,18, 0, 0, 0, 0, 0, "Hides selected faces");
@@ -1213,7 +1247,7 @@ static void editing_panel_curve_tools1(Object *ob, Curve *cu)
        uiDefBut(block, BUT,B_SELSWAP,  "Select Swap",  400,80,150,18, 0, 0, 0, 0, 0, "Selects unselected faces, and deselects selected faces");
        uiBlockEndAlign(block);
 
-       uiDefButF(block, NUM,   REDRAWVIEW3D, "NSize:", 400, 40, 150, 19, &editbutsize, 0.001, 1.0, 10, 0, "");
+       uiDefButF(block, NUM,   REDRAWVIEW3D, "NSize:", 400, 40, 150, 19, &editbutsize, 0.001, 1.0, 10, 0, "Normal size for drawing");
 }
 
 /* for curve, surf and font! */
@@ -1224,9 +1258,9 @@ static void editing_panel_curve_type(Object *ob, Curve *cu)
        block= uiNewBlock(&curarea->uiblocks, "editing_panel_curve_type", UI_EMBOSS, UI_HELV, curarea->win);
        if(uiNewPanel(curarea, block, "Curve and Surface", "Editing", 320, 0, 318, 204)==0) return;
 
-       uiDefButS(block, TOG|BIT|5, 0, "UV Orco",                                       600,160,150,19, &cu->flag, 0, 0, 0, 0, "");
+       uiDefButS(block, TOG|BIT|5, 0, "UV Orco",                                       600,160,150,19, &cu->flag, 0, 0, 0, 0, "Forces to use UV coordinates for texture mapping 'orco'");
        if(ob->type==OB_SURF)
-               uiDefButS(block, TOG|BIT|6, REDRAWVIEW3D, "No Puno Flip",       600,140,150,19, &cu->flag, 0, 0, 0, 0, "");
+               uiDefButS(block, TOG|BIT|6, REDRAWVIEW3D, "No Puno Flip",       600,140,150,19, &cu->flag, 0, 0, 0, 0, "Don't flip vertex normals while render");
 
        uiBlockBeginAlign(block);
        uiDefBut(block, BUT,B_DOCENTRE, "Centre",                                       600, 115, 150, 19, 0, 0, 0, 0, 0, "Shifts object data to be centered about object's origin");
@@ -1242,35 +1276,42 @@ static void editing_panel_curve_type(Object *ob, Curve *cu)
        }
 
        if(ob->type!=OB_SURF) {
-
+       
                if(ob->type==OB_CURVE) {
                        extern float prlen;             // buttons_object.c, should be moved....
                        char str[32];
-                       uiBlockBeginAlign(block);
-                       uiDefButS(block, NUM, B_RECALCPATH, "PathLen:",                 600,50,150,19, &cu->pathlen, 1.0, 9000.0, 0, 0, "");
-                       uiDefButS(block, TOG|BIT|3, B_RECALCPATH, "CurvePath",  600,30,75,19 , &cu->flag, 0, 0, 0, 0, "");
-                       uiDefButS(block, TOG|BIT|4, REDRAWVIEW3D, "CurveFollow",675,30,75,19, &cu->flag, 0, 0, 0, 0, "");
+                       
                        sprintf(str, "%.4f", prlen);
-                       uiDefBut(block, BUT, B_PRINTLEN,                "PrintLen",     600,10,75,19, 0, 0, 0, 0, 0, "");
-                       uiDefBut(block, LABEL, 0, str,                                          675,10,75,19, 0, 1.0, 0, 0, 0, "");
+                       uiDefBut(block, BUT, B_PRINTLEN,                "PrintLen",     600,135,75,19, 0, 0, 0, 0, 0, "");
+                       uiDefBut(block, LABEL, 0, str,                                          675,135,75,19, 0, 1.0, 0, 0, 0, "");
+                       
+                       uiBlockBeginAlign(block);
+                       uiDefButS(block, NUM, B_RECALCPATH, "PathLen:",                 600,50,150,19, &cu->pathlen, 1.0, 9000.0, 0, 0, "If no speed Ipo was set, the amount of frames of the path");
+                       uiDefButS(block, TOG|BIT|3, B_RECALCPATH, "CurvePath",  600,30,75,19 , &cu->flag, 0, 0, 0, 0, "Enables curve to become translation path");
+                       uiDefButS(block, TOG|BIT|4, REDRAWVIEW3D, "CurveFollow",675,30,75,19, &cu->flag, 0, 0, 0, 0, "Makes curve path children to rotate along path");
+                       uiDefButS(block, TOG|BIT|7, B_CURVECHECK, "CurveStretch", 600,10,150,19, &cu->flag, 0, 0, 0, 0, "Option for curve-deform: makes deformed child to stretch along entire path");
+                       uiDefButS(block, TOG|BIT|8, REDRAWVIEW3D, "PathDist Offs", 600,-10,150,19, &cu->flag, 0, 0, 0, 0, "Children will use TimeOffs value as path distance offset");
+
+                       uiBlockEndAlign(block);
                }
 
                uiBlockBeginAlign(block);
-               uiDefButS(block, NUM, B_MAKEDISP, "DefResolU:", 760,160,120,19, &cu->resolu, 1.0, 128.0, 0, 0, "");
-               uiDefBut(block, BUT, B_SETRESOLU, "Set",                880,160,30,19, 0, 0, 0, 0, 0, "");
+               uiDefButS(block, NUM, B_MAKEDISP, "DefResolU:", 760,160,120,19, &cu->resolu, 1.0, 1024.0, 0, 0, "Default resolution");
+               uiDefBut(block, BUT, B_SETRESOLU, "Set",                880,160,30,19, 0, 0, 0, 0, 0, "Set resolution for interpolation");
 
                uiBlockBeginAlign(block);
-               uiDefButF(block, NUM, B_MAKEDISP, "Width:",             760,90,150,19, &cu->width, 0.0, 2.0, 1, 0, "");
-               uiDefButF(block, NUM, B_MAKEDISP, "Ext1:",              760,70,150,19, &cu->ext1, 0.0, 5.0, 10, 0, "");
-               uiDefButF(block, NUM, B_MAKEDISP, "Ext2:",              760,50,150,19, &cu->ext2, 0.0, 2.0, 1, 0, "");
-               uiDefButS(block, NUM, B_MAKEDISP, "BevResol:",  760,30,150,19, &cu->bevresol, 0.0, 10.0, 0, 0, "");
-               uiDefIDPoinBut(block, test_obcurpoin_but, B_MAKEDISP, "BevOb:",         760,10,150,19, &cu->bevobj, "");
+               uiDefButF(block, NUM, B_MAKEDISP, "Width:",             760,90,150,19, &cu->width, 0.0, 2.0, 1, 0, "Make interpolated result thinner or fatter");
+               uiDefButF(block, NUM, B_MAKEDISP, "Ext1:",              760,70,150,19, &cu->ext1, 0.0, 5.0, 10, 0, "Extrude depth");
+               uiDefButF(block, NUM, B_MAKEDISP, "Ext2:",              760,50,150,19, &cu->ext2, 0.0, 2.0, 1, 0, "Extrude beveling depth");
+               uiDefButS(block, NUM, B_MAKEDISP, "BevResol:",  760,30,150,19, &cu->bevresol, 0.0, 10.0, 0, 0, "Amount of bevels");
+               uiDefIDPoinBut(block, test_obcurpoin_but, B_MAKEDISP, "BevOb:",         760,10,150,19, &cu->bevobj, "Curve object name that defines the bevel shape");
+               uiDefIDPoinBut(block, test_obcurpoin_but, B_MAKEDISP, "TaperOb:",               760,-10,150,19, &cu->taperobj, "Curve object name that defines the taper (width)");
 
                uiBlockBeginAlign(block);
                uiBlockSetCol(block, TH_BUT_SETTING1);
-               uiDefButS(block, TOG|BIT|2, B_MAKEDISP, "Back", 760,130,50,19, &cu->flag, 0, 0, 0, 0, "");
-               uiDefButS(block, TOG|BIT|1, B_MAKEDISP, "Front",810,130,50,19, &cu->flag, 0, 0, 0, 0, "");
-               uiDefButS(block, TOG|BIT|0, B_CU3D, "3D",               860,130,50,19, &cu->flag, 0, 0, 0, 0, "");
+               uiDefButS(block, TOG|BIT|2, B_MAKEDISP, "Back", 760,130,50,19, &cu->flag, 0, 0, 0, 0, "Draw filled back for curves");
+               uiDefButS(block, TOG|BIT|1, B_MAKEDISP, "Front",810,130,50,19, &cu->flag, 0, 0, 0, 0, "Draw filled front for curves");
+               uiDefButS(block, TOG|BIT|0, B_CU3D, "3D",               860,130,50,19, &cu->flag, 0, 0, 0, 0, "Allow Curve Object to be 3d, it doesn't fill then");
 
 
        }
@@ -1292,7 +1333,10 @@ static void editing_panel_camera_type(Object *ob, Camera *cam)
        block= uiNewBlock(&curarea->uiblocks, "editing_panel_camera_type", UI_EMBOSS, UI_HELV, curarea->win);
        if(uiNewPanel(curarea, block, "Camera", "Editing", 320, 0, 318, 204)==0) return;
 
-       uiDefButF(block, NUM,REDRAWVIEW3D, "Lens:", 470,178,160,20, &cam->lens, 1.0, 250.0, 100, 0, "Specify the lens of the camera");
+       if(cam->type==CAM_ORTHO)
+               uiDefButF(block, NUM,REDRAWVIEW3D, "Scale:", 470,178,160,20, &cam->ortho_scale, 0.01, 1000.0, 50, 0, "Specify the ortho scaling of the used camera");
+       else
+               uiDefButF(block, NUM,REDRAWVIEW3D, "Lens:", 470,178,160,20, &cam->lens, 1.0, 250.0, 100, 0, "Specify the lens of the camera");
 
        uiBlockBeginAlign(block);
        uiDefButF(block, NUM,REDRAWVIEW3D, "ClipSta:", 470,147,160,20, &cam->clipsta, 0.001*grid, 100.0*grid, 10, 0, "Specify the startvalue of the the field of view");
@@ -1301,13 +1345,59 @@ 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);
 }
 
+/* yafray: extra camera panel to set Depth-of-Field parameters */
+static void editing_panel_camera_yafraydof(Object *ob, Camera *cam)
+{
+       uiBlock *block;
+       char *mst1, *mst2;
+
+       block= uiNewBlock(&curarea->uiblocks, "editing_panel_camera_yafraydof", UI_EMBOSS, UI_HELV, curarea->win);
+       uiNewPanelTabbed("Camera", "Editing");
+       if(uiNewPanel(curarea, block, "Yafray DoF", "Editing", 320, 0, 318, 204)==0) return;
+
+       uiDefButF(block, NUM, REDRAWVIEW3D, "DoFDist:", 10, 147, 180, 20, &cam->YF_dofdist, 0.0, 5000.0, 50, 0, "Sets distance to point of focus (use camera 'ShowLimits' to make visible in 3Dview)");
+       uiDefButF(block, NUM, B_DIFF, "Aperture:", 10, 125, 180, 20, &cam->YF_aperture, 0.0, 2.0, 1, 0, "Sets lens aperture, the larger, the more blur (use small values, 0 is no DoF)");
+
+       uiDefButS(block, TOG|BIT|2, B_DIFF, "Random sampling", 10, 90, 180, 20, &cam->flag, 0, 0, 0, 0, "Use noisy random Lens sampling instead of QMC");
+
+       uiDefBut(block, LABEL, 0, "Bokeh", 10, 60, 180, 19, 0, 0.0, 0.0, 0, 0, "");
+       mst1 = "Bokeh Type%t|Disk1%x0|Disk2%x1|Triangle%x2|Square%x3|Pentagon%x4|Hexagon%x5|Ring%x6";
+       uiDefButS(block, MENU, B_REDR, mst1, 10, 40, 89, 20, &cam->YF_bkhtype, 0.0, 0.0, 0, 0, "Sets Bokeh type");
+       
+       if ((cam->YF_bkhtype!=0) && (cam->YF_bkhtype!=6)) {
+               mst2 = "Bokeh Bias%t|Uniform%x0|Center%x1|Edge%x2";
+               uiDefButS(block, MENU, B_REDR, mst2, 100, 40, 90, 20, &cam->YF_bkhbias, 0.0, 0.0, 0, 0, "Sets Bokeh bias");
+               if (cam->YF_bkhtype>1)
+                       uiDefButF(block, NUM, B_DIFF, "Rotation:", 10, 15, 180, 20, &cam->YF_bkhrot, 0.0, 360.0, 100, 0, "Shape rotation amount in degrees");
+       }
+
+}
+
+/* **************************** 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 ******************************** */
 
 void do_mballbuts(unsigned short event)
@@ -1331,17 +1421,17 @@ static void editing_panel_mball_type(Object *ob, MetaBall *mb)
        mb= ob->data;
 
        uiBlockBeginAlign(block);
-       uiDefButF(block, NUMSLI, B_RECALCMBALL, "Wiresize:",    470,178,250,19, &mb->wiresize, 0.05, 1.0, 0, 0, "");
-       uiDefButF(block, NUMSLI, 0, "Rendersize:",                      470,158,250,19, &mb->rendersize, 0.05, 1.0, 0, 0, "");
-       uiDefButF(block, NUMSLI, B_RECALCMBALL, "Threshold:", 470,138,250,19, &mb->thresh, 0.0001, 5.0, 0, 0, "");
+       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, "");
-       uiDefButS(block, ROW, B_DIFF, "Always", 471, 85, 120, 19, &mb->flag, 0.0, 0.0, 0, 0, "");
-       uiDefButS(block, ROW, B_DIFF, "Half Res",       471, 65, 120, 19, &mb->flag, 0.0, 1.0, 0, 0, "");
-       uiDefButS(block, ROW, B_DIFF, "Fast",           471, 45, 120, 19, &mb->flag, 0.0, 2.0, 0, 0, "");
-       uiDefButS(block, ROW, B_DIFF, "Never",          471, 25, 120, 19, &mb->flag, 0.0, 3.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");
 
 }
 
@@ -1355,25 +1445,28 @@ static void editing_panel_mball_tools(Object *ob, MetaBall *mb)
 
        if(ob==G.obedit && lastelem) {
                uiBlockBeginAlign(block);
-               uiDefButF(block, NUMSLI, B_RECALCMBALL, "Stiffness:", 750,178,250,19, &lastelem->s, 0.0, 10.0, 0, 0, "");
+               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, NUMSLI, B_RECALCMBALL, "dx:",          750,158,250,19, &lastelem->expx, 0.0, 20.0, 0, 0, "");
+               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, NUMSLI, B_RECALCMBALL, "dy:",          750,138,250,19, &lastelem->expy, 0.0, 20.0, 0, 0, "");
+               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, NUMSLI, B_RECALCMBALL, "dz:",          750,118,250,19, &lastelem->expz, 0.0, 20.0, 0, 0, "");
+               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, "");
+               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, "");
-               uiDefButS(block, ROW, B_RECALCMBALL, "Plane",                   814,62,60,19, &lastelem->type, 1.0, 5.0, 0, 0, "");
-               uiDefButS(block, ROW, B_RECALCMBALL, "Elipsoid",                876,62,60,19, &lastelem->type, 1.0, 6.0, 0, 0, "");
-               uiDefButS(block, ROW, B_RECALCMBALL, "Cube",                    938,62,60,19, &lastelem->type, 1.0, 7.0, 0, 0, "");
+               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);
 
-               uiDefButS(block, TOG|BIT|1, B_RECALCMBALL, "Negative",753,16,60,19, &lastelem->flag, 0, 0, 0, 0, "");
+               uiBlockBeginAlign(block);
+               uiDefButS(block, TOG|BIT|1, B_RECALCMBALL, "Negative",753,16,125,19, &lastelem->flag, 0, 0, 0, 0, "Make active meta creating holes");
+               uiDefButS(block, TOG|BIT|2, B_RECALCMBALL, "Hide",878,16,125,19, &lastelem->flag, 0, 0, 0, 0, "Make active meta invisible");
+               uiBlockEndAlign(block);
 
        }
 
@@ -1395,6 +1488,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;
@@ -1420,39 +1514,39 @@ static void editing_panel_lattice_type(Object *ob, Lattice *lt)
        uiBlock *block;
 
        block= uiNewBlock(&curarea->uiblocks, "editing_panel_lattice_type", UI_EMBOSS, UI_HELV, curarea->win);
-       if(uiNewPanel(curarea, block, "Latice", "Editing", 320, 0, 318, 204)==0) return;
+       if(uiNewPanel(curarea, block, "Lattice", "Editing", 320, 0, 318, 204)==0) return;
 
 
        uiSetButLock(lt->key!=0, "Not with VertexKeys");
        uiSetButLock(ob==G.obedit, "Unable to perform function in EditMode");
 
        uiBlockBeginAlign(block);
-       uiDefButS(block, NUM, B_RESIZELAT,      "U:",                           470, 178,100,19, &lt->pntsu, 1.0, 64.0, 0, 0, "Points in U direction");
+
+       uiDefButS(block, NUM, B_RESIZELAT,      "U:",                           469, 178,100,19, &lt->pntsu, 1.0, 64.0, 0, 0, "Points in U direction");
        uiDefButC(block, ROW, B_LATTCHANGED,            "Lin",          572, 178, 40, 19, &lt->typeu, 1.0, (float)KEY_LINEAR, 0, 0, "Set Linear interpolation");
-       uiDefButC(block, ROW, B_LATTCHANGED,            "Card",         612, 178, 40, 19, &lt->typeu, 1.0, (float)KEY_CARDINAL, 0, 0, "Set Cardinal interpolation");
+       uiDefButC(block, ROW, B_LATTCHANGED,            "Card",         613, 178, 40, 19, &lt->typeu, 1.0, (float)KEY_CARDINAL, 0, 0, "Set Cardinal interpolation");
        uiDefButC(block, ROW, B_LATTCHANGED,            "B",            652, 178, 40, 19, &lt->typeu, 1.0, (float)KEY_BSPLINE, 0, 0, "Set B-spline interpolation");
 
-       uiBlockBeginAlign(block);
-       uiDefButS(block, NUM, B_RESIZELAT,      "V:",                           470, 158,100,19, &lt->pntsv, 1.0, 64.0, 0, 0, "Points in V direction");
-       uiDefButC(block, ROW, B_LATTCHANGED,            "Lin",          572, 158, 40, 19, &lt->typev, 2.0, (float)KEY_LINEAR, 0, 0, "Set Linear interpolation");
-       uiDefButC(block, ROW, B_LATTCHANGED,            "Card",         612, 158, 40, 19, &lt->typev, 2.0, (float)KEY_CARDINAL, 0, 0, "Set Cardinal interpolation");
-       uiDefButC(block, ROW, B_LATTCHANGED,            "B",            652, 158, 40, 19, &lt->typev, 2.0, (float)KEY_BSPLINE, 0, 0, "Set B-spline interpolation");
+       uiDefButS(block, NUM, B_RESIZELAT,      "V:",                           469, 156,100,19, &lt->pntsv, 1.0, 64.0, 0, 0, "Points in V direction");
+       uiDefButC(block, ROW, B_LATTCHANGED,            "Lin",          572, 156, 40, 19, &lt->typev, 2.0, (float)KEY_LINEAR, 0, 0, "Set Linear interpolation");
+       uiDefButC(block, ROW, B_LATTCHANGED,            "Card",         613, 156, 40, 19, &lt->typev, 2.0, (float)KEY_CARDINAL, 0, 0, "Set Cardinal interpolation");
+       uiDefButC(block, ROW, B_LATTCHANGED,            "B",            652, 156, 40, 19, &lt->typev, 2.0, (float)KEY_BSPLINE, 0, 0, "Set B-spline interpolation");
+
+       uiDefButS(block, NUM, B_RESIZELAT,      "W:",                           469, 134,100,19, &lt->pntsw, 1.0, 64.0, 0, 0, "Points in W direction");
+       uiDefButC(block, ROW, B_LATTCHANGED,            "Lin",          572, 134, 40, 19, &lt->typew, 3.0, (float)KEY_LINEAR, 0, 0, "Set Linear interpolation");
+       uiDefButC(block, ROW, B_LATTCHANGED,            "Card",         613, 134, 40, 19, &lt->typew, 3.0, (float)KEY_CARDINAL, 0, 0, "Set Cardinal interpolation");
+       uiDefButC(block, ROW, B_LATTCHANGED,            "B",            652, 134, 40, 19, &lt->typew, 3.0, (float)KEY_BSPLINE, 0, 0, "Set B-spline interpolation");
 
-       uiBlockBeginAlign(block);
-       uiDefButS(block, NUM, B_RESIZELAT,      "W:",                           470, 138,100,19, &lt->pntsw, 1.0, 64.0, 0, 0, "Points in W direction");
-       uiDefButC(block, ROW, B_LATTCHANGED,            "Lin",          572, 138, 40, 19, &lt->typew, 3.0, (float)KEY_LINEAR, 0, 0, "Set Linear interpolation");
-       uiDefButC(block, ROW, B_LATTCHANGED,            "Card",         612, 138, 40, 19, &lt->typew, 3.0, (float)KEY_CARDINAL, 0, 0, "Set Cardinal interpolation");
-       uiDefButC(block, ROW, B_LATTCHANGED,            "B",            652, 138, 40, 19, &lt->typew, 3.0, (float)KEY_BSPLINE, 0, 0, "Set B-spline interpolation");
        uiBlockEndAlign(block);
 
-       uiDefBut(block, BUT, B_RESIZELAT,       "Make Regular",         470,101,99,32, 0, 0, 0, 0, 0, "Make Lattice regular");
+       uiDefBut(block, BUT, B_RESIZELAT,       "Make Regular",         469,98,102,31, 0, 0, 0, 0, 0, "Make Lattice regular");
 
        uiClearButLock();
-       uiDefButS(block, TOG|BIT|1, B_LATTCHANGED, "Outside",   571,101,120,31, &lt->flag, 0, 0, 0, 0, "Only draw, and take into account, the outer vertices");
+       uiDefButS(block, TOG|BIT|1, B_LATTCHANGED, "Outside",   571,98,122,31, &lt->flag, 0, 0, 0, 0, "Only draw, and take into account, the outer vertices");
 
        if(lt->key) {
-               uiDefButS(block, NUM, B_DIFF, "Slurph:",                        470,60,120,19, &(lt->key->slurph), -500.0, 500.0, 0, 0, "Set time value to denote 'slurph' (sequential delay) vertices with key framing");
-               uiDefButS(block, TOG, B_RELKEY, "Relative Keys",        470,40,120,19, &lt->key->type, 0, 0, 0, 0, "Use relative keys (instead of absolute)");
+               uiDefButS(block, NUM, B_DIFF, "Slurph:",                        469,60,120,19, &(lt->key->slurph), -500.0, 500.0, 0, 0, "Set time value to denote 'slurph' (sequential delay) vertices with key framing");
+               uiDefButS(block, TOG, B_RELKEY, "Relative Keys",        469,40,120,19, &lt->key->type, 0, 0, 0, 0, "Use relative keys (instead of absolute)");
        }
 
 }
@@ -1558,7 +1652,8 @@ static void constraint_ebone_name_fix(ListBase *conlist, EditBone *eBone)
        }
 }
 
-static void validate_editbonebutton(EditBone *eBone)
+// called in outliner too...
+void validate_editbonebutton(EditBone *eBone)
 {
        EditBone        *prev;
        bAction         *act=NULL;
@@ -1651,6 +1746,36 @@ static void validate_editbonebutton_cb(void *bonev, void *arg2_unused)
        validate_editbonebutton(curBone);
 }
 
+/* called from outliner now, can be used for buttons in posemode too */
+/* current Armature should be active Object */
+/* after this function, the Bones in Armature are re-allocced! */
+void rename_bone_ext(char *oldname, char *newname)
+{
+       EditBone *ebone;
+       int temp_editmode= 0;
+
+       /* since the naming functions work only on editArmature, we have to... */
+       if(G.obedit!=OBACT) exit_editmode(2);
+       if(G.obedit==NULL) {
+               G.obedit= OBACT;
+               make_editArmature();
+               temp_editmode= 1;
+       }
+       
+       /* now find the eBone with oldname */
+       for(ebone= G.edbo.first; ebone; ebone= ebone->next)
+               if(strcmp(ebone->name, oldname)==0) break;
+
+       if(ebone) {
+               strcpy(ebone->oldname, oldname);
+               strcpy(ebone->name, newname);
+               validate_editbonebutton(ebone); // does exit_editmode... tsk, so armature bones pointers are invalid now
+       }
+       if(temp_editmode) exit_editmode(2);
+       
+}
+
+
 static void armature_rest_pos_func(void *notused1, void *notused2) 
 {
        clear_object_constraint_status(OBACT);
@@ -1683,8 +1808,8 @@ static void editing_panel_armature_type(Object *ob, bArmature *arm)
 static void editing_panel_armature_bones(Object *ob, bArmature *arm)
 {
        uiBlock         *block;
-       EditBone        *curBone;
        uiBut           *but;
+       EditBone        *curBone;
        char            *boneString=NULL;
        int                     bx=148, by=180;
        int                     index;
@@ -1699,7 +1824,7 @@ static void editing_panel_armature_bones(Object *ob, bArmature *arm)
        uiNewPanelHeight(block, 204);
 
 
-       uiDefBut(block, LABEL, 0, "Selected Bones",                                             bx,by,158,18, 0, 0, 0, 0, 0, "");
+       uiDefBut(block, LABEL, 0, "Selected Bones", bx,by,158,18, 0, 0, 0, 0, 0, "Only show in Armature Editmode");
        by-=20;
        for (curBone=G.edbo.first, index=0; curBone; curBone=curBone->next, index++){
                if (curBone->flag & (BONE_SELECTED)) {
@@ -1714,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){
@@ -1732,24 +1857,11 @@ static void editing_panel_armature_bones(Object *ob, bArmature *arm)
                        /* Dist and weight buttons */
                        uiBlockBeginAlign(block);
                        but=uiDefButS(block, MENU, REDRAWVIEW3D,
-                                                       "Skinnable %x0|"
-                                                       "Unskinnable %x1|"
-                                                       "Head %x2|"
-                                                       "Neck %x3|"
-                                                       "Back %x4|"
-                                                       "Shoulder %x5|"
-                                                       "Arm %x6|"
-                                                       "Hand %x7|"
-                                                       "Finger %x8|"
-                                                       "Thumb %x9|"
-                                                       "Pelvis %x10|"
-                                                       "Leg %x11|"
-                                                       "Foot %x12|"
-                                                       "Toe %x13|"
-                                                       "Tentacle %x14",
-                                                       bx-10,by-19,117,18,
-                                                       &curBone->boneclass,
-                                                       0.0, 0.0, 0.0, 0.0,
+                                                       "Skinnable %x0|" "Unskinnable %x1|" "Head %x2|"
+                                                       "Neck %x3|" "Back %x4|" "Shoulder %x5|" "Arm %x6|"
+                                                       "Hand %x7|" "Finger %x8|" "Thumb %x9|" "Pelvis %x10|"
+                                                       "Leg %x11|" "Foot %x12|" "Toe %x13|" "Tentacle %x14",
+                                                       bx-10,by-19,117,18, &curBone->boneclass, 0.0, 0.0, 0.0, 0.0,
                                                        "Classification of armature element");
 
                        /* Dist and weight buttons */
@@ -1776,9 +1888,6 @@ static void editing_panel_armature_bones(Object *ob, bArmature *arm)
 
 void do_meshbuts(unsigned short event)
 {
-       void decimate_faces(void);
-       void decimate_cancel(void);
-       void decimate_apply(void);
        Object *ob;
        Mesh *me;
        float fac;
@@ -1809,16 +1918,17 @@ void do_meshbuts(unsigned short event)
                case B_DELVGROUP:
                        del_defgroup (G.obedit);
                        allqueue (REDRAWVIEW3D, 1);
+                       BIF_undo_push("Delete vertex group");
                        break;
                case B_ASSIGNVGROUP:
-                       undo_push_mesh("Assign to vertex group");
                        assign_verts_defgroup ();
                        allqueue (REDRAWVIEW3D, 1);
+                       BIF_undo_push("Assign to vertex group");
                        break;
                case B_REMOVEVGROUP:
-                       undo_push_mesh("Remove from vertex group");
                        remove_verts_defgroup (0);
                        allqueue (REDRAWVIEW3D, 1);
+                       BIF_undo_push("Remove from vertex group");
                        break;
                case B_SELVGROUP:
                        sel_verts_defgroup(1);
@@ -1835,7 +1945,8 @@ void do_meshbuts(unsigned short event)
                        allqueue(REDRAWBUTSEDIT, 0);
                        break;
                case B_MAKESTICKY:
-                       make_sticky();
+                       RE_make_sticky();
+                       allqueue(REDRAWBUTSEDIT, 0);
                        break;
                
                case B_MAKEEDGES:
@@ -1936,28 +2047,28 @@ void do_meshbuts(unsigned short event)
                G.f -= G_DISABLE_OK;
                break;
        case B_REMDOUB:
-               undo_push_mesh("Rem Doubles");
                notice("Removed: %d", removedoublesflag(1, doublimit));
                allqueue(REDRAWVIEW3D, 0);
+               BIF_undo_push("Rem Doubles");
                break;
        case B_SUBDIV:
                waitcursor(1);
-               undo_push_mesh("Subdivide");
                subdivideflag(1, 0.0, editbutflag & B_BEAUTY);
                countall();
                waitcursor(0);
                allqueue(REDRAWVIEW3D, 0);
+               BIF_undo_push("Subdivide");
                break;
        case B_FRACSUBDIV:
                randfac= 10;
                if(button(&randfac, 1, 100, "Rand fac:")==0) return;
                waitcursor(1);
-               undo_push_mesh("Fractal Subdivide");
                fac= -( (float)randfac )/100;
                subdivideflag(1, fac, editbutflag & B_BEAUTY);
                countall();
                waitcursor(0);
                allqueue(REDRAWVIEW3D, 0);
+               BIF_undo_push("Fractal Subdivide");
                break;
        case B_XSORT:
                if( select_area(SPACE_VIEW3D)) xsortvert_flag(1);
@@ -1974,6 +2085,16 @@ void do_meshbuts(unsigned short event)
        case B_VERTEXSMOOTH:
                vertexsmooth();
                break;
+       case B_DRAWEDGES:
+               G.f &= ~G_DRAWCREASES;
+               allqueue(REDRAWBUTSEDIT, 0);
+               allqueue(REDRAWVIEW3D, 0);
+               break;
+       case B_DRAWCREASES:
+               G.f &= ~G_DRAWEDGES;
+               allqueue(REDRAWBUTSEDIT, 0);
+               allqueue(REDRAWVIEW3D, 0);
+               break;
        }
        /* WATCH IT: previous events only in editmode! */
 }
@@ -2037,25 +2158,74 @@ static void editing_panel_mesh_tools1(Object *ob, Mesh *me)
        block= uiNewBlock(&curarea->uiblocks, "editing_panel_mesh_tools1", UI_EMBOSS, UI_HELV, curarea->win);
        if(uiNewPanel(curarea, block, "Mesh Tools 1", "Editing", 960, 0, 318, 204)==0) return;
 
-       uiDefBut(block, BUT,B_DOCENTRE, "Centre",       1091, 200, 166, 19, 0, 0, 0, 0, 0, "Shifts object data to be centered about object's origin");
        uiBlockBeginAlign(block);
-       uiDefBut(block, BUT,B_HIDE,             "Hide",         1091,155,77,24, 0, 0, 0, 0, 0, "Hides selected faces");
-       uiDefBut(block, BUT,B_REVEAL,   "Reveal",       1171,155,86,24, 0, 0, 0, 0, 0, "Reveals selected faces");
+       uiDefBut(block, BUT,B_DOCENTRE, "Centre",       955, 200, 160, 19, 0, 0, 0, 0, 0, "Shifts object data to be centered about object's origin");
+       uiDefBut(block, BUT,B_HIDE,             "Hide",         1115, 200,  160, 19, 0, 0, 0, 0, 0, "Hides selected faces");
+       uiDefBut(block, BUT,B_SELSWAP,  "Select Swap",  955, 180, 160, 19, 0, 0, 0, 0, 0, "Selects unselected faces, and deselects selected faces");
+       uiDefBut(block, BUT,B_REVEAL,   "Reveal",               1115, 180,  160, 19, 0, 0, 0, 0, 0, "Reveals selected faces");
        uiBlockEndAlign(block);
 
-       uiDefBut(block, BUT,B_SELSWAP,  "Select Swap",  1091,130,166,24, 0, 0, 0, 0, 0, "Selects unselected faces, and deselects selected faces");
-
        uiBlockBeginAlign(block);
-       uiDefButF(block, NUM,             REDRAWVIEW3D, "NSize:",               1090, 110, 164, 19, &editbutsize, 0.001, 2.0, 10, 0, "Sets the length to use when displaying face normals");
-       uiDefButI(block, TOG|BIT|19, REDRAWVIEW3D, "Draw Creases",      1090,90,164,19, &G.f, 0, 0, 0, 0, "Displays face normals as lines");
-       uiDefButI(block, TOG|BIT|6, REDRAWVIEW3D, "Draw Normals",       1090,70,164,19, &G.f, 0, 0, 0, 0, "Displays face normals as lines");
-       uiDefButI(block, TOG|BIT|7, REDRAWVIEW3D, "Draw Faces", 1090,50,164,19, &G.f, 0, 0, 0, 0, "Displays all faces as shades");
-       uiDefButI(block, TOG|BIT|18, REDRAWVIEW3D, "Draw Edges", 1090,30,164,19, &G.f, 0, 0, 0, 0, "Displays selected edges using hilights");
-       uiDefButI(block, TOG|BIT|11, 0, "All edges",                            1090,10,164,19, &G.f, 0, 0, 0, 0, "Displays all edges in object mode without optimization");
+       uiDefButF(block, NUM,             REDRAWVIEW3D, "NSize:",       955, 131, 150, 19, &editbutsize, 0.001, 2.0, 10, 0, "Sets the length to use when displaying face normals");
+       uiDefButI(block, TOG|BIT|6, REDRAWVIEW3D, "Draw Normals",       955,110,150,19, &G.f, 0, 0, 0, 0, "Displays face normals as lines");
+       uiDefButI(block, TOG|BIT|7, REDRAWVIEW3D, "Draw Faces",         955,88,150,19, &G.f, 0, 0, 0, 0, "Displays all faces as shades");
+       uiDefButI(block, TOG|BIT|18, REDRAWVIEW3D, "Draw Edges",        955,66,150,19, &G.f, 0, 0, 0, 0, "Displays selected edges using hilights");
+       uiDefButI(block, TOG|BIT|19, REDRAWVIEW3D, "Draw Creases",      955,44,150,19, &G.f, 0, 0, 0, 0, "Displays creases created for subsurf weighting");
+       uiDefButI(block, TOG|BIT|20, REDRAWVIEW3D, "Draw Seams",        955,22,150,19, &G.f, 0, 0, 0, 0, "Displays UV unwrapping seams");
+       uiDefButI(block, TOG|BIT|11, 0, "All Edges",                    955, 0,150,19, &G.f, 0, 0, 0, 0, "Displays all edges in object mode without optimization");
+       uiBlockEndAlign(block);
+       
+       /* Measurement drawing options */
+       uiBlockBeginAlign(block);
+       uiDefButI(block, TOG|BIT|22, REDRAWVIEW3D, "Edge Length",       1125,131,150,19, &G.f, 0, 0, 0, 0, "Displays selected edge lengths");
+       uiDefButI(block, TOG|BIT|24, REDRAWVIEW3D, "Edge Angles",       1125,110,150,19,  &G.f, 0, 0, 0, 0, "Displays the angles in the selected edges in degrees");
+       uiDefButI(block, TOG|BIT|23, REDRAWVIEW3D, "Face Area",         1125,88,150,19, &G.f, 0, 0, 0, 0, "Displays the area of selected faces");
        uiBlockEndAlign(block);
 
 }
 
+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)
 {
@@ -2135,9 +2305,9 @@ static void editing_panel_links(Object *ob)
        if(ma) uiDefBut(block, LABEL, 0, ma->id.name+2, 318,153, 103, 20, 0, 0, 0, 0, 0, "");
 
        uiBlockBeginAlign(block);
-       if(ma) uiDefButF(block, COL, B_REDR, "",                        291,123,24,30, &(ma->r), 0, 0, 0, 0, "");
-       uiDefButC(block, NUM, B_REDR,   str,            318,123,103,30, &ob->actcol, min, (float)(ob->totcol), 0, 0, "Displays total number of material indices and the current index");
-       uiDefBut(block, BUT,B_MATWICH,  "?",            423,123,31,30, 0, 0, 0, 0, 0, "In EditMode, sets the active material index from selected faces");
+       if(ma) uiDefButF(block, COL, B_REDR, "",                        292,123,31,30, &(ma->r), 0, 0, 0, 0, "");
+       uiDefButC(block, NUM, B_REDR,   str,            324,123,100,30, &ob->actcol, min, (float)(ob->totcol), 0, 0, "Displays total number of material indices and the current index");
+       uiDefBut(block, BUT,B_MATWICH,  "?",            424,123,30,30, 0, 0, 0, 0, 0, "In EditMode, sets the active material index from selected faces");
 
        uiBlockBeginAlign(block);
        uiDefBut(block, BUT,B_MATNEW,   "New",          292,98,80,20, 0, 0, 0, 0, 0, "Adds a new Material index");
@@ -2156,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.)");
@@ -2236,6 +2374,7 @@ void do_fpaintbuts(unsigned short event)
        Mesh *me;
        Object *ob;
        extern TFace *lasttface; /* caches info on tface bookkeeping ?*/
+       extern VPaint Gvp;         /* from vpaint */
 
        ob= OBACT;
        if(ob==0) return;
@@ -2319,55 +2458,129 @@ void do_fpaintbuts(unsigned short event)
                        allqueue(REDRAWBUTSEDIT, 0);
                }
                break;
+       case B_WEIGHT0_0:
+               editbutvweight = 0.0f;
+               allqueue(REDRAWBUTSEDIT, 0);
+               break;
+
+       case B_WEIGHT1_4:
+               editbutvweight = 0.25f;
+               allqueue(REDRAWBUTSEDIT, 0);
+               break;
+       case B_WEIGHT1_2:
+               editbutvweight = 0.5f;
+               allqueue(REDRAWBUTSEDIT, 0);
+               break;
+       case B_WEIGHT3_4:
+               editbutvweight = 0.75f;
+               allqueue(REDRAWBUTSEDIT, 0);
+               break;
+       case B_WEIGHT1_0:
+               editbutvweight = 1.0f;
+               allqueue(REDRAWBUTSEDIT, 0);
+               break;
+               
+       case B_OPA0_0:
+               Gvp.a = 0.0f;
+               allqueue(REDRAWBUTSEDIT, 0);
+               break;
+       case B_OPA1_4:
+               Gvp.a = 0.25f;
+               allqueue(REDRAWBUTSEDIT, 0);
+               break;
+       case B_OPA1_2:
+               Gvp.a = 0.5f;
+               allqueue(REDRAWBUTSEDIT, 0);
+               break;
+       case B_OPA3_4:
+               Gvp.a = 0.75f;
+               allqueue(REDRAWBUTSEDIT, 0);
+               break;
+       case B_OPA1_0:
+               Gvp.a = 1.0f;
+               allqueue(REDRAWBUTSEDIT, 0);
+               break;
+               
+
        }
 }
 
 
-/* -------------------- MODE: vpaint faceselect ------------------- */
+/* -------------------- MODE: vpaint  ------------------- */
 
 static void editing_panel_mesh_paint(void)
 {
        extern VPaint Gvp;         /* from vpaint */
        uiBlock *block;
-
+       
        block= uiNewBlock(&curarea->uiblocks, "editing_panel_mesh_paint", UI_EMBOSS, UI_HELV, curarea->win);
        if(uiNewPanel(curarea, block, "Paint", "Editing", 640, 0, 318, 204)==0) return;
+       
+       
+       if(G.f & ( G_WEIGHTPAINT))
+       {
+               Object *ob;
+           ob= OBACT;
+       if(ob==NULL) return;
 
-       uiBlockBeginAlign(block);
-       uiDefButF(block, NUMSLI, 0, "R ",                       979,160,194,19, &Gvp.r, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of red used for painting");
-       uiDefButF(block, NUMSLI, 0, "G ",                       979,140,194,19, &Gvp.g, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of green used for painting");
-       uiDefButF(block, NUMSLI, 0, "B ",                       979,120,194,19, &Gvp.b, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of blue used for painting");
-       uiBlockEndAlign(block);
-
-       uiDefButF(block, NUMSLI, 0, "Opacity ",         979,100,194,19, &Gvp.a, 0.0, 1.0, 0, 0, "The amount of pressure on the brush");
-       uiDefButF(block, NUMSLI, 0, "Size ",            979,80,194,19, &Gvp.size, 2.0, 64.0, 0, 0, "The size of the brush");
-
-       uiDefButF(block, COL, B_REDR, "",               1176,100,28,80, &(Gvp.r), 0, 0, 0, B_VPCOLSLI, "");
-       uiBlockBeginAlign(block);
-       uiDefButS(block, ROW, B_DIFF, "Mix",                    1212,160,63,19, &Gvp.mode, 1.0, 0.0, 0, 0, "Mix the vertex colours");
-       uiDefButS(block, ROW, B_DIFF, "Add",                    1212,140,63,19, &Gvp.mode, 1.0, 1.0, 0, 0, "Add the vertex colour");
-       uiDefButS(block, ROW, B_DIFF, "Sub",                    1212, 120,63,19, &Gvp.mode, 1.0, 2.0, 0, 0, "Subtract from the vertex colour");
-       uiDefButS(block, ROW, B_DIFF, "Mul",                    1212, 100,63,19, &Gvp.mode, 1.0, 3.0, 0, 0, "Multiply the vertex colour");
-       uiDefButS(block, ROW, B_DIFF, "Filter",         1212, 80,63,19, &Gvp.mode, 1.0, 4.0, 0, 0, "Mix the colours with an alpha factor");
-
-       uiBlockBeginAlign(block);
-       uiDefButS(block, TOG|BIT|1, 0, "Area",          980,50,80,19, &Gvp.flag, 0, 0, 0, 0, "Set the area the brush covers");
-       uiDefButS(block, TOG|BIT|2, 0, "Soft",          1061,50,112,19, &Gvp.flag, 0, 0, 0, 0, "Use a soft brush");
-       uiDefButS(block, TOG|BIT|3, 0, "Normals",       1174,50,102,19, &Gvp.flag, 0, 0, 0, 0, "Use vertex normal for painting");
-
-       uiBlockBeginAlign(block);
-       uiDefBut(block, BUT, B_VPGAMMA, "Set",  980,30,80,19, 0, 0, 0, 0, 0, "Apply Mul and Gamma to vertex colours");
-       uiDefButF(block, NUM, B_DIFF, "Mul:",           1061,30,112,19, &Gvp.mul, 0.1, 50.0, 10, 0, "Set the number to multiply vertex colours with");
-       uiDefButF(block, NUM, B_DIFF, "Gamma:",         1174,30,102,19, &Gvp.gamma, 0.1, 5.0, 10, 0, "Change the clarity of the vertex colours");
-       uiBlockEndAlign(block);
-
-       uiDefBut(block, BUT, B_SET_VCOL, "Set VertCol", 980,5,80,20, 0, 0, 0, 0, 0, "Set Vertex colour of selection to current (Shift+K)");
-
+               uiBlockBeginAlign(block);
+               uiDefButF(block, NUMSLI, REDRAWVIEW3D, "Weight:",979,160,194,19, &editbutvweight, 0, 1, 10, 0, "Sets the current vertex group's bone deformation strength");
+               uiDefBut(block, BUT, B_WEIGHT0_0 , "0",                 979,140,40,19, 0, 0, 0, 0, 0, "");
+               uiDefBut(block, BUT, B_WEIGHT1_4 , "1/4",                       1020,140,40,19, 0, 0, 0, 0, 0, "");
+               uiDefBut(block, BUT, B_WEIGHT1_2 , "1/2",                       1060,140,40,19, 0, 0, 0, 0, 0, "");
+               uiDefBut(block, BUT, B_WEIGHT3_4 , "3/4",                       1100,140,40,19, 0, 0, 0, 0, 0, "");
+               uiDefBut(block, BUT, B_WEIGHT1_0 , "1",                 1140,140,33,19, 0, 0, 0, 0, 0, "");
+               
+               uiDefButF(block, NUMSLI, 0, "Opacity ",         979,120,194,19, &Gvp.a, 0.0, 1.0, 0, 0, "The amount of pressure on the brush");
+               uiDefBut(block, BUT, B_OPA0_0 , "0",                    979,100,40,19, 0, 0, 0, 0, 0, "");
+               uiDefBut(block, BUT, B_OPA1_4 , "1/4",                  1020,100,40,19, 0, 0, 0, 0, 0, "");
+               uiDefBut(block, BUT, B_OPA1_2 , "1/2",                  1060,100,40,19, 0, 0, 0, 0, 0, "");
+               uiDefBut(block, BUT, B_OPA3_4 , "3/4",                  1100,100,40,19, 0, 0, 0, 0, 0, "");
+               uiDefBut(block, BUT, B_OPA1_0 , "1",                    1140,100,33,19, 0, 0, 0, 0, 0, "");
+               uiDefButF(block, NUMSLI, 0, "Size ",            979,80,194,19, &Gvp.size, 2.0, 64.0, 0, 0, "The size of the brush");
+               uiBlockEndAlign(block);
+               if(ob){
+               uiBlockBeginAlign(block);
+       uiDefButBitC(block, TOG, OB_DRAWWIRE, REDRAWVIEW3D, "Wire",     979,40,194,19   , &ob->dtx, 0, 0, 0, 0, "Displays the active object's wireframe in shaded drawing modes");
+               uiBlockEndAlign(block);
+               }
+       }
+       else{
+               uiBlockBeginAlign(block);
+               uiDefButF(block, NUMSLI, 0, "R ",                       979,160,194,19, &Gvp.r, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of red used for painting");
+               uiDefButF(block, NUMSLI, 0, "G ",                       979,140,194,19, &Gvp.g, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of green used for painting");
+               uiDefButF(block, NUMSLI, 0, "B ",                       979,120,194,19, &Gvp.b, 0.0, 1.0, B_VPCOLSLI, 0, "The amount of blue used for painting");
+               uiBlockEndAlign(block);
+               uiDefButF(block, NUMSLI, 0, "Opacity ",         979,100,194,19, &Gvp.a, 0.0, 1.0, 0, 0, "The amount of pressure on the brush");
+               uiDefButF(block, NUMSLI, 0, "Size ",            979,80,194,19, &Gvp.size, 2.0, 64.0, 0, 0, "The size of the brush");
+               
+               uiDefButF(block, COL, B_REDR, "",               1176,99,28,80, &(Gvp.r), 0, 0, 0, B_VPCOLSLI, "");
+               uiBlockBeginAlign(block);
+               uiDefButS(block, ROW, B_DIFF, "Mix",                    1212,160,63,19, &Gvp.mode, 1.0, 0.0, 0, 0, "Mix the vertex colours");
+               uiDefButS(block, ROW, B_DIFF, "Add",                    1212,140,63,19, &Gvp.mode, 1.0, 1.0, 0, 0, "Add the vertex colour");
+               uiDefButS(block, ROW, B_DIFF, "Sub",                    1212, 120,63,19, &Gvp.mode, 1.0, 2.0, 0, 0, "Subtract from the vertex colour");
+               uiDefButS(block, ROW, B_DIFF, "Mul",                    1212, 100,63,19, &Gvp.mode, 1.0, 3.0, 0, 0, "Multiply the vertex colour");
+               uiDefButS(block, ROW, B_DIFF, "Filter",         1212, 80,63,19, &Gvp.mode, 1.0, 4.0, 0, 0, "Mix the colours with an alpha factor");
+               
+               uiBlockBeginAlign(block);
+               uiDefButS(block, TOG|BIT|1, 0, "Area",          979,50,81,19, &Gvp.flag, 0, 0, 0, 0, "Vertex paint evaluates the area of the face the brush covers (otherwise vertices only)");
+               uiDefButS(block, TOG|BIT|2, 0, "Soft",          1061,50,112,19, &Gvp.flag, 0, 0, 0, 0, "Use a soft brush");
+               uiDefButS(block, TOG|BIT|3, 0, "Normals",       1174,50,102,19, &Gvp.flag, 0, 0, 0, 0, "Vertex paint applies the vertex normal before painting");
+               
+               uiBlockBeginAlign(block);
+               uiDefBut(block, BUT, B_VPGAMMA, "Set",  979,30,81,19, 0, 0, 0, 0, 0, "Apply Mul and Gamma to vertex colours");
+               uiDefButF(block, NUM, B_DIFF, "Mul:",           1061,30,112,19, &Gvp.mul, 0.1, 50.0, 10, 0, "Set the number to multiply vertex colours with");
+               uiDefButF(block, NUM, B_DIFF, "Gamma:",         1174,30,102,19, &Gvp.gamma, 0.1, 5.0, 10, 0, "Change the clarity of the vertex colours");
+               uiBlockEndAlign(block);
+               
+               uiDefBut(block, BUT, B_SET_VCOL, "Set VertCol", 979,5,81,20, 0, 0, 0, 0, 0, "Set Vertex colour of selection to current (Shift+K)");
+       }
+       
 }
 
-
 static void editing_panel_mesh_texface(void)
 {
+       extern VPaint Gvp;         /* from vpaint */
        uiBlock *block;
        extern TFace *lasttface;
 
@@ -2402,12 +2615,16 @@ static void editing_panel_mesh_texface(void)
                uiDefButC(block, ROW, REDRAWVIEW3D, "Alpha",    720,80,60,19, &lasttface->transp, 2.0, 2.0, 0, 0, "Render polygon transparent, depending on alpha channel of the texture");
 
                uiBlockSetCol(block, TH_AUTO);
+
                uiBlockBeginAlign(block);
-               uiDefBut(block, BUT, B_COPY_TF_MODE, "Copy DrawMode", 600,7,117,28, 0, 0, 0, 0, 0, "Copy the drawmode");
-               uiDefBut(block, BUT, B_COPY_TF_UV, "Copy UV+tex",         721,7,85,28, 0, 0, 0, 0, 0, "Copy UV information and textures");
-               uiDefBut(block, BUT, B_COPY_TF_COL, "Copy VertCol",       809,7,103,28, 0, 0, 0, 0, 0, "Copy vertex colours");
-       }
+               uiDefButF(block, COL, B_VPCOLSLI, "",                   769,40,40,28, &(Gvp.r), 0, 0, 0, 0, "");
+               uiDefBut(block, BUT, B_SET_VCOL, "Set VertCol", 809,40,103,28, 0, 0, 0, 0, 0, "Set Vertex colour of selection to current (Shift+K)");
 
+               uiBlockBeginAlign(block);
+               uiDefBut(block, BUT, B_COPY_TF_MODE, "Copy DrawMode", 600,7,117,28, 0, 0, 0, 0, 0, "Copy the drawmode from active face to selected faces");
+               uiDefBut(block, BUT, B_COPY_TF_UV, "Copy UV+tex",         721,7,85,28, 0, 0, 0, 0, 0, "Copy UV information and textures from active face to selected faces");
+               uiDefBut(block, BUT, B_COPY_TF_COL, "Copy VertCol",       809,7,103,28, 0, 0, 0, 0, 0, "Copy vertex colours from active face to selected faces");
+       }
 }
 
 void do_uvautocalculationbuts(unsigned short event)
@@ -2429,6 +2646,9 @@ void do_uvautocalculationbuts(unsigned short event)
        case B_UVAUTO_WINDOW:
                if(select_area(SPACE_VIEW3D)) calculate_uv_map(event);
                break;
+       case B_UVAUTO_LSCM:
+               unwrap_lscm();
+               break;
        }
 }
 
@@ -2444,34 +2664,40 @@ static void editing_panel_mesh_uvautocalculation(void)
                return;
 
        uiBlockBeginAlign(block);
-       uiDefBut(block, BUT, B_UVAUTO_STD1,"Standard 1/1",100,row,200,butH, 0, 0, 0, 0, 0, "Applies standard UV mapping");
-       uiDefBut(block, BUT, B_UVAUTO_STD2,"1/2",100,row-butHB,66,butH, 0, 0, 0, 0, 0, "Applies standard UV mapping 1/2");
-       uiDefBut(block, BUT, B_UVAUTO_STD4,"1/4",166,row-butHB,67,butH, 0, 0, 0, 0, 0, "Applies standard UV mapping 1/4");
-       uiDefBut(block, BUT, B_UVAUTO_STD8,"1/8",234,row-butHB,66,butH, 0, 0, 0, 0, 0, "Applies standard UV mapping 1/8");
+       uiDefBut(block, BUT, B_UVAUTO_LSCM,"LSCM Unwrap",100,row,200,butH, 0, 0, 0, 0, 0, "Applies conformal UV mapping, preserving local angles");
        uiBlockEndAlign(block);
-       row-= 2*butHB+butS;
+       row-= butHB+butS;
 
        uiBlockBeginAlign(block);
-       uiDefBut(block, BUT, B_UVAUTO_BOUNDS1,"Bounds 1/1",100,row,200,butH, 0, 0, 0, 0, 0, "Applies planar UV mapping with bounds 1/1");
-       uiDefBut(block, BUT, B_UVAUTO_BOUNDS2,"1/2",100,row-butHB,66,butH, 0, 0, 0, 0, 0, "Applies planar UV mapping with bounds 1/2");
-       uiDefBut(block, BUT, B_UVAUTO_BOUNDS4,"1/4",166,row-butHB,67,butH, 0, 0, 0, 0, 0, "Applies planar UV mapping with bounds 1/4");
-       uiDefBut(block, BUT, B_UVAUTO_BOUNDS8,"1/8",234,row-butHB,66,butH, 0, 0, 0, 0, 0, "Applies planar UV mapping with bounds 1/8");
-       uiDefBut(block, BUT, B_UVAUTO_WINDOW,"From Window",100,row-2*butH,200,butH, 0, 0, 0, 0, 0, "Applies planar UV mapping from window");
+       uiDefBut(block, BUT, B_UVAUTO_STD1,"Standard",100,row,100,butH, 0, 0, 0, 0, 0, "Applies standard UV mapping");
+       uiDefBut(block, BUT, B_UVAUTO_STD2,"/2",200,row,33,butH, 0, 0, 0, 0, 0, "Applies standard UV mapping 1/2");
+       uiDefBut(block, BUT, B_UVAUTO_STD4,"/4",233,row,34,butH, 0, 0, 0, 0, 0, "Applies standard UV mapping 1/4");
+       uiDefBut(block, BUT, B_UVAUTO_STD8,"/8",267,row,33,butH, 0, 0, 0, 0, 0, "Applies standard UV mapping 1/8");
        uiBlockEndAlign(block);
-       row-= 3*butHB+butS;
+       row-= butHB+butS;
+
+       uiBlockBeginAlign(block);
+       uiDefBut(block, BUT, B_UVAUTO_BOUNDS1,"Bounds",100,row,100,butH, 0, 0, 0, 0, 0, "Applies planar UV mapping with bounds 1/1");
+       uiDefBut(block, BUT, B_UVAUTO_BOUNDS2,"/2",200,row,33,butH, 0, 0, 0, 0, 0, "Applies planar UV mapping with bounds 1/2");
+       uiDefBut(block, BUT, B_UVAUTO_BOUNDS4,"/4",233,row,34,butH, 0, 0, 0, 0, 0, "Applies planar UV mapping with bounds 1/4");
+       uiDefBut(block, BUT, B_UVAUTO_BOUNDS8,"/8",267,row,33,butH, 0, 0, 0, 0, 0, "Applies planar UV mapping with bounds 1/8");
+       uiDefBut(block, BUT, B_UVAUTO_WINDOW,"From Window",100,row-butH,200,butH, 0, 0, 0, 0, 0, "Applies planar UV mapping from window");
+       uiBlockEndAlign(block);
+       row-= 2*butHB+butS;
 
        uiBlockBeginAlign(block);
-       uiDefButS(block,ROW,REDRAWVIEW3D,"No Edges",100,row,200,butH,&facesel_draw_edges, 2.0, 0, 0, 0,  "Don't draw edges of deselected faces in 3D view");
-       uiDefButS(block,ROW,REDRAWVIEW3D,"Draw Edges",100,row-butH,200,butH,&facesel_draw_edges, 2.0, 1.0, 0, 0,  "Draw edges of deselected faces z-buffered in 3D view");
-       uiDefButS(block,ROW,REDRAWVIEW3D,"All Edges",100,row-2*butH,200,butH,&facesel_draw_edges, 2.0, 2.0, 0, 0,  "Draw all edges of deselected faces in 3D view");
+       uiDefButI(block, TOG|BIT|7, REDRAWVIEW3D, "Draw Faces", 100,row,200,butH, &G.f, 0, 0, 0, 0, "Displays all faces as shades");
+       uiDefButI(block,TOG|BIT|18,REDRAWVIEW3D,"Draw Edges",100,row-butHB,200,butH,&G.f, 2.0, 0, 0, 0,  "Displays edges of visible faces");
+       uiDefButI(block,TOG|BIT|21,REDRAWVIEW3D,"Draw Hidden Edges",100,row-2*butHB,200,butH,&G.f, 2.0, 1.0, 0, 0,  "Displays edges of hidden faces");
+       uiDefButI(block,TOG|BIT|20,REDRAWVIEW3D,"Draw Seams",100,row-3*butHB,200,butH,&G.f, 2.0, 2.0, 0, 0,  "Displays UV unwrapping seams");
        uiBlockEndAlign(block);
-       row-= 3*butHB+butS;
+       row-= 4*butHB+butS;
 
        row= 180;
 
        uiBlockBeginAlign(block);
        uiDefBut(block, BUT, B_UVAUTO_CUBE,"Cube",315,row,200,butH, 0, 0, 0, 0, 0, "Applies cube UV mapping");
-       uiDefButF(block, NUM,B_UVAUTO_CUBESIZE ,"Size:",315,row-butHB,200,butH, &uv_calc_cubesize, 0.0001, 100.0, 10, 0, "Defines the cubemap size");
+       uiDefButF(block, NUM,B_UVAUTO_CUBESIZE ,"Size:",315,row-butHB,200,butH, &uv_calc_cubesize, 0.0001, 100.0, 10, 3, "Defines the cubemap size");
        uiBlockEndAlign(block);
        row-= 2*butHB+butS;
 
@@ -2482,7 +2708,7 @@ static void editing_panel_mesh_uvautocalculation(void)
 
        uiBlockBeginAlign(block);
        uiDefBut(block, BUT, B_UVAUTO_CYLINDER,"Cylinder",315,row,200,butH, 0, 0, 0, 0, 0, "Applies cylindrical UV mapping");
-       uiDefButF(block, NUM,B_UVAUTO_CYLRADIUS ,"Radius:",315,row-butHB,200,butH, &uv_calc_radius, 0.1, 100.0, 10, 0, "Defines the radius of the UV mapping cylinder");
+       uiDefButF(block, NUM,B_UVAUTO_CYLRADIUS ,"Radius:",315,row-butHB,200,butH, &uv_calc_radius, 0.1, 100.0, 10, 3, "Defines the radius of the UV mapping cylinder");
        uiBlockEndAlign(block);
        row-= 2*butHB+butS;
 
@@ -2579,6 +2805,8 @@ void editing_panels()
                cam= ob->data;
                editing_panel_links(ob); // no editmode!
                editing_panel_camera_type(ob, cam);
+               /* yafray: extra panel for dof parameters */
+               if (G.scene->r.renderer==R_YAFRAY) editing_panel_camera_yafraydof(ob, cam);
                break;
 
        case OB_ARMATURE: