Made weight-painting more bearable :)
[blender.git] / source / blender / src / toets.c
index ff8273c6d1587e5929adaaf010df6e48c38cfb92..d1b0844647e4c8a65e53736c3ac1df4ecfcac59c 100644 (file)
 #include <string.h>
 #include <math.h>
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 #ifdef WIN32
 #include "BLI_winstuff.h"
 #endif
 #include "BKE_action.h"
 #include "BKE_anim.h"
 #include "BKE_blender.h"
+#include "BKE_depsgraph.h"
 #include "BKE_displist.h"
 #include "BKE_global.h"
 #include "BKE_ipo.h"
-#include "BKE_ika.h"
 #include "BKE_key.h"
 #include "BKE_scene.h"
 #include "BKE_utildefines.h"
@@ -79,6 +75,7 @@
 #include "BIF_interface.h"
 #include "BIF_poseobject.h"
 #include "BIF_renderwin.h"
+#include "BKE_object.h"
 #include "BIF_screen.h"
 #include "BIF_space.h"
 #include "BIF_toets.h"
 #include "BSE_edit.h"
 #include "BSE_editipo.h"
 #include "BSE_headerbuttons.h"
+#include "BSE_seqaudio.h"
 
 #include "blendef.h"
-#include "render.h"
+#include "render.h"            // darn schrijfplaatje() (ton)
 
 #include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
 
 #include "BIF_poseobject.h"
 
-/* only used in toets.c */
+/* only used in toets.c and initrender.c */
 /* this function doesn't really belong here */
 /* ripped from render module */
 void schrijfplaatje(char *name);
 
 
-void write_imag(char *name)
+static void write_imag(char *name)
 {
        /* from file select */
        char str[256];
@@ -177,6 +175,7 @@ void schrijfplaatje(char *name)
 
        if(ibuf) {
                ibuf->rect= (unsigned int *) R.rectot;
+//             ibuf->rect_float = R.rectftot;
 
                if(R.r.planes == 8) IMB_cspace(ibuf, rgb_to_bw);
 
@@ -410,11 +409,7 @@ void persptoetsen(unsigned short event)
                }
                else if(event==PAD9) {
                        countall();
-                       do_all_ipos();
-                       do_all_keys();
-                       do_all_actions();
-                       do_all_ikas();
-                       test_all_displists();
+                       update_for_newframe();
                        
                        reset_slowparents();    /* editobject.c */
                }
@@ -534,7 +529,7 @@ int blenderqread(unsigned short event, short val)
        
        if(val==0) return 1;
        if(event==MOUSEY || event==MOUSEX) return 1;
-       if (G.flags & G_FLAGS_AUTOPLAY) return 1;
+       if (G.flags & G_FILE_AUTOPLAY) return 1;
 
        if (curarea && curarea->spacetype==SPACE_TEXT) textspace= 1;
        else if (curarea && curarea->spacetype==SPACE_SCRIPT) textspace= 1;
@@ -685,7 +680,8 @@ int blenderqread(unsigned short event, short val)
        case DOWNARROWKEY:
                if(textediting==0 && textspace==0) {
 
-#ifdef _WIN32  // FULLSCREEN
+#if 0
+//#ifdef _WIN32        // FULLSCREEN
                        if(event==DOWNARROWKEY){
                                if (G.qual==LR_ALTKEY)
                                        mainwindow_toggle_fullscreen(0);
@@ -712,7 +708,8 @@ int blenderqread(unsigned short event, short val)
        case UPARROWKEY:
                if(textediting==0 && textspace==0) {
 
-#ifdef _WIN32  // FULLSCREEN
+#if 0
+//#ifdef _WIN32        // FULLSCREEN
                        if(event==UPARROWKEY){ 
                                if(G.qual==LR_ALTKEY)
                                        mainwindow_toggle_fullscreen(1);
@@ -734,7 +731,13 @@ int blenderqread(unsigned short event, short val)
                break;
 
        case ESCKEY:
-               sound_stop_all_sounds();
+               sound_stop_all_sounds();        // whats this?
+               
+               /* stop playback on ESC always */
+               rem_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM);
+               audiostream_stop();
+               allqueue(REDRAWALL, 0);
+               
                break;
        case TABKEY:
                if(G.qual==0) {
@@ -759,15 +762,16 @@ int blenderqread(unsigned short event, short val)
                        Object *ob= OBACT;
                        if(ob) {
                                if(ob->type==OB_ARMATURE) {
-                                       if(G.obpose) exit_posemode(1);
+                                       if(ob->flag & OB_POSEMODE) exit_posemode();
                                        else enter_posemode();
                                }
                                else if(ob->type==OB_MESH) {
                                        if(ob==G.obedit) EM_selectmode_menu();
+                                       else set_wpaint();
                                }
                        }
                }
-               else if(G.qual==LR_SHIFTKEY) {
+               else if(G.qual==LR_SHIFTKEY) {  // ??
                        if(G.obedit)
                                exit_editmode(2); // freedata, and undo
                        if(G.f & G_FACESELECT)
@@ -781,8 +785,6 @@ int blenderqread(unsigned short event, short val)
                        }
                        if(G.f & G_WEIGHTPAINT)
                                set_wpaint();
-                       if(G.obpose)
-                               exit_posemode(1);
                }
                break;
 
@@ -867,7 +869,7 @@ int blenderqread(unsigned short event, short val)
                break;
                
        case SKEY:
-               if(G.obpose==0 && G.obedit==0) {
+               if(G.obedit==NULL) {
                        if(G.qual==LR_CTRLKEY) {
                                strcpy(dir, G.sce);
                                if (untitled(dir)) {
@@ -883,6 +885,8 @@ int blenderqread(unsigned short event, short val)
        
        case TKEY:
                if (G.qual==(LR_SHIFTKEY|LR_ALTKEY|LR_CTRLKEY)) {
+                       Object *ob = OBACT;
+                       int event = pupmenu(ob?"Time%t|draw|recalc ob|recalc data":"Time%t|draw");
                        int a;
                        double delta, stime;
 
@@ -890,19 +894,27 @@ int blenderqread(unsigned short event, short val)
                        
                        stime= PIL_check_seconds_timer();
                        for(a=0; a<100000; a++) {
-                               scrarea_do_windraw(curarea);
+                               if (event==1) {
+                                       scrarea_do_windraw(curarea);
+                               } else if (event==2) {
+                                       ob->recalc |= OB_RECALC_OB;
+                                       object_handle_update(ob);
+                               } else if (event==3) {
+                                       ob->recalc |= OB_RECALC_DATA;
+                                       object_handle_update(ob);
+                               }
 
                                delta= PIL_check_seconds_timer()-stime;
                                if (delta>5.0) break;
                        }
                        
                        waitcursor(0);
-                       notice("FPS: %f (%d iterations)", a/delta, a);
+                       notice("%8.6f s/op - %6.2f ops/s - %d iterations", delta/a, a/delta, a);
                        return 0;
                }
                else if(G.qual==(LR_ALTKEY|LR_CTRLKEY)) {
                        int a;
-                       int event= pupmenu("10 Timer%t|draw|draw+swap|displist|undo");
+                       int event= pupmenu("10 Timer%t|draw|draw+swap|undo");
                        if(event>0) {
                                double stime= PIL_check_seconds_timer();
                                char tmpstr[128];
@@ -916,12 +928,8 @@ int blenderqread(unsigned short event, short val)
                                        } else if (event==2) {
                                                scrarea_do_windraw(curarea);
                                                screen_swapbuffers();
-                                       } else if (event==3) {
-                                               if (OBACT) {
-                                                       makeDispList(OBACT);
-                                               }
                                        }
-                                       else if(event==4) {
+                                       else if(event==3) {
                                                BKE_write_undo("10 timer");
                                        }
                                }
@@ -950,8 +958,10 @@ int blenderqread(unsigned short event, short val)
                                return 0;
                        }
                        else if(G.qual==LR_ALTKEY) {
-                               BIF_undo_menu();
-                               return 0;
+                               if(curarea->spacetype!=SPACE_TEXT) {
+                                       BIF_undo_menu();
+                                       return 0;
+                               }
                        }
                }
                break;
@@ -975,7 +985,7 @@ int blenderqread(unsigned short event, short val)
                break;
                
        case XKEY:
-               if(textspace==0) {
+               if(textspace==0 && textediting==0) {
                        if(G.qual==LR_CTRLKEY) {
                                if(okee("Erase all")) {
                                        if( BIF_read_homefile()==0) error("No file ~/.B.blend");
@@ -985,16 +995,20 @@ int blenderqread(unsigned short event, short val)
                }
                break;
        case YKEY:      // redo alternative
-               if(G.qual==LR_CTRLKEY) {
-                       BIF_redo(); 
-                       return 0;
+               if(textspace==0) {
+                       if(G.qual==LR_CTRLKEY) {
+                               BIF_redo(); 
+                               return 0;
+                       }
                }
                break;
        case ZKEY:      // undo
-               if(G.qual & (LR_CTRLKEY|LR_COMMANDKEY)) { // all combos with ctrl/commandkey are accepted
-                       if ELEM(G.qual, LR_CTRLKEY, LR_COMMANDKEY) BIF_undo();
-                       else BIF_redo(); // all combos with ctrl is redo
-                       return 0;
+               if(textspace==0) {
+                       if(G.qual & (LR_CTRLKEY|LR_COMMANDKEY)) { // all combos with ctrl/commandkey are accepted
+                               if ELEM(G.qual, LR_CTRLKEY, LR_COMMANDKEY) BIF_undo();
+                               else BIF_redo(); // all combos with ctrl is redo
+                               return 0;
+                       }
                }
                break; 
        }