Long waited feature: Render Baking
[blender.git] / source / blender / src / space.c
index 87390954932c4f2c18f0f0bb8215c4f6d56fe752..078c6f6a8864d67f0ed338607cf05a99e04c6f0b 100644 (file)
@@ -52,6 +52,7 @@
 
 #include "BLI_blenlib.h"
 #include "BLI_arithb.h"
+#include "BLI_gsqueue.h"
 #include "BLI_linklist.h"
 
 #include "DNA_action_types.h"
@@ -61,6 +62,8 @@
 #include "DNA_image_types.h"
 #include "DNA_ipo_types.h"
 #include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_modifier_types.h" /* used for select grouped hooks */
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
@@ -80,6 +83,7 @@
 #include "BKE_group.h"
 #include "BKE_ipo.h"
 #include "BKE_main.h"
+#include "BKE_mesh.h"
 #include "BKE_node.h"
 #include "BKE_scene.h"
 #include "BKE_utildefines.h"
 #include "BIF_poseobject.h"
 #include "BIF_outliner.h"
 #include "BIF_resources.h"
+#include "BIF_retopo.h"
 #include "BIF_screen.h"
 #include "BIF_space.h"
 #include "BIF_toets.h"
 #include "BDR_drawmesh.h"
 #include "BDR_drawobject.h"
 #include "BDR_imagepaint.h"
+#include "BDR_sculptmode.h"
 #include "BDR_unwrapper.h"
 
 #include "BLO_readfile.h" /* for BLO_blendhandle_close */
 #include "mydevice.h"
 #include "blendef.h"
 #include "datatoc.h"
+#include "multires.h"
 
 #include "BIF_transform.h"
 
@@ -608,13 +615,34 @@ static void select_same_group(Object *ob) /* Select objects in the same group as
        if (!group || !ob)
                return;
        
-       for (base= FIRSTBASE; base; base= base->next)
-               if (object_in_group(base->object, group)) {
+       for (base= FIRSTBASE; base; base= base->next) {
+               if (!(base->flag & SELECT) && object_in_group(base->object, group)) {
                        base->flag |= SELECT;
                        base->object->flag |= SELECT;
                }
+       }
 }
 
+static void select_object_hooks(Object *ob)    /* Select objects in the same group as the active */
+{
+       Base *base;
+       ModifierData *md;
+       HookModifierData *hmd;
+       
+       if (!ob)
+               return;
+       
+       for (md = ob->modifiers.first; md; md=md->next) {
+               if (md->type==eModifierType_Hook) {
+                       hmd= (HookModifierData*) md;
+                       if (hmd->object && !(hmd->object->flag & SELECT)) {
+                               base= object_in_scene(hmd->object, G.scene);
+                               base->flag |= SELECT;
+                               base->object->flag |= SELECT;
+                       }
+               }
+       }
+}
 
 static void select_same_parent(Object *ob)     /* Select objects woth the same parent as the active (siblings), parent can be NULL also */
 {
@@ -662,6 +690,7 @@ void select_object_grouped(short nr)
        else if(nr==4) select_same_parent(OBACT);       
        else if(nr==5) select_same_type(OBACT); 
        else if(nr==7) select_same_group(OBACT);
+       else if(nr==8) select_object_hooks(OBACT);
        
        
        
@@ -680,13 +709,14 @@ static void select_object_grouped_menu(void)
 
        /* make menu string */
        
-       str= MEM_mallocN(180, "groupmenu");
+       str= MEM_mallocN(512, "groupmenu");
        strcpy(str, "Select Grouped%t|Children%x1|"
                    "Immediate Children%x2|Parent%x3|"
                    "Siblings (Shared Parent)%x4|"
                    "Objects of Same Type%x5|"
                                "Objects on Shared Layers%x6|"
-                "Objects in Same Group%x7|");
+                "Objects in Same Group%x7|"
+                "Object Hooks%x8|");
 
        /* here we go */
        
@@ -752,6 +782,8 @@ void BIF_undo_push(char *str)
                else if (G.obedit->type==OB_ARMATURE)
                        undo_push_armature(str);
        }
+       else if(G.f & G_SCULPTMODE) {
+       }
        else {
                if(U.uiflag & USER_GLOBALUNDO) 
                        BKE_write_undo(str);
@@ -771,11 +803,16 @@ void BIF_undo(void)
                        vpaint_undo();
                else if(G.f & G_TEXTUREPAINT)
                        imagepaint_undo();
+               else if(G.f & G_SCULPTMODE)
+                       sculptmode_undo();
                else if(curarea->spacetype==SPACE_IMAGE && (G.sima->flag & SI_DRAWTOOL))
                        imagepaint_undo();
                else {
                        /* now also in faceselect mode */
                        if(U.uiflag & USER_GLOBALUNDO) {
+                               if(G.f & G_SCULPTMODE)
+                                       set_sculpt_object(NULL);
+
                                BKE_undo_step(1);
                                sound_initialize_sounds();
                        }
@@ -796,6 +833,8 @@ void BIF_redo(void)
                        vpaint_undo();
                else if(G.f & G_TEXTUREPAINT)
                        imagepaint_undo();
+               else if(G.f & G_SCULPTMODE)
+                       sculptmode_redo();
                else if(curarea->spacetype==SPACE_IMAGE && (G.sima->flag & SI_DRAWTOOL))
                        imagepaint_undo();
                else {
@@ -820,6 +859,8 @@ void BIF_undo_menu(void)
                        ;
                else if(G.f & G_VERTEXPAINT)
                        ;
+               else if(G.f & G_SCULPTMODE)
+                       sculptmode_undo_menu();
                else {
                        if(U.uiflag & USER_GLOBALUNDO) {
                                char *menu= BKE_undo_menu_string();
@@ -850,7 +891,8 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
        if(val) {
 
                if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
-               if(event==MOUSEY || event==MOUSEX) return;
+
+               //if(event==MOUSEY || event==MOUSEX) return;
                
                if(event==UI_BUT_EVENT) do_butspace(val); /* temporal, view3d deserves own queue? */
                
@@ -863,6 +905,23 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                        else if (event==RIGHTMOUSE) event = LEFTMOUSE;
                }
 
+               if(!G.obedit && (G.f & G_SCULPTMODE)) {
+                       if(G.scene->sculptdata.propset) {
+                               sculptmode_propset(event);
+                               return;
+                       }
+                       else if(event!=LEFTMOUSE && event!=MIDDLEMOUSE && (event==MOUSEY || event==MOUSEX)) {
+                               if(!bwin_qtest(sa->win))
+                                       allqueue(REDRAWVIEW3D, 0);
+                       }
+               }
+
+               /* Handle retopo painting */
+               if(retopo_mesh_paint_check()) {
+                       if(!retopo_paint(event))
+                               return;
+               }
+
                /* run any view3d event handler script links */
                if (event && sa->scriptlink.totscript)
                        if (BPY_do_spacehandlers(sa, event, SPACEHANDLER_VIEW3D_EVENT))
@@ -1007,10 +1066,16 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                         * based on user preference USER_LMOUSESELECT
                         */
                        case LEFTMOUSE: 
-                               if ((G.obedit) || !(G.f&(G_VERTEXPAINT|G_WEIGHTPAINT|G_TEXTUREPAINT))) {
+                               if ((G.obedit) || !(G.f&(G_SCULPTMODE|G_VERTEXPAINT|G_WEIGHTPAINT|G_TEXTUREPAINT))) {
                                        mouse_cursor();
                                }
-                               else if (G.f & G_WEIGHTPAINT){
+                               else if (G.f & G_SCULPTMODE) {
+                                       if(G.qual==LR_SHIFTKEY+LR_CTRLKEY)
+                                               sculptmode_pmv(0);
+                                       else if(!G.scene->sculptdata.propset)
+                                               sculpt();
+                               }
+                               else if (G.f & G_WEIGHTPAINT) {
                                        weight_paint();
                                }
                                else if (G.f & G_VERTEXPAINT) {
@@ -1062,6 +1127,8 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                        face_select();
                                else if( G.f & (G_VERTEXPAINT|G_TEXTUREPAINT))
                                        sample_vpaint();
+                               else if((G.f & G_SCULPTMODE) && G.qual==LR_SHIFTKEY+LR_CTRLKEY)
+                                       sculptmode_pmv(1);
                                else
                                        mouse_select(); /* does poses too */
                                break;
@@ -1125,30 +1192,24 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                
                                doredraw= 1;
                                break;
-                       
+
                        case ONEKEY:
                                if(G.qual==LR_CTRLKEY) {
-                                       if(ob && ob->type == OB_MESH) {
-                                               flip_subdivison(ob, 1);
-                                       }
+                                       flip_subdivison(1);
                                }
                                else do_layer_buttons(0); 
                                break;
                                
                        case TWOKEY:
                                if(G.qual==LR_CTRLKEY) {
-                                       if(ob && ob->type == OB_MESH) {
-                                               flip_subdivison(ob, 2);
-                                       }
+                                       flip_subdivison(2);
                                }
                                else do_layer_buttons(1); 
                                break;
                                
                        case THREEKEY:
                                if(G.qual==LR_CTRLKEY) {
-                                       if(ob && ob->type == OB_MESH) {
-                                               flip_subdivison(ob, 3);
-                                       }
+                                       flip_subdivison(3);
                                }
                                else if ( G.qual == (LR_SHIFTKEY | LR_ALTKEY | LR_CTRLKEY) ) {
                                        if ( (G.obedit) && (G.obedit->type==OB_MESH) )
@@ -1159,9 +1220,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                
                        case FOURKEY:
                                if(G.qual==LR_CTRLKEY) {
-                                       if(ob && ob->type == OB_MESH) {
-                                               flip_subdivison(ob, 4);
-                                       }
+                                       flip_subdivison(4);
                                }
                                else if ( G.qual == (LR_SHIFTKEY | LR_ALTKEY | LR_CTRLKEY) ) {
                                        if ( (G.obedit) && (G.obedit->type==OB_MESH) )
@@ -1254,7 +1313,12 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                if(G.qual==LR_ALTKEY)
                                        view3d_edit_clipping(v3d);
                                else if(G.qual==LR_SHIFTKEY)
-                                       set_render_border();
+                               {
+                                       if(G.vd->persp==2)
+                                               set_render_border();
+                                       else
+                                               view3d_border_zoom();
+                               }
                                else if(G.qual==LR_CTRLKEY) {
                                        if(okee("Bake all selected")) {
                                                extern void softbody_bake(Object *ob);
@@ -1264,6 +1328,8 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                                fluidsimBake(NULL);
                                        }
                                }
+                               else if(G.qual== (LR_ALTKEY|LR_CTRLKEY))
+                                       objects_bake_render();
                                else if(G.qual==0)
                                        borderselect();
                                break;
@@ -1321,11 +1387,14 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                        imagestodisplist();
                                }
                                else if((G.qual==0)){
-                                       pupval= pupmenu("Draw mode%t|BoundBox %x1|Wire %x2|OpenGL Solid %x3|Shaded Solid %x4|Textured Solid %x5");
-                                       if(pupval>0) {
-                                               G.vd->drawtype= pupval;
-                                               doredraw= 1;
-                                       
+                                       if(G.f & G_SCULPTMODE)
+                                               sculptmode_propset_init(DKEY);
+                                       else {
+                                               pupval= pupmenu("Draw mode%t|BoundBox %x1|Wire %x2|OpenGL Solid %x3|Shaded Solid %x4|Textured Solid %x5");
+                                               if(pupval>0) {
+                                                       G.vd->drawtype= pupval;
+                                                       doredraw= 1;
+                                               }
                                        }
                                }
                                
@@ -1476,6 +1545,15 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                }
                                else if(G.f & G_FACESELECT)
                                        hide_tface();
+                               else if(G.f & G_SCULPTMODE) {
+                                       if(G.qual==LR_ALTKEY) {
+                                               waitcursor(1);
+                                               sculptmode_pmv_off(get_mesh(ob));
+                                               BIF_undo_push("Partial mesh hide");
+                                               allqueue(REDRAWVIEW3D,0);
+                                               waitcursor(0);
+                                       }
+                               }
                                else if(ob && (ob->flag & OB_POSEMODE)) {
                                        if (G.qual==0)
                                                hide_selected_pose_bones();
@@ -1638,7 +1716,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                        case OKEY:
                                if (G.obedit) {
                                        if (G.qual==LR_SHIFTKEY) {
-                                               G.scene->prop_mode = (G.scene->prop_mode+1)%6;
+                                               G.scene->prop_mode = (G.scene->prop_mode+1)%7;
                                                allqueue(REDRAWHEADERS, 0);
                                        }
                                        else if((G.qual==LR_ALTKEY)) {
@@ -1651,10 +1729,8 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                                allqueue(REDRAWHEADERS, 0);
                                        }
                                }
-                               else if((G.qual==LR_SHIFTKEY)) {
-                                       if(ob && ob->type == OB_MESH) {
-                                               flip_subdivison(ob, -1);
-                                       }
+                               else if((G.qual==LR_SHIFTKEY || G.qual==(LR_ALTKEY|LR_SHIFTKEY))) {
+                                       flip_subdivison(-1);
                                }
                                else if(G.qual==LR_ALTKEY) {
                                        if(okee("Clear origin")) {
@@ -1671,8 +1747,11 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                                else
                                                        make_parent();
                                        }
+                                       
                                        else if(G.qual==LR_ALTKEY && G.obedit->type==OB_ARMATURE)
                                                clear_bone_parent();
+                                       else if((G.qual==0) && (G.obedit->type==OB_ARMATURE)) 
+                                               select_bone_parent();
                                        else if((G.qual==0) && G.obedit->type==OB_MESH)
                                                separatemenu();
                                        else if ((G.qual==0) && ELEM(G.obedit->type, OB_CURVE, OB_SURF))
@@ -1696,6 +1775,10 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                }
                                else if(G.qual==LR_ALTKEY)
                                        clear_parent();
+                               else if(G.qual==(LR_ALTKEY|LR_CTRLKEY))
+                                       make_proxy();
+                               else if((G.qual==0) && (OBACT) && (OBACT->type==OB_ARMATURE) && (OBACT->flag & OB_POSEMODE))
+                                       select_bone_parent();
                                else if((G.qual==0)) {
                        start_game();
                                }
@@ -1911,7 +1994,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                break;
                        case XKEY:
                        case DELKEY:
-                               if(G.qual==0)
+                               if(G.qual==0 || G.qual==LR_SHIFTKEY)
                                        delete_context_selected();
                                break;
                        case YKEY:
@@ -1995,19 +2078,33 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                break;
                        
                        case PAGEUPKEY:
-                               if(G.qual==LR_CTRLKEY)
-                                       movekey_obipo(1);
-                               else if((G.qual==0))
-                                       nextkey_obipo(1);       /* in editipo.c */
+                               if(G.f & G_SCULPTMODE) {
+                                       if(ob && ob->type == OB_MESH && ((Mesh*)ob->data)->mr) {
+                                               ((Mesh*)ob->data)->mr->newlvl= ((Mesh*)ob->data)->mr->current+1;
+                                               multires_set_level(ob,ob->data);
+                                       }
+                               } else {
+                                       if(G.qual==LR_CTRLKEY)
+                                               movekey_obipo(1);
+                                       else if((G.qual==0))
+                                               nextkey_obipo(1);       /* in editipo.c */
+                               }
                                break;
 
                        case PAGEDOWNKEY:
-                               if(G.qual==LR_CTRLKEY)
-                                       movekey_obipo(-1);
-                               else if((G.qual==0))
-                                       nextkey_obipo(-1);
+                               if(G.f & G_SCULPTMODE) {
+                                       if(ob && ob->type == OB_MESH && ((Mesh*)ob->data)->mr) {
+                                               ((Mesh*)ob->data)->mr->newlvl= ((Mesh*)ob->data)->mr->current-1;
+                                               multires_set_level(ob,ob->data);
+                                       }
+                               } else {
+                                       if(G.qual==LR_CTRLKEY)
+                                               movekey_obipo(-1);
+                                       else if((G.qual==0))
+                                               nextkey_obipo(-1);
+                               }
                                break;
-                               
+
                        case PAD0: case PAD1: case PAD2: case PAD3: case PAD4:
                        case PAD5: case PAD6: case PAD7: case PAD8: case PAD9:
                        case PADENTER:
@@ -2018,6 +2115,14 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                if ( (G.qual==LR_CTRLKEY)
                                         && (G.obedit) && (G.obedit->type==OB_MESH) )
                                        select_less();
+                               else if ( (G.qual==LR_CTRLKEY)
+                                        && (G.obedit) && (G.obedit->type==OB_CURVE) )
+                                       select_less_nurb();
+                               /*
+                               else if ( (G.qual==LR_CTRLKEY)
+                                        && (G.obedit) && (G.obedit->type==OB_SURF) )
+                                       select_less_nurb(); 
+                               */
                                else {
                                        persptoetsen(event);
                                        doredraw= 1;
@@ -2028,6 +2133,14 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                if ( (G.qual==LR_CTRLKEY)
                                         && (G.obedit) && (G.obedit->type==OB_MESH) )
                                        select_more();
+                               else if ( (G.qual==LR_CTRLKEY)
+                                        && (G.obedit) && (G.obedit->type==OB_CURVE) )
+                                       select_more_nurb();
+                               /*
+                               else if ( (G.qual==LR_CTRLKEY)
+                                        && (G.obedit) && (G.obedit->type==OB_SURF) )
+                                       select_more_nurb();
+                               */
                                else {
                                        persptoetsen(event);
                                        doredraw= 1;
@@ -2082,6 +2195,8 @@ static void initview3d(ScrArea *sa)
        vd->gridflag |= V3D_SHOW_Y;
        vd->gridflag |= V3D_SHOW_FLOOR;
        vd->gridflag &= ~V3D_SHOW_Z;
+
+       vd->depths= NULL;
 }
 
 
@@ -2233,7 +2348,7 @@ static void winqreadipospace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                sethandles_ipo(HD_ALIGN);
                        break;
                case JKEY:
-                       if((G.qual==0))
+                       if((G.qual==LR_CTRLKEY))
                                join_ipo_menu();
                        break;
                case KKEY:
@@ -2244,10 +2359,20 @@ static void winqreadipospace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                doredraw= 1;
                        }
                        break;
+               case MKEY:
+                       if((G.qual==0))
+                               ipo_mirror_menu();
+                       break;
                case NKEY:
                        toggle_blockhandler(sa, IPO_HANDLER_PROPERTIES, UI_PNL_TO_MOUSE);
                        doredraw= 1;
                        break;
+               case OKEY: 
+                       if(G.qual==LR_SHIFTKEY) 
+                               smooth_ipo();
+                       else
+                               clean_ipo(sipo->ipo, 1);
+                       break;
                case RKEY:
                        if((G.qual==0))
                                ipo_record();
@@ -2429,10 +2554,10 @@ static void info_user_themebuts(uiBlock *block, short y1, short y2, short y3)
        }
        else if(th_curcol==TH_BUT_DRAWTYPE) {
                uiBlockBeginAlign(block);
-               uiDefButC(block, ROW, B_UPDATE_THEME, "Minimal",        465,y3,100,20,  col, 2.0, 0.0, 0, 0, "");
-               uiDefButC(block, ROW, B_UPDATE_THEME, "Shaded", 565,y3,100,20,  col, 2.0, 1.0, 0, 0, "");
-               uiDefButC(block, ROW, B_UPDATE_THEME, "Rounded",        465,y2,100,20,  col, 2.0, 2.0, 0, 0, "");
-               uiDefButC(block, ROW, B_UPDATE_THEME, "OldSkool",       565,y2,100,20,  col, 2.0, 3.0, 0, 0, "");
+               uiDefButC(block, ROW, B_UPDATE_THEME, "Minimal", 465,y3,100,20,  col, 2.0, (float) TH_MINIMAL, 0, 0, "");
+               uiDefButC(block, ROW, B_UPDATE_THEME, "Shaded", 565,y3,100,20,  col, 2.0, (float) TH_SHADED, 0, 0, "");
+               uiDefButC(block, ROW, B_UPDATE_THEME, "Rounded", 465,y2,100,20,  col, 2.0, (float) TH_ROUNDED, 0, 0, "");
+               uiDefButC(block, ROW, B_UPDATE_THEME, "OldSkool", 565,y2,100,20,  col, 2.0, (float) TH_OLDSKOOL, 0, 0, "");
                uiBlockEndAlign(block);
        }
        else {
@@ -2720,7 +2845,11 @@ void drawinfospace(ScrArea *sa, void *spacedata)
                        &U.rvibright, 0, 10, 0, 0,
                        "The brightness of the icon");
                uiBlockEndAlign(block);
-               
+
+        uiDefButS(block, NUM, B_DRAWINFO, "Rotation Angle:",
+                       (xpos+edgsp+(3*mpref)+(4*midsp)),y1,(mpref),buth,
+                       &U.pad_rot_angle, 0, 90, 0, 0,
+                       "The rotation step for numerical pad keys (2 4 6 8)");
 
                uiDefBut(block, LABEL,0,"Select with:",
                        (xpos+(2*edgsp)+(3*mpref)+(3*midsp)),y6label,mpref,buth,
@@ -2987,6 +3116,18 @@ void drawinfospace(ScrArea *sa, void *spacedata)
                }
 
        } else if (U.userpref == 4) { /* system & opengl */
+
+#ifdef WITH_VERSE
+               uiDefBut(block, TEX, 0, "Verse Master: ",
+                       (xpos+edgsp),y3label+buth+5,mpref*2,buth,
+                       U.versemaster, 1.0, 63.0, 0, 0,
+                       "The Verse Master-server IP");
+               uiDefBut(block, TEX, 0, "Verse Username: ",
+                       (xpos+edgsp)+mpref*2+10,y3label+buth+5,mpref*2,buth,
+                       U.verseuser, 1.0, 63.0, 0, 0,
+                       "The Verse user name");
+#endif
+
                uiDefBut(block, LABEL,0,"Solid OpenGL light:",
                        xpos+edgsp, y3label, mpref, buth,
                        0, 0, 0, 0, 0, "");
@@ -3110,7 +3251,6 @@ void drawinfospace(ScrArea *sa, void *spacedata)
                        (xpos+edgsp+(4*mpref)+(4*midsp)),y1,mpref,buth,
                        &(U.uiflag), 0, 0, 0, 0, "Hide files/datablocks that start with a dot(.*)");
 
-
                uiDefBut(block, LABEL,0,"OpenGL:",
                        (xpos+edgsp+(5*midsp)+(5*mpref)),y5label,mpref,buth,
                        0, 0, 0, 0, 0, "");
@@ -3821,6 +3961,9 @@ static void winqreadseqspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                scrarea_queue_winredraw(curarea);
                        }
                        break;
+               case RKEY:
+                       reassign_inputs_seq_effect();
+                       break;
                case SKEY:
                        if((G.qual==LR_SHIFTKEY))
                                seq_snap_menu();
@@ -4168,7 +4311,7 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                break;
                        case OKEY:
                                if (G.qual==LR_SHIFTKEY) {
-                                       G.scene->prop_mode = (G.scene->prop_mode+1)%6;
+                                       G.scene->prop_mode = (G.scene->prop_mode+1)%7;
                                        allqueue(REDRAWHEADERS, 0);
                                }
                                else if((G.qual==0)) {
@@ -4249,11 +4392,26 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                        
                break;
        case NKEY:
-               if(G.qual==0) {
+               if(G.qual==LR_ALTKEY) {
+                       new_image_sima();
+               }
+               else if(G.qual==0) {
                        toggle_blockhandler(sa, IMAGE_HANDLER_PROPERTIES, UI_PNL_TO_MOUSE);
                        scrarea_queue_winredraw(sa);
                }
                break;
+       case OKEY:
+               if (G.qual & LR_ALTKEY)
+                       open_image_sima(G.qual & LR_CTRLKEY);
+               break;
+       case RKEY:
+               if(G.qual==LR_ALTKEY)
+                       reload_image_sima();
+               break;
+       case SKEY:
+               if(G.qual & LR_ALTKEY)
+                       save_image_sima();
+               break;
        case ESCKEY:
                if(sima->flag & SI_PREVSPACE) {
                        /* only allow ESC once */
@@ -4349,6 +4507,23 @@ static void winqreadoopsspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                        else
                                outliner_toggle_visible(sa);
                        break;
+               case FKEY: 
+                       {
+                               /* search */
+                               int search_flags=0, again=0;
+                               
+                               /* CTRL=case sensitive, SHIFT=find again, ALT=complete */
+                               if (G.qual & LR_CTRLKEY) search_flags |= 1;
+                               if (G.qual & LR_ALTKEY) search_flags |= 8;
+                               if (G.qual & LR_SHIFTKEY) again = 1;
+                               
+                               outliner_find_panel(sa, again, search_flags);                           
+                       }
+                       break;
+               case XKEY:
+               case DELKEY:
+                       outliner_del(sa);
+                       break;
                case WKEY:
                        outliner_operation_menu(sa);
                        break;
@@ -4887,13 +5062,20 @@ void freespacelist(ScrArea *sa)
                        }
                        if(vd->localvd) MEM_freeN(vd->localvd);
                        if(vd->clipbb) MEM_freeN(vd->clipbb);
+                       if(vd->depths) {
+                               if(vd->depths->depths) MEM_freeN(vd->depths->depths);
+                               MEM_freeN(vd->depths);
+                               vd->depths= NULL;
+                       }
+                       retopo_free_view_data(vd);
                        if(G.vd==vd) G.vd= NULL;
                        if(vd->ri) { 
                                BIF_view3d_previewrender_free(vd);
                        }
                }
                else if(sl->spacetype==SPACE_OOPS) {
-                       free_oopspace((SpaceOops *)sl);
+                       SpaceOops *so= (SpaceOops *) sl;
+                       free_oopspace(so);
                }
                else if(sl->spacetype==SPACE_IMASEL) {
                        free_imasel((SpaceImaSel *)sl);
@@ -4945,6 +5127,7 @@ void duplicatespacelist(ScrArea *newarea, ListBase *lb1, ListBase *lb2)
                }
                else if(sl->spacetype==SPACE_VIEW3D) {
                        BIF_view3d_previewrender_free((View3D *)sl);
+                       ((View3D*)sl)->depths= NULL;
                }
                else if(sl->spacetype==SPACE_OOPS) {
                        SpaceOops *so= (SpaceOops *)sl;