diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index 9d06de9cd91..d93bfc3a604 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -261,6 +261,9 @@ 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); +//stupid compiler flag isn't working +//remember to undef this later +#define EVENT_RECORDER #ifdef EVENT_RECORDER #include @@ -268,6 +271,8 @@ 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); +int CTX_rec_events_set(bContext *C, int state); +double CTX_rec_lasttime(bContext *C, double newtime); #endif diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index c51ba36c93c..7b31e87ab03 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -112,6 +112,12 @@ void copy_dverts(struct MDeformVert *dst, struct MDeformVert *src, int totvert); void mesh_delete_material_index(struct Mesh *me, int index); void mesh_set_smooth_flag(struct Object *meshOb, int enableSmooth); +/*used for unit testing; compares two meshes, checking only + differences we care about. should be usable with leaf's + testing framework I get RNA work done, will use hackish + testing code for now.*/ +char *mesh_cmp(struct Mesh *me1, struct Mesh *me2, float thresh); + struct BoundBox *mesh_get_bb(struct Object *ob); void mesh_get_texspace(struct Mesh *me, float *loc_r, float *rot_r, float *size_r); diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index f93805ec5a5..764ba058a7a 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -41,6 +41,7 @@ #include "BLI_listbase.h" #include "BLI_string.h" +#include "PIL_time.h" #include "BKE_context.h" #include "BKE_main.h" @@ -84,6 +85,7 @@ struct bContext { #ifdef EVENT_RECORDER int evtrec, evtplay; char evtplaypath[300]; + double evtlasttime; #endif }; @@ -111,6 +113,13 @@ int CTX_rec_events(bContext *C) return C->evtrec; } +int CTX_rec_events_set(bContext *C, int state) +{ + C->evtrec = state; + + return 1; +} + FILE *CTX_rec_file(bContext *C) { static FILE *f = NULL; @@ -119,15 +128,34 @@ FILE *CTX_rec_file(bContext *C) return f; } +double CTX_rec_lasttime(bContext *C, double newtime) +{ + double ret; + + if (C->evtlasttime == 0.0) { + ret = newtime; + } else ret = C->evtlasttime; + + C->evtlasttime = newtime; + + return ret; +} + int CTX_set_events_path(bContext *C, char *path) { if (!path) C->evtplaypath[0] = 0; + else + strcpy(C->evtplaypath, path); + + return 1; } +extern int erec_playing; int CTX_play_events(bContext *C, char **playpath) { - *playpath = C->evtplaypath[0] ? C->evtplaypath : NULL; + if (playpath) + *playpath = C->evtplaypath[0] ? C->evtplaypath : NULL; return C->evtplaypath[0]; } diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index f43927e7df6..e01590746ff 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -42,9 +42,11 @@ #include "DNA_key_types.h" #include "DNA_meshdata_types.h" #include "DNA_ipo_types.h" +#include "DNA_customdata_types.h" #include "BKE_animsys.h" #include "BKE_main.h" +#include "BKE_customdata.h" #include "BKE_DerivedMesh.h" #include "BKE_global.h" #include "BKE_mesh.h" @@ -58,6 +60,7 @@ #include "BKE_object.h" #include "BKE_utildefines.h" #include "BKE_tessmesh.h" +#include "BLI_edgehash.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" @@ -68,6 +71,230 @@ #include "bmesh.h" +enum { + MESHCMP_DVERT_WEIGHTMISMATCH = 1, + MESHCMP_DVERT_GROUPMISMATCH, + MESHCMP_DVERT_TOTGROUPMISMATCH, + MESHCMP_LOOPCOLMISMATCH, + MESHCMP_LOOPUVMISMATCH, + MESHCMP_LOOPMISMATCH, + MESHCMP_POLYVERTMISMATCH, + MESHCMP_POLYMISMATCH, + MESHCMP_EDGEUNKNOWN, + MESHCMP_VERTCOMISMATCH, + MESHCMP_CDLAYERS_MISMATCH, +}; + +static char *cmpcode_to_str(int code) +{ + switch (code) { + case MESHCMP_DVERT_WEIGHTMISMATCH: + return "Vertex Weight Mismatch"; + case MESHCMP_DVERT_GROUPMISMATCH: + return "Vertex Group Mismatch"; + case MESHCMP_DVERT_TOTGROUPMISMATCH: + return "Vertex Doesn't Belong To Same Number Of Groups"; + case MESHCMP_LOOPCOLMISMATCH: + return "Vertex Color Mismatch"; + case MESHCMP_LOOPUVMISMATCH: + return "UV Mismatch"; + case MESHCMP_LOOPMISMATCH: + return "Loop Mismatch"; + case MESHCMP_POLYVERTMISMATCH: + return "Loop Vert Mismatch In Poly Test"; + case MESHCMP_POLYMISMATCH: + return "Loop Vert Mismatch"; + case MESHCMP_EDGEUNKNOWN: + return "Edge Mismatch"; + case MESHCMP_VERTCOMISMATCH: + return "Vertex Coordinate Mismatch"; + case MESHCMP_CDLAYERS_MISMATCH: + "CustomData Layer Count Mismatch"; + default: + return "Mesh Comparison Code Unknown"; + } +} + +/*thresh is threshold for comparing vertices, uvs, vertex colors, + weights, etc.*/ +int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2, float thresh) +{ + CustomDataLayer *l1, *l2; + int i, i1=0, i2=0, tot, j; + + for (i=0; itotlayer; i++) { + if (ELEM7(c1->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY, + CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + i1++; + } + + for (i=0; itotlayer; i++) { + if (ELEM7(c2->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY, + CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + i2++; + } + + if (i1 != i2) + return MESHCMP_CDLAYERS_MISMATCH; + + l1 = c1->layers; l2 = c2->layers; + tot = i1; + i1 = 0; i2 = 0; + for (i=0; i < tot; i++) { + while (i1 < c1->totlayer && !ELEM7(l1->type, CD_MVERT, CD_MEDGE, CD_MPOLY, + CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + i1++, l1++; + + while (i2 < c2->totlayer && !ELEM7(l2->type, CD_MVERT, CD_MEDGE, CD_MPOLY, + CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + i2++, l2++; + + if (l1->type == CD_MVERT) { + MVert *v1 = l1->data; + MVert *v2 = l2->data; + int vtot = m1->totvert; + + for (j=0; jco, v2->co) > thresh) + return MESHCMP_VERTCOMISMATCH; + /*I don't care about normals, let's just do coodinates*/ + } + } + + /*we're order-agnostic for edges here*/ + if (l1->type == CD_MEDGE) { + MEdge *e1 = l1->data; + MEdge *e2 = l2->data; + EdgeHash *eh = BLI_edgehash_new(); + int etot = m1->totedge; + + for (j=0; jv1, e1->v2, e1); + } + + for (j=0; jv1, e2->v2)) + return MESHCMP_EDGEUNKNOWN; + } + BLI_edgehash_free(eh, NULL); + } + + if (l1->type == CD_MPOLY) { + MPoly *p1 = l1->data; + MPoly *p2 = l2->data; + int ptot = m1->totpoly; + + for (j=0; jtotloop != p2->totloop) + return MESHCMP_POLYMISMATCH; + + lp1 = m1->mloop + p1->loopstart; + lp2 = m2->mloop + p2->loopstart; + + for (k=0; ktotloop; k++, lp1++, lp2++) { + if (lp1->v != lp2->v) + return MESHCMP_POLYVERTMISMATCH; + } + } + } + if (l1->type == CD_MLOOP) { + MLoop *lp1 = l1->data; + MLoop *lp2 = l2->data; + int ltot = m1->totloop; + + for (j=0; jv != lp2->v) + return MESHCMP_LOOPMISMATCH; + } + } + if (l1->type == CD_MLOOPUV) { + MLoopUV *lp1 = l1->data; + MLoopUV *lp2 = l2->data; + int ltot = m1->totloop; + + for (j=0; juv, lp2->uv) > thresh) + return MESHCMP_LOOPUVMISMATCH; + } + } + + if (l1->type == CD_MLOOPCOL) { + MLoopCol *lp1 = l1->data; + MLoopCol *lp2 = l2->data; + int ltot = m1->totloop; + + for (j=0; jr - lp2->r) > thresh || + ABS(lp1->g - lp2->g) > thresh || + ABS(lp1->b - lp2->b) > thresh || + ABS(lp1->a - lp2->a) > thresh) + { + return MESHCMP_LOOPCOLMISMATCH; + } + } + } + + if (l1->type == CD_MDEFORMVERT) { + MDeformVert *dv1 = l1->data; + MDeformVert *dv2 = l2->data; + int dvtot = m1->totvert; + + for (j=0; jdw, *dw2=dv2->dw; + + if (dv1->totweight != dv2->totweight) + return MESHCMP_DVERT_TOTGROUPMISMATCH; + + for (k=0; ktotweight; k++, dw1++, dw2++) { + if (dw1->def_nr != dw2->def_nr) + return MESHCMP_DVERT_GROUPMISMATCH; + if (ABS(dw1->weight - dw2->weight) > thresh) + return MESHCMP_DVERT_WEIGHTMISMATCH; + } + } + } + } +} + +/*used for testing. returns an error string the two meshes don't match*/ +char *mesh_cmp(Mesh *me1, Mesh *me2, float thresh) +{ + int c; + + if (!me1 || !me2) + return "Requires two input meshes"; + + if (me1->totvert != me2->totvert) + return "Number of verts don't match"; + + if (me1->totedge != me2->totedge) + return "Number of edges don't match"; + + if (me1->totpoly != me2->totpoly) + return "Number of faces don't match"; + + if (me1->totloop !=me2->totloop) + return "Number of loops don't match"; + + if ((c = customdata_compare(&me1->vdata, &me2->vdata, me1, me2, thresh))) + return cmpcode_to_str(c); + + if ((c = customdata_compare(&me1->edata, &me2->edata, me1, me2, thresh))) + return cmpcode_to_str(c); + + if ((c = customdata_compare(&me1->ldata, &me2->ldata, me1, me2, thresh))) + return cmpcode_to_str(c); + + if ((c = customdata_compare(&me1->pdata, &me2->pdata, me1, me2, thresh))) + return cmpcode_to_str(c); + + return NULL; +} + static void mesh_ensure_tesselation_customdata(Mesh *me) { int tottex, totcol; diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 7a45a43ddd4..cdb569c8f75 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -182,6 +182,9 @@ void VIEW3D_OT_snap_cursor_to_grid(struct wmOperatorType *ot); void VIEW3D_OT_snap_cursor_to_center(struct wmOperatorType *ot); void VIEW3D_OT_snap_cursor_to_selected(struct wmOperatorType *ot); void VIEW3D_OT_snap_cursor_to_active(struct wmOperatorType *ot); +#ifdef EVENT_RECORDER +void VIEW3D_OT_evtrec(struct wmOperatorType *ot); +#endif /* space_view3d.c */ ARegion *view3d_has_buttons_region(ScrArea *sa); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 9ee12a8ef1e..c436c179f8f 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -54,6 +54,9 @@ void view3d_operatortypes(void) { +#ifdef EVENT_RECORDER + WM_operatortype_append(VIEW3D_OT_evtrec); +#endif WM_operatortype_append(VIEW3D_OT_rotate); WM_operatortype_append(VIEW3D_OT_move); WM_operatortype_append(VIEW3D_OT_zoom); diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index e47a3af19f1..c07d7d88944 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -303,3 +303,27 @@ void VIEW3D_OT_toolshelf(wmOperatorType *ot) /* flags */ ot->flag= 0; } + + +#ifdef EVENT_RECORDER +static int view3d_evtrec(bContext *C, wmOperator *op) +{ + + CTX_rec_events_set(C, !CTX_rec_events(C)); + + return OPERATOR_FINISHED; +} + +void VIEW3D_OT_evtrec(wmOperatorType *ot) +{ + ot->name= "Toggle Event Recorder"; + ot->description= "Toggles event recorder"; + ot->idname= "VIEW3D_OT_evtrec"; + + ot->exec= view3d_evtrec; + ot->poll= ED_operator_view3d_active; + + /* flags */ + ot->flag= 0; +} +#endif diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index e6d0772f425..07aef5a5328 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -182,6 +182,7 @@ typedef struct wmWindow { ListBase subwindows; /* opengl stuff for sub windows, see notes in wm_subwindow.c */ ListBase gesture; /* gesture stuff */ + double lasttime; } wmWindow; /* should be somthing like DNA_EXCLUDE diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index af109a688c1..a8a2f08d76c 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -413,7 +413,7 @@ static void rna_Mesh_uv_texture_clone_set(PointerRNA *ptr, PointerRNA value) } } #endif - return NULL; + return; } static void rna_Mesh_uv_texture_stencil_set(PointerRNA *ptr, PointerRNA value) @@ -431,7 +431,7 @@ static void rna_Mesh_uv_texture_stencil_set(PointerRNA *ptr, PointerRNA value) } } #endif - return NULL; + return; } static int rna_Mesh_active_uv_texture_index_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c index 220a66d089a..938b4ee632b 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.c +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -36,8 +36,15 @@ #include "ED_mesh.h" #ifdef RNA_RUNTIME - - +char *rna_Mesh_unit_test_compare(struct Mesh *mesh, bContext *C, struct Mesh *mesh2) +{ + char *ret = mesh_cmp(mesh, mesh2, FLT_EPSILON*60); + + if (!ret) + ret = "Same"; + + return ret; +} #else void RNA_api_mesh(StructRNA *srna) @@ -56,6 +63,14 @@ void RNA_api_mesh(StructRNA *srna) func= RNA_def_function(srna, "update", "ED_mesh_update"); RNA_def_boolean(func, "calc_edges", 0, "Calculate Edges", "Force recalculation of edges."); RNA_def_function_flag(func, FUNC_USE_CONTEXT); + + func= RNA_def_function(srna, "unit_test_compare", "rna_Mesh_unit_test_compare"); + parm= RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to compare to"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + /* return value */ + parm= RNA_def_string(func, "result", "nothing", 64, "Return value", "String description of result of comparison"); + RNA_def_function_return(func, parm); + } #endif diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 807125765f7..bcdef5c2278 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -343,7 +343,7 @@ typedef struct wmEvent { short customdatafree; int pad2; void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */ - + double delay; } wmEvent; /* ************** custom wmEvent data ************** */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index abbf0e32342..97cc67fae57 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -72,6 +72,10 @@ #include "wm_event_types.h" #include "wm_draw.h" +#ifdef EVENT_RECORDER +int erec_playing = 0; +#endif + /* ************ event management ************** */ void wm_event_add(wmWindow *win, wmEvent *event_to_add) @@ -1586,7 +1590,7 @@ void wm_event_do_handlers(bContext *C) wmWindow *win; #ifdef EVENT_RECORDER - FILE *file = NULL; + static FILE *file = NULL; char *fpath = NULL; #endif @@ -1626,43 +1630,82 @@ void wm_event_do_handlers(bContext *C) } } - #ifdef EVENT_RECORDER - if (CTX_play_events(C, &fpath) && fpath) { - wmEvent evt; +#ifdef EVENT_RECORDER + if (CTX_play_events(C, &fpath) && fpath) + { + wmEvent evt; + double nextdelay = 0.0; + + erec_playing = 1; + + if (!file) + file= fopen(fpath, "rb"); + + while (file && !feof(file)) { + char buf1[6]; + fread(buf1, 5, 1, file); + buf1[5] = 0; - 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!!"); + if (strcasecmp(buf1, "event")) { + if (!strcasecmp(buf1, "break")) break; - } - fread(&evt, sizeof(*event), 1, file); - - wm_event_add(win, &evt); + fprintf(stderr, "EEK! bad event playback file!!"); + break; } + fread(&evt, sizeof(*event), 1, file); + + /*add in artifical delay after button open events*/ + if (!evt.customdata) { + evt.delay += nextdelay; + nextdelay = 0.0; + } + + if (evt.type == EVT_BUT_OPEN) + nextdelay = 1.0; + + /*don't do anything if theres customdata in the + event*/ + if (evt.customdata) + continue; + + wm_event_add(win, &evt); + } + + if (file && feof(file)) { + erec_playing = 0; fclose(file); CTX_set_events_path(C, NULL); } - #endif - + } +#endif + + if (win->lasttime == 0.0) + win->lasttime = PIL_check_seconds_timer(); + while( (event= win->queue.first) ) { int action = WM_HANDLER_CONTINUE; - - #ifdef EVENT_RECORDER +#if 1 + /*used for hackish recorder playback*/ + while (event->delay>0.0 && PIL_check_seconds_timer() + - win->lasttime < event->delay) ; + +#endif +#ifdef EVENT_RECORDER if (CTX_rec_events(C) && !CTX_play_events(C, NULL)) { FILE *file = CTX_rec_file(C); + char tag[6] = "event"; + double delay = PIL_check_seconds_timer(); + delay -= CTX_rec_lasttime(C, delay); + event->delay = delay; + + fwrite(tag, sizeof(tag)-1, 1, file); fwrite(event, sizeof(*event), 1, file); - fprintf(file, "event"); - fflush(event); + fflush(file); } - - #endif +#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); @@ -1796,10 +1839,25 @@ void wm_event_do_handlers(bContext *C) BLI_remlink(&win->queue, event); wm_event_free(event); + win->lasttime = PIL_check_seconds_timer(); } +#ifdef EVENT_RECORDER + if (CTX_rec_events(C) && !CTX_play_events(C, NULL)) { + FILE *file = CTX_rec_file(C); + char tag[6] = "break"; + + fwrite(tag, 5, 1, file); + fflush(file); + } +#endif + /* only add mousemove when queue was read entirely */ +#ifdef EVENT_RECORDER + if(win->addmousemove && win->eventstate && !erec_playing) { +#else if(win->addmousemove && win->eventstate) { +#endif wmEvent event= *(win->eventstate); event.type= MOUSEMOVE; event.prevx= event.x; @@ -2198,7 +2256,11 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int t switch (type) { /* mouse move */ case GHOST_kEventCursorMove: { - if(win->active) { +#ifdef EVENT_RECORDER + if(win->active && !erec_playing) { +#else + if(win->active) { +#endif GHOST_TEventCursorData *cd= customdata; wmEvent *lastevent= win->queue.last; @@ -2246,6 +2308,10 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int t break; } case GHOST_kEventTrackpad: { +#ifdef EVENT_RECORDER + if(wm->winactive && !erec_playing) { +#endif + GHOST_TEventTrackpadData * pd = customdata; switch (pd->subtype) { case GHOST_kTrackpadEventMagnify: @@ -2259,6 +2325,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int t event.type= MOUSEPAN; break; } + #if defined(__APPLE__) && defined(GHOST_COCOA) //Cocoa already uses coordinates with y=0 at bottom, and returns inwindow coordinates on mouse moved event event.x= evt->x = pd->x; @@ -2278,6 +2345,9 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int t update_tablet_data(win, &event); wm_event_add(win, &event); break; +#ifdef EVENT_RECORDER + } +#endif } /* mouse button */ case GHOST_kEventButtonDown: @@ -2285,6 +2355,11 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int t GHOST_TEventButtonData *bd= customdata; event.val= (type==GHOST_kEventButtonDown) ? KM_PRESS:KM_RELEASE; /* Note!, this starts as 0/1 but later is converted to KM_PRESS/KM_RELEASE by tweak */ + #ifdef EVENT_RECORDER + if (erec_playing) + return; + #endif + if (bd->button == GHOST_kButtonMaskLeft) event.type= LEFTMOUSE; else if (bd->button == GHOST_kButtonMaskRight) @@ -2324,6 +2399,11 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int t event.ascii= kd->ascii; event.val= (type==GHOST_kEventKeyDown)?KM_PRESS:KM_RELEASE; + #ifdef EVENT_RECORDER + if (erec_playing) + return; + #endif + /* exclude arrow keys, esc, etc from text input */ if(type==GHOST_kEventKeyUp || (event.ascii<32 && event.ascii>0)) event.ascii= '\0'; @@ -2375,6 +2455,10 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int t case GHOST_kEventWheel: { GHOST_TEventWheelData* wheelData = customdata; + #ifdef EVENT_RECORDER + if (erec_playing) + return; + #endif if (wheelData->z > 0) event.type= WHEELUPMOUSE; else diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 45234464ef0..09610a2829e 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -367,7 +367,7 @@ void wm_window_add_ghostwindows(wmWindowManager *wm) for(win= wm->windows.first; win; win= win->next) { if(win->ghostwin==NULL) { - if(win->sizex==0) { + if(win->sizex==0 || prefsizx || prefsizy) { win->posx= prefstax; win->posy= prefstay; win->sizex= prefsizx; @@ -858,7 +858,9 @@ static int wm_window_timer(const bContext *C) void wm_window_process_events(const bContext *C) { - int hasevent= GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */ + int hasevent= 0; + + hasevent = GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */ if(hasevent) GHOST_DispatchEvents(g_system); diff --git a/source/creator/creator.c b/source/creator/creator.c index 2652d4399bb..271e690b3ed 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -236,7 +236,7 @@ static int print_help(int argc, char **argv, void *data) BLI_argsPrintArgDoc(ba, "--debug"); BLI_argsPrintArgDoc(ba, "--debug-fpe"); #ifdef EVENT_RECORDER - BLI_argsPrintArgDoc(ba, "--runmacro"); + BLI_argsPrintArgDoc(ba, "--eventmacro"); #endif printf("\n"); @@ -346,7 +346,7 @@ static int nocrashhandler(int argc, char **argv, void *data) { no_handler = 1; - return -1; + return 0; } @@ -809,6 +809,8 @@ static int set_macro_playback(int argc, char **argv, void *data) return; CTX_set_events_path(C, argv[1]); + + return 0; } #endif @@ -996,11 +998,6 @@ 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, "\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); @@ -1024,13 +1021,15 @@ void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) BLI_argsAdd(ba, 2, "-w", "--window-border", "\n\tForce opening with borders (default)", with_borders, NULL); BLI_argsAdd(ba, 2, "-W", "--window-borderless", "\n\tForce opening with without borders", without_borders, NULL); BLI_argsAdd(ba, 2, "-R", NULL, "\n\tRegister .blend extension (windows only)", register_extension, ba); - + BLI_argsAdd(ba, 2, "--no_crash_handler", NULL, "disable crash handler", nocrashhandler, NULL); + /* third pass: disabling things and forcing settings */ BLI_argsAddCase(ba, 3, "-nojoystick", 1, NULL, 0, "\n\tDisable joystick support", no_joystick, syshandle); BLI_argsAddCase(ba, 3, "-noglsl", 1, NULL, 0, "\n\tDisable GLSL shading", no_glsl, NULL); BLI_argsAddCase(ba, 3, "-noaudio", 1, NULL, 0, "\n\tForce sound system to None", no_audio, NULL); BLI_argsAddCase(ba, 3, "-setaudio", 1, NULL, 0, "\n\tForce sound system to a specific device\n\tNULL SDL OPENAL JACK", set_audio, NULL); + /* fourth pass: processing arguments */ BLI_argsAdd(ba, 4, "-g", NULL, game_doc, set_ge_parameters, syshandle); BLI_argsAdd(ba, 4, "-f", "--render-frame", "\n\tRender frame and save it.\n\t+ start frame relative, - end frame relative.", render_frame, C); @@ -1049,6 +1048,10 @@ void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) BLI_argsAdd(ba, 4, "-t", "--threads", "\n\tUse amount of for rendering in background\n\t[1-" QUOTE(BLENDER_MAX_THREADS) "], 0 for systems processor count.", set_threads, NULL); BLI_argsAdd(ba, 4, "-x", "--use-extension", "\n\tSet option to add the file extension to the end of the file", set_extension, C); +#ifdef EVENT_RECORDER + BLI_argsAdd(ba, 4, "--eventmacro", NULL, "\n\tevent macro", set_macro_playback, C); +#endif + } int main(int argc, char **argv) @@ -1201,7 +1204,11 @@ int main(int argc, char **argv) if(WM_init_game(C)) return 0; } - else if(!G.file_loaded) +#ifdef EVENT_RECORDER + else if(!G.file_loaded && !CTX_play_events(C, NULL)) +#else + else if(!G.file_loaded) +#endif WM_init_splash(C); }