commit of wip copy to work on other comuter
authorJoseph Eagar <joeedh@gmail.com>
Tue, 26 Oct 2010 19:13:17 +0000 (19:13 +0000)
committerJoseph Eagar <joeedh@gmail.com>
Tue, 26 Oct 2010 19:13:17 +0000 (19:13 +0000)
source/blender/blenkernel/BKE_context.h
source/blender/blenkernel/intern/context.c
source/blender/bmesh/operators/createops.c
source/blender/windowmanager/intern/wm_event_system.c
source/creator/creator.c

index f6d41190c5ad56b4e8f7cf500c982092ba1aa5cd..9d06de9cd911c147ccacf78280a6de7e8f44aad5 100644 (file)
@@ -261,6 +261,16 @@ struct bPoseChannel *CTX_data_active_pose_bone(const bContext *C);
 int CTX_data_selected_pose_bones(const bContext *C, ListBase *list);
 int CTX_data_visible_pose_bones(const bContext *C, ListBase *list);
 
+#ifdef EVENT_RECORDER
+#include <stdio.h>
+
+int CTX_rec_events(bContext *C);
+FILE *CTX_rec_file(bContext *C);
+int CTX_set_events_path(bContext *C, char *path);
+int CTX_play_events(bContext *C, char **playpath);
+
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index 7928424e47c9617fdb31be8cc4b34efe1c1cb558..f93805ec5a58cb04c2bca9546672440d2946f26a 100644 (file)
@@ -80,6 +80,11 @@ struct bContext {
        struct {
                int render;
        } eval;
+       
+#ifdef EVENT_RECORDER
+       int evtrec, evtplay;
+       char evtplaypath[300];
+#endif
 };
 
 /* context */
@@ -100,6 +105,34 @@ bContext *CTX_copy(const bContext *C)
        return newC;
 }
 
+#ifdef EVENT_RECORDER
+int CTX_rec_events(bContext *C)
+{
+       return C->evtrec;
+}
+
+FILE *CTX_rec_file(bContext *C)
+{
+       static FILE *f = NULL;
+       if (!f)
+               f = fopen("eventlog.txt", "wb");
+       return f;
+}
+
+int CTX_set_events_path(bContext *C, char *path)
+{
+       if (!path)
+               C->evtplaypath[0] = 0;
+}
+
+int CTX_play_events(bContext *C, char **playpath)
+{
+       *playpath = C->evtplaypath[0] ? C->evtplaypath : NULL;
+       
+       return C->evtplaypath[0];
+}
+#endif
+
 void CTX_free(bContext *C)
 {
        MEM_freeN(C);
index 57c5e13ba57e997ddd9dc667c853dcd3c7cd8777..39a717d68dfb2e7af2b762d4a3d7fb5b31d26ee9 100644 (file)
@@ -397,6 +397,8 @@ void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata)
                        copy_v3_v3(vdata[BMINDEX_GET(v2)].sco, vec1);
                }
                
+               BLI_srandom(0);
+               
                /*first, ensure no 0 or 180 angles between adjacent
                  (and that adjacent's adjacent) edges*/
                for (i=0, k=0; i<totedge; i++) {
@@ -451,7 +453,7 @@ void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata)
                }
                
                copy_v3_v3(vdata[BMINDEX_GET(v)].offco, cent);
-               copy_v3_v3(v->co, cent);
+               //copy_v3_v3(v->co, cent);
                
                /*now, sort edges so the triangle fan of all edges
                  has a consistent normal.  this is the same as
index 3d5ae66236d266132cdac12408e69eeea8ec25a8..abbf0e32342134e140f0933228c21b96657bd516 100644 (file)
@@ -1585,6 +1585,11 @@ void wm_event_do_handlers(bContext *C)
        wmWindowManager *wm= CTX_wm_manager(C);
        wmWindow *win;
 
+#ifdef EVENT_RECORDER
+       FILE *file = NULL;
+       char *fpath = NULL;
+#endif
+
        for(win= wm->windows.first; win; win= win->next) {
                wmEvent *event;
                
@@ -1621,9 +1626,44 @@ void wm_event_do_handlers(bContext *C)
                        }
                }
                
+               #ifdef EVENT_RECORDER
+                       if (CTX_play_events(C, &fpath) && fpath) {
+                               wmEvent evt;
+                               
+                               file = fopen(fpath, "rb");
+                               while (!feof(file)) {
+                                       char buf1[6];
+                                       fread(buf1, sizeof(*buf1), 1, file);
+                                       buf1[5] = 0;
+                                       if (!strcasecmp(buf1, "event")) {
+                                               fprintf(stderr, "EEK! bad event playback file!!");
+                                               break;
+                                       }
+                                       
+                                       fread(&evt, sizeof(*event), 1, file);
+                                       
+                                       wm_event_add(win, &evt);
+                               }
+                               
+                               fclose(file);
+                               CTX_set_events_path(C, NULL);
+                       }
+               #endif
+
                while( (event= win->queue.first) ) {
                        int action = WM_HANDLER_CONTINUE;
-
+                       
+               #ifdef EVENT_RECORDER
+                       if (CTX_rec_events(C) && !CTX_play_events(C, NULL)) {
+                               FILE *file = CTX_rec_file(C);
+                               
+                               fwrite(event, sizeof(*event), 1, file);
+                               fprintf(file, "event");
+                               fflush(event);
+                       }
+                       
+               #endif
+               
                        if((G.f & G_DEBUG) && event && !ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE))
                                printf("pass on evt %d val %d\n", event->type, event->val); 
                        
index 709b4bc504763b1a1f485cf66edd4b553c51b4fd..2652d4399bb1a65672f6fa28319c3b1454df89fc 100644 (file)
@@ -235,7 +235,9 @@ static int print_help(int argc, char **argv, void *data)
        printf ("Misc Options:\n");
        BLI_argsPrintArgDoc(ba, "--debug");
        BLI_argsPrintArgDoc(ba, "--debug-fpe");
-
+#ifdef EVENT_RECORDER
+       BLI_argsPrintArgDoc(ba, "--runmacro");
+#endif
        printf("\n");
 
        BLI_argsPrintArgDoc(ba, "-nojoystick");
@@ -798,6 +800,18 @@ static int set_start_frame(int argc, char **argv, void *data)
        }
 }
 
+#ifdef EVENT_RECORDER
+static int set_macro_playback(int argc, char **argv, void *data)
+{
+       bContext *C = data;
+       
+       if (argc < 2)
+               return;
+               
+       CTX_set_events_path(C, argv[1]);
+}
+#endif
+
 static int set_end_frame(int argc, char **argv, void *data)
 {
        bContext *C = data;
@@ -983,6 +997,10 @@ void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle)
        /* end argument processing after -- */
        BLI_argsAdd(ba, -1, "--", NULL, "\n\tEnds option processing, following arguments passed unchanged. Access via python's sys.argv", end_arguments, NULL);
        BLI_argsAdd(ba, 1,  "--no_crash_handler", NULL, "disable crash handler", nocrashhandler, NULL);
+       
+#ifdef EVENT_RECORDER
+       BLI_argsAdd(ba, 1, "--eventmacro", NULL, "<file>\n\tevent macro", set_macro_playback, NULL);
+#endif
 
        /* first pass: background mode, disable python and commands that exit after usage */
        BLI_argsAdd(ba, 1, "-h", "--help", "\n\tPrint this help text and exit", print_help, ba);