From f059167c30c71cb241dfbf94ccff007a5b90e262 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 18 Feb 2012 16:23:34 +0000 Subject: [PATCH 1/7] Proxies: FFmpeg proxy builder wasn't taking image quality into account at all which made it using default quality settings which are really bad for camera tracking (and perhaps for CSE too). haven't found Jpeg quality setting for FFmpeg which will behave in the same way as quality setting for image sequence, but seems that mapping image quality from 1..100 UI range to 31..1 range of qmin/qmax gives expected result. --- source/blender/imbuf/intern/indexer.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index e1481d2a08f..eb1bfc80383 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -459,12 +459,13 @@ static int round_up(int x, int mod) static struct proxy_output_ctx * alloc_proxy_output_ffmpeg( struct anim * anim, AVStream * st, int proxy_size, int width, int height, - int UNUSED(quality)) + int quality) { struct proxy_output_ctx * rv = MEM_callocN( sizeof(struct proxy_output_ctx), "alloc_proxy_output"); char fname[FILE_MAX]; + int ffmpeg_quality; // JPEG requires this width = round_up(width, 8); @@ -514,6 +515,12 @@ static struct proxy_output_ctx * alloc_proxy_output_ffmpeg( rv->c->time_base.num = 1; rv->st->time_base = rv->c->time_base; + /* there's no way to set JPEG quality in the same way as in AVI JPEG and image sequence, + * but this seems to be giving expected quality result */ + ffmpeg_quality = 31 * (1.0f - (float)quality / 100.0f); + av_set_int(rv->c, "qmin", ffmpeg_quality); + av_set_int(rv->c, "qmax", ffmpeg_quality); + if (rv->of->flags & AVFMT_GLOBALHEADER) { rv->c->flags |= CODEC_FLAG_GLOBAL_HEADER; } From 69ee17f0b6121ab63f0a7712c9563295eda88d39 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 18 Feb 2012 16:42:19 +0000 Subject: [PATCH 2/7] Wring scaling and precision error in previous commit. --- source/blender/imbuf/intern/indexer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index eb1bfc80383..ade63aa1e9c 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -517,7 +517,7 @@ static struct proxy_output_ctx * alloc_proxy_output_ffmpeg( /* there's no way to set JPEG quality in the same way as in AVI JPEG and image sequence, * but this seems to be giving expected quality result */ - ffmpeg_quality = 31 * (1.0f - (float)quality / 100.0f); + ffmpeg_quality = (int)(1.0f + 30.0f * (1.0f - (float)quality / 100.0f) + 0.5f); av_set_int(rv->c, "qmin", ffmpeg_quality); av_set_int(rv->c, "qmax", ffmpeg_quality); From 02b28e9162784933f470c5381b290f2582706a51 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 19 Feb 2012 05:11:24 +0000 Subject: [PATCH 3/7] replace MIN2 / MAX2 with minf / maxf to avoid calling functions multiple times. --- source/blender/blenkernel/intern/seqeffects.c | 2 +- source/blender/editors/physics/particle_edit.c | 2 +- source/blender/editors/transform/transform.c | 4 ++-- source/blender/gpu/intern/gpu_material.c | 2 +- source/blender/render/intern/source/pixelshading.c | 2 +- source/blender/render/intern/source/shadeoutput.c | 2 +- source/creator/creator.c | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 9edcc7a73e8..d88a5c26c2c 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -1697,7 +1697,7 @@ float hyp3,hyp4,b4,b5 hyp2 = fabsf(angle*x+y+(-(yo-posy*0.5f)-angle*(xo-posx*0.5f)))*wipezone->pythangle; } - hwidth= MIN2(hwidth, fabsf(b3-b1)/2.0f); + hwidth = minf(hwidth, fabsf(b3-b1)/2.0f); if(b2 < b1 && b2 < b3 ){ output = in_band(hwidth,hyp,0,1); diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index dbf03e34c32..ceba6755821 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -3472,7 +3472,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) view3d_operator_needs_opengl(C); selected= (short)count_selected_keys(scene, edit); - dmax = MAX2(fabs(dx), fabs(dy)); + dmax = maxf(fabsf(dx), fabsf(dy)); tot_steps = dmax/(0.2f * brush->size) + 1; dx /= (float)tot_steps; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 9d368476f03..8749328c454 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4881,8 +4881,8 @@ static int doEdgeSlide(TransInfo *t, float perc) upVert = editedge_getOtherVert(tempsv->up, centerVert); downVert = editedge_getOtherVert(tempsv->down, centerVert); - len = MIN2(perc, len_v3v3(upVert->co,downVert->co)); - len = MAX2(len, 0); + len = minf(perc, len_v3v3(upVert->co, downVert->co)); + len = maxf(len, 0.0f); //Adjust Edgeloop if(prop) { diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index ef2abb20cf3..0ddaf07c67e 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -1071,7 +1071,7 @@ static void do_material_tex(GPUShadeInput *shi) else newnor = tnor; - norfac = MIN2(fabsf(mtex->norfac), 1.0f); + norfac = minf(fabsf(mtex->norfac), 1.0f); if(norfac == 1.0f && !GPU_link_changed(stencil)) { shi->vn = newnor; diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index 24683ec57f7..9746a6dbd86 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -161,7 +161,7 @@ static void render_lighting_halo(HaloRen *har, float col_r[3]) copy_v3_v3(lvrot, lv); mul_m3_v3(lar->imat, lvrot); - x= MAX2(fabs(lvrot[0]/lvrot[2]) , fabs(lvrot[1]/lvrot[2])); + x = maxf(fabsf(lvrot[0]/lvrot[2]), fabsf(lvrot[1]/lvrot[2])); /* 1.0/(sqrt(1+x*x)) is equivalent to cos(atan(x)) */ inpr= 1.0/(sqrt(1.0f+x*x)); diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 2f620bb96d4..78420aa6ca8 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -1204,7 +1204,7 @@ float lamp_get_visibility(LampRen *lar, const float co[3], float lv[3], float *d copy_v3_v3(lvrot, lv); mul_m3_v3(lar->imat, lvrot); - x= MAX2(fabs(lvrot[0]/lvrot[2]) , fabs(lvrot[1]/lvrot[2])); + x = maxf(fabsf(lvrot[0]/lvrot[2]), fabsf(lvrot[1]/lvrot[2])); /* 1.0f/(sqrt(1+x*x)) is equivalent to cos(atan(x)) */ inpr= 1.0f/(sqrt(1.0f+x*x)); diff --git a/source/creator/creator.c b/source/creator/creator.c index 68a7bc415a8..0b67dfabf16 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -727,7 +727,7 @@ static int render_frame(int argc, const char **argv, void *data) BKE_reports_init(&reports, RPT_PRINT); - frame = MIN2(MAXFRAME, MAX2(MINAFRAME, frame)); + frame = CLAMPIS(frame, MINAFRAME, MAXFRAME); RE_SetReports(re, &reports); RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, frame, frame, scene->r.frame_step); From e43c80620c5568171a6c2b4e0d66686ef9d540d0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 19 Feb 2012 05:17:55 +0000 Subject: [PATCH 4/7] fix for incorrect check to find largest axis (was checking Y twice, not Z). --- source/blender/editors/space_view3d/view3d_draw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 4f46a746b9e..c73d8e14f05 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1584,7 +1584,7 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d) /* calc window coord */ initgrabz(rv3d, 0.0, 0.0, 0.0); ED_view3d_win_to_delta(ar, mval_f, vec); - fac= MAX3( fabs(vec[0]), fabs(vec[1]), fabs(vec[1]) ); + fac= maxf(fabsf(vec[0]), maxf(fabsf(vec[1]), fabsf(vec[2]))); /* largest abs axis */ fac= 1.0f/fac; asp= ( (float)ibuf->y)/(float)ibuf->x; From cc90116c5a4be64fe55b86aad9fc9f47185690d8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 19 Feb 2012 06:00:20 +0000 Subject: [PATCH 5/7] style cleanyp: split > 120 width lines. --- source/blender/editors/object/object_edit.c | 5 +- source/blender/windowmanager/intern/wm_draw.c | 16 +++- .../windowmanager/intern/wm_event_system.c | 76 +++++++++++++------ .../blender/windowmanager/intern/wm_files.c | 26 +++++-- .../blender/windowmanager/intern/wm_gesture.c | 4 +- .../blender/windowmanager/intern/wm_keymap.c | 20 +++-- .../windowmanager/intern/wm_operators.c | 16 ++-- .../blender/windowmanager/intern/wm_window.c | 8 +- 8 files changed, 122 insertions(+), 49 deletions(-) diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 1286ac850f6..b7affcdd72c 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1004,7 +1004,10 @@ static void UNUSED_FUNCTION(copy_attr_menu)(Main *bmain, Scene *scene, View3D *v * view3d_edit_object_copyattrmenu() and in toolbox.c */ - strcpy(str, "Copy Attributes %t|Location%x1|Rotation%x2|Size%x3|Draw Options%x4|Time Offset%x5|Dupli%x6|Object Color%x31|%l|Mass%x7|Damping%x8|All Physical Attributes%x11|Properties%x9|Logic Bricks%x10|Protected Transform%x29|%l"); + strcpy(str, + "Copy Attributes %t|Location%x1|Rotation%x2|Size%x3|Draw Options%x4|" + "Time Offset%x5|Dupli%x6|Object Color%x31|%l|Mass%x7|Damping%x8|All Physical Attributes%x11|Properties%x9|" + "Logic Bricks%x10|Protected Transform%x29|%l"); strcat (str, "|Object Constraints%x22"); strcat (str, "|NLA Strips%x26"); diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 4fe11044d30..df4ebfd9b9f 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -90,9 +90,16 @@ static void wm_paintcursor_draw(bContext *C, ARegion *ar) if (ELEM(win->grabcursor, GHOST_kGrabWrap, GHOST_kGrabHide)) { int x = 0, y = 0; wm_get_cursor_position(win, &x, &y); - pc->draw(C, x - ar_other->winrct.xmin, y - ar_other->winrct.ymin, pc->customdata); - } else { - pc->draw(C, win->eventstate->x - ar_other->winrct.xmin, win->eventstate->y - ar_other->winrct.ymin, pc->customdata); + pc->draw(C, + x - ar_other->winrct.xmin, + y - ar_other->winrct.ymin, + pc->customdata); + } + else { + pc->draw(C, + win->eventstate->x - ar_other->winrct.xmin, + win->eventstate->y - ar_other->winrct.ymin, + pc->customdata); } } } @@ -458,7 +465,8 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple) if(triple->x[x] > maxsize || triple->y[y] > maxsize) { glBindTexture(triple->target, 0); - printf("WM: failed to allocate texture for triple buffer drawing (texture too large for graphics card).\n"); + printf("WM: failed to allocate texture for triple buffer drawing " + "(texture too large for graphics card).\n"); return 0; } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index f7da70b6c77..d78faa76855 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -82,7 +82,8 @@ # include "RNA_enum_types.h" #endif -static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA *properties, ReportList *reports, short context, short poll_only); +static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA *properties, ReportList *reports, + short context, short poll_only); /* ************ event management ************** */ @@ -223,7 +224,9 @@ void wm_event_do_notifiers(bContext *C) } } - if(note->window==win || (note->window == NULL && (note->reference == NULL || note->reference == CTX_data_scene(C)))) { + if (note->window == win || + (note->window == NULL && (note->reference == NULL || note->reference == CTX_data_scene(C)))) + { if(note->category==NC_SCENE) { if(note->data==ND_FRAME) do_anim= 1; @@ -637,7 +640,8 @@ int WM_operator_repeat_check(const bContext *UNUSED(C), wmOperator *op) static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, PointerRNA *properties, ReportList *reports) { - wmOperator *op= MEM_callocN(sizeof(wmOperator), ot->idname); /* XXX operatortype names are static still. for debug */ + /* XXX operatortype names are static still. for debug */ + wmOperator *op= MEM_callocN(sizeof(wmOperator), ot->idname); /* XXX adding new operator could be function, only happens here now */ op->type= ot; @@ -818,8 +822,10 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P if(op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) wm->op_undo_depth--; } - else - printf("invalid operator call %s\n", ot->idname); /* debug, important to leave a while, should never happen */ + else { + /* debug, important to leave a while, should never happen */ + printf("invalid operator call '%s'\n", ot->idname); + } /* Note, if the report is given as an argument then assume the caller will deal with displaying them * currently python only uses this */ @@ -842,9 +848,12 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P int wrap; if (op->opm) { - wrap = (U.uiflag & USER_CONTINUOUS_MOUSE) && ((op->opm->flag & OP_GRAB_POINTER) || (op->opm->type->flag & OPTYPE_GRAB_POINTER)); - } else { - wrap = (U.uiflag & USER_CONTINUOUS_MOUSE) && ((op->flag & OP_GRAB_POINTER) || (ot->flag & OPTYPE_GRAB_POINTER)); + wrap = (U.uiflag & USER_CONTINUOUS_MOUSE) && + ((op->opm->flag & OP_GRAB_POINTER) || (op->opm->type->flag & OPTYPE_GRAB_POINTER)); + } + else { + wrap = (U.uiflag & USER_CONTINUOUS_MOUSE) && + ((op->flag & OP_GRAB_POINTER) || (ot->flag & OPTYPE_GRAB_POINTER)); } /* exception, cont. grab in header is annoying */ @@ -860,7 +869,9 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P ARegion *ar= CTX_wm_region(C); ScrArea *sa= CTX_wm_area(C); - if(ar && ar->regiontype == RGN_TYPE_WINDOW && event && BLI_in_rcti(&ar->winrct, event->x, event->y)) { + if (ar && ar->regiontype == RGN_TYPE_WINDOW && event && + BLI_in_rcti(&ar->winrct, event->x, event->y)) + { winrect= &ar->winrct; } else if(sa) { @@ -895,7 +906,8 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P * this is for python to access since its done the operator lookup * * invokes operator in context */ -static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA *properties, ReportList *reports, short context, short poll_only) +static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA *properties, ReportList *reports, + short context, short poll_only) { wmWindow *window= CTX_wm_window(C); wmEvent *event; @@ -1297,7 +1309,8 @@ static void wm_event_modalkeymap(const bContext *C, wmOperator *op, wmEvent *eve } /* Warning: this function removes a modal handler, when finished */ -static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHandler *handler, wmEvent *event, PointerRNA *properties) +static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHandler *handler, + wmEvent *event, PointerRNA *properties) { int retval= OPERATOR_PASS_THROUGH; @@ -1615,9 +1628,10 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) if(!keymap->poll || keymap->poll(C)) { for(kmi= keymap->items.first; kmi; kmi= kmi->next) { if(wm_eventmatch(event, kmi)) { - - event->keymap_idname= kmi->idname; /* weak, but allows interactive callback to not use rawkey */ - + + /* weak, but allows interactive callback to not use rawkey */ + event->keymap_idname = kmi->idname; + action |= wm_handler_operator_call(C, handlers, handler, event, kmi->ptr); if(action & WM_HANDLER_BREAK) /* not always_pass here, it denotes removed handler */ break; @@ -1716,7 +1730,8 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) ) { event->val = KM_DBL_CLICK; /* removed this because in cases where we're this is used as a single click - * event, this will give old coords, since the distance is checked above, using new coords should be ok. */ + * event, this will give old coords, + * since the distance is checked above, using new coords should be ok. */ // event->x = win->eventstate->prevclickx; // event->y = win->eventstate->prevclicky; action |= wm_handlers_do(C, event, handlers); @@ -2233,7 +2248,8 @@ void WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap) } } -wmEventHandler *WM_event_add_ui_handler(const bContext *C, ListBase *handlers, wmUIHandlerFunc func, wmUIHandlerRemoveFunc remove, void *userdata) +wmEventHandler *WM_event_add_ui_handler(const bContext *C, ListBase *handlers, + wmUIHandlerFunc func, wmUIHandlerRemoveFunc remove, void *userdata) { wmEventHandler *handler= MEM_callocN(sizeof(wmEventHandler), "event ui handler"); handler->ui_handle= func; @@ -2249,7 +2265,8 @@ wmEventHandler *WM_event_add_ui_handler(const bContext *C, ListBase *handlers, w } /* set "postpone" for win->modalhandlers, this is in a running for() loop in wm_handlers_do() */ -void WM_event_remove_ui_handler(ListBase *handlers, wmUIHandlerFunc func, wmUIHandlerRemoveFunc remove, void *userdata, int postpone) +void WM_event_remove_ui_handler(ListBase *handlers, + wmUIHandlerFunc func, wmUIHandlerRemoveFunc remove, void *userdata, int postpone) { wmEventHandler *handler; @@ -2629,7 +2646,9 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U case GHOST_kEventButtonDown: case GHOST_kEventButtonUp: { 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 */ + + /* Note!, this starts as 0/1 but later is converted to KM_PRESS/KM_RELEASE by tweak */ + event.val= (type==GHOST_kEventButtonDown) ? KM_PRESS:KM_RELEASE; if (bd->button == GHOST_kButtonMaskLeft) event.type= LEFTMOUSE; @@ -2700,7 +2719,8 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U if (event.utf8_buf[0]) { if (BLI_str_utf8_size(event.utf8_buf) == -1) { - printf("%s: ghost detected an invalid unicode character '%d'!\n", __func__, (int)(unsigned char)event.utf8_buf[0]); + printf("%s: ghost detected an invalid unicode character '%d'!\n", + __func__, (int)(unsigned char)event.utf8_buf[0]); event.utf8_buf[0]= '\0'; } } @@ -2709,19 +2729,27 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U /* assigning both first and second is strange - campbell */ switch(event.type) { case LEFTSHIFTKEY: case RIGHTSHIFTKEY: - event.shift= evt->shift= (event.val==KM_PRESS) ? ((evt->ctrl || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : FALSE; + event.shift = evt->shift = (event.val == KM_PRESS) ? + ((evt->ctrl || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : + FALSE; break; case LEFTCTRLKEY: case RIGHTCTRLKEY: - event.ctrl= evt->ctrl= (event.val==KM_PRESS) ? ((evt->shift || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : FALSE; + event.ctrl = evt->ctrl = (event.val == KM_PRESS) ? + ((evt->shift || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : + FALSE; break; case LEFTALTKEY: case RIGHTALTKEY: - event.alt= evt->alt= (event.val==KM_PRESS) ? ((evt->ctrl || evt->shift || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : FALSE; + event.alt = evt->alt = (event.val == KM_PRESS) ? + ((evt->ctrl || evt->shift || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : + FALSE; break; case OSKEY: - event.oskey= evt->oskey= (event.val==KM_PRESS) ? ((evt->ctrl || evt->alt || evt->shift) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : FALSE; + event.oskey = evt->oskey = (event.val == KM_PRESS) ? + ((evt->ctrl || evt->alt || evt->shift) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : + FALSE; break; default: - if(event.val==KM_PRESS && event.keymodifier==0) + if(event.val == KM_PRESS && event.keymodifier==0) evt->keymodifier= event.type; /* only set in eventstate, for next event */ else if(event.val==KM_RELEASE && event.keymodifier==event.type) event.keymodifier= evt->keymodifier= 0; diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index a4c90888b74..bae6c7abcda 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -391,7 +391,10 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports) // XXX mainwindow_set_filename_to_title(G.main->name); - if(retval == BKE_READ_FILE_OK_USERPREFS) wm_init_userdef(C); // in case a userdef is read from regular .blend + if(retval == BKE_READ_FILE_OK_USERPREFS) { + /* in case a userdef is read from regular .blend */ + wm_init_userdef(C); + } if (retval != BKE_READ_FILE_FAIL) { G.relbase_valid = 1; @@ -420,13 +423,20 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports) CTX_wm_window_set(C, NULL); /* exits queues */ -#if 0 /* gives popups on windows but not linux, bug in report API but disable for now to stop users getting annoyed */ +#if 0 + /* gives popups on windows but not linux, bug in report API + * but disable for now to stop users getting annoyed */ /* TODO, make this show in header info window */ { Scene *sce; - for(sce= G.main->scene.first; sce; sce= sce->id.next) { - if(sce->r.engine[0] && BLI_findstring(&R_engines, sce->r.engine, offsetof(RenderEngineType, idname)) == NULL) { - BKE_reportf(reports, RPT_WARNING, "Engine not available: '%s' for scene: %s, an addon may need to be installed or enabled", sce->r.engine, sce->id.name+2); + for (sce= G.main->scene.first; sce; sce= sce->id.next) { + if (sce->r.engine[0] && + BLI_findstring(&R_engines, sce->r.engine, offsetof(RenderEngineType, idname)) == NULL) + { + BKE_reportf(reports, RPT_WARNING, + "Engine not available: '%s' for scene: %s, " + "an addon may need to be installed or enabled", + sce->r.engine, sce->id.name+2); } } } @@ -659,8 +669,10 @@ static ImBuf *blend_file_thumb(Scene *scene, int **thumb_pt) return NULL; /* gets scaled to BLEN_THUMB_SIZE */ - ibuf= ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera, BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2, IB_rect, OB_SOLID, err_out); - + ibuf= ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera, + BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2, + IB_rect, OB_SOLID, err_out); + if(ibuf) { float aspect= (scene->r.xsch*scene->r.xasp) / (scene->r.ysch*scene->r.yasp); diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 4fb8751de69..acf6ded0bbe 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -74,7 +74,9 @@ wmGesture *WM_gesture_new(bContext *C, wmEvent *event, int type) wm_subwindow_getorigin(window, gesture->swinid, &sx, &sy); - if( ELEM5(type, WM_GESTURE_RECT, WM_GESTURE_CROSS_RECT, WM_GESTURE_TWEAK, WM_GESTURE_CIRCLE, WM_GESTURE_STRAIGHTLINE)) { + if (ELEM5(type, WM_GESTURE_RECT, WM_GESTURE_CROSS_RECT, WM_GESTURE_TWEAK, + WM_GESTURE_CIRCLE, WM_GESTURE_STRAIGHTLINE)) + { rcti *rect= MEM_callocN(sizeof(rcti), "gesture rect new"); gesture->customdata= rect; diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 661bd90435c..d603262227f 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -767,7 +767,9 @@ char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len) return str; } -static wmKeyMapItem *wm_keymap_item_find_handlers(const bContext *C, ListBase *handlers, const char *opname, int UNUSED(opcontext), IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r) +static wmKeyMapItem *wm_keymap_item_find_handlers( + const bContext *C, ListBase *handlers, const char *opname, int UNUSED(opcontext), + IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r) { wmWindowManager *wm= CTX_wm_manager(C); wmEventHandler *handler; @@ -806,7 +808,9 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(const bContext *C, ListBase *h return NULL; } -static wmKeyMapItem *wm_keymap_item_find_props(const bContext *C, const char *opname, int opcontext, IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r) +static wmKeyMapItem *wm_keymap_item_find_props( + const bContext *C, const char *opname, int opcontext, + IDProperty *properties, int compare_props, int hotkey, wmKeyMap **keymap_r) { wmWindow *win= CTX_wm_window(C); ScrArea *sa= CTX_wm_area(C); @@ -854,7 +858,9 @@ static wmKeyMapItem *wm_keymap_item_find_props(const bContext *C, const char *op return found; } -static wmKeyMapItem *wm_keymap_item_find(const bContext *C, const char *opname, int opcontext, IDProperty *properties, const short hotkey, const short sloppy, wmKeyMap **keymap_r) +static wmKeyMapItem *wm_keymap_item_find( + const bContext *C, const char *opname, int opcontext, + IDProperty *properties, const short hotkey, const short sloppy, wmKeyMap **keymap_r) { wmKeyMapItem *found= wm_keymap_item_find_props(C, opname, opcontext, properties, 1, hotkey, keymap_r); @@ -864,7 +870,9 @@ static wmKeyMapItem *wm_keymap_item_find(const bContext *C, const char *opname, return found; } -char *WM_key_event_operator_string(const bContext *C, const char *opname, int opcontext, IDProperty *properties, const short sloppy, char *str, int len) +char *WM_key_event_operator_string( + const bContext *C, const char *opname, int opcontext, + IDProperty *properties, const short sloppy, char *str, int len) { wmKeyMapItem *kmi= wm_keymap_item_find(C, opname, opcontext, properties, 0, sloppy, NULL); @@ -876,7 +884,9 @@ char *WM_key_event_operator_string(const bContext *C, const char *opname, int op return NULL; } -int WM_key_event_operator_id(const bContext *C, const char *opname, int opcontext, IDProperty *properties, int hotkey, wmKeyMap **keymap_r) +int WM_key_event_operator_id( + const bContext *C, const char *opname, int opcontext, + IDProperty *properties, int hotkey, wmKeyMap **keymap_r) { wmKeyMapItem *kmi= wm_keymap_item_find(C, opname, opcontext, properties, hotkey, TRUE, keymap_r); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 19c45164b53..eddd3c4f3ab 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -153,7 +153,9 @@ void WM_operatortype_append(void (*opfunc)(wmOperatorType*)) ot->name= IFACE_("Dummy Name"); } - RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description:IFACE_("(undocumented operator)")); // XXX All ops should have a description but for now allow them not to. + // XXX All ops should have a description but for now allow them not to. + RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description:IFACE_("(undocumented operator)")); + RNA_def_struct_identifier(ot->srna, ot->idname); BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot); @@ -1136,7 +1138,8 @@ int WM_operator_props_popup(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if((op->type->flag & OPTYPE_REGISTER)==0) { - BKE_reportf(op->reports, RPT_ERROR, "Operator '%s' does not have register enabled, incorrect invoke function.", op->type->idname); + BKE_reportf(op->reports, RPT_ERROR, + "Operator '%s' does not have register enabled, incorrect invoke function.", op->type->idname); return OPERATOR_CANCELLED; } @@ -1845,7 +1848,10 @@ static void WM_OT_link_append(wmOperatorType *ot) ot->flag |= OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_LOADLIB, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_DIRECTORY|WM_FILESEL_FILENAME| WM_FILESEL_RELPATH|WM_FILESEL_FILES, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel( + ot, FOLDERFILE|BLENDERFILE, FILE_LOADLIB, FILE_OPENFILE, + WM_FILESEL_FILEPATH|WM_FILESEL_DIRECTORY|WM_FILESEL_FILENAME|WM_FILESEL_RELPATH|WM_FILESEL_FILES, + FILE_DEFAULTDISPLAY); RNA_def_boolean(ot->srna, "link", 1, "Link", "Link the objects or datablocks rather than appending"); RNA_def_boolean(ot->srna, "autoselect", 1, "Select", "Select the linked objects"); @@ -3205,8 +3211,8 @@ static int radial_control_get_properties(bContext *C, wmOperator *op) return 0; /* slightly ugly; allow this property to not resolve - correctly. needed because 3d texture paint shares the same - keymap as 2d image paint */ + * correctly. needed because 3d texture paint shares the same + * keymap as 2d image paint */ if(!radial_control_get_path(&ctx_ptr, op, "zoom_path", &rc->zoom_ptr, &rc->zoom_prop, 2, RC_PROP_REQUIRE_FLOAT|RC_PROP_ALLOW_MISSING)) diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index fe967bbcd1c..599de5697f1 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -155,7 +155,8 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win) CTX_wm_window_set(C, NULL); } - /* always set drawable and active to NULL, prevents non-drawable state of main windows (bugs #22967 and #25071, possibly #22477 too) */ + /* always set drawable and active to NULL, + * prevents non-drawable state of main windows (bugs #22967 and #25071, possibly #22477 too) */ wm->windrawable= NULL; wm->winactive= NULL; @@ -751,7 +752,10 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) } if(type!=GHOST_kEventWindowSize) { - if(G.f & G_DEBUG) printf("win move event pos %d %d size %d %d\n", win->posx, win->posy, win->sizex, win->sizey); + if(G.f & G_DEBUG) { + printf("win move event pos %d %d size %d %d\n", + win->posx, win->posy, win->sizex, win->sizey); + } } } From 0b13390b9f879fc1feac959dd4ce9c864c5bca31 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 19 Feb 2012 08:09:10 +0000 Subject: [PATCH 6/7] Reload movie clip to ensure all cache and prefetched Ffmpeg frames are properly updating after proxy building is finished. --- source/blender/editors/space_clip/clip_ops.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 5d0f294b06a..a77e6dccbb8 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -879,6 +879,7 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog IMB_anim_index_rebuild(clip->anim, tc_flag, size_flag, quality, stop, do_update, progress); if(!build_undistort_count) { + BKE_movieclip_reload(clip); return; } else { @@ -905,6 +906,8 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog if(distortion) BKE_tracking_distortion_destroy(distortion); + + BKE_movieclip_reload(clip); } static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) From 5cd85ed57ea649c58c7c19d709bfc4cae7fffcad Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 19 Feb 2012 11:09:44 +0000 Subject: [PATCH 7/7] More pose armature code factorization: * New armature_mat_bone_to_pose, which is just the reverse of armature_mat_pose_to_bone (currently used by armature evaluation code only, but might be used by constraints space conversion code too, see note below). * Found another place where another (a bit erroneous) pose_to_bone code existed (apply_targetless_ik(), in transform_conversion.c, used by "auto ik" option), replaced it by a call to armature_mat_pose_to_bone. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Notes: * All those changes leave many #if 0 commented code, I will remove those in a few weeks. * There is at least one other place where generic armature_mat_(pose_to_bone/bone_to_pose) functions should be usable: the space conversion function of constraints (constraint_mat_convertspace(), in BKE's constraint.c), but here I have some problems (old code is also somewhat erroneous, but using new one makes old rigs using bone space constraints wrong, e.g. sintel one, and it’s just impossible to make conversion code...). So I'll wait and investigate more for this one. --- source/blender/blenkernel/BKE_armature.h | 1 + source/blender/blenkernel/intern/armature.c | 14 ++++++++++++++ .../editors/transform/transform_conversions.c | 6 +++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index b09122d022b..e94ad6ecfac 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -107,6 +107,7 @@ void armature_mat_world_to_pose(struct Object *ob, float inmat[][4], float outma void armature_loc_world_to_pose(struct Object *ob, float *inloc, float *outloc); void armature_mat_pose_to_bone(struct bPoseChannel *pchan, float inmat[][4], float outmat[][4]); void armature_loc_pose_to_bone(struct bPoseChannel *pchan, float *inloc, float *outloc); +void armature_mat_bone_to_pose(struct bPoseChannel *pchan, float inmat[][4], float outmat[][4]); void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float arm_mat[][4]); void armature_mat_pose_to_bone_ex(struct Object *ob, struct bPoseChannel *pchan, float inmat[][4], float outmat[][4]); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 02b9330d588..036116c54da 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1302,6 +1302,17 @@ void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outm mul_v3_m4v3(outmat[3], loc_mat, inmat[3]); } +/* Convert Bone-Space Matrix to Pose-Space Matrix. */ +void armature_mat_bone_to_pose(bPoseChannel *pchan, float inmat[][4], float outmat[][4]) +{ + float rotscale_mat[4][4], loc_mat[4][4]; + + pchan_to_pose_mat(pchan, rotscale_mat, loc_mat); + + mult_m4_m4m4(outmat, rotscale_mat, inmat); + mul_v3_m4v3(outmat[3], loc_mat, inmat[3]); +} + /* Convert Pose-Space Location to Bone-Space Location * NOTE: this cannot be used to convert to pose-space location of the supplied * pose-channel into its local space (i.e. 'visual'-keyframing) @@ -2405,6 +2416,8 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti /* Construct the posemat based on PoseChannels, that we do before applying constraints. */ /* pose_mat(b)= pose_mat(b-1) * yoffs(b-1) * d_root(b) * bone_mat(b) * chan_mat(b) */ + armature_mat_bone_to_pose(pchan, pchan->chan_mat, pchan->pose_mat); +#if 0 /* XXX Old code, will remove this later. */ { float rotscale_mat[4][4], loc_mat[4][4]; pchan_to_pose_mat(pchan, rotscale_mat, loc_mat); @@ -2413,6 +2426,7 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti /* Location. */ mul_v3_m4v3(pchan->pose_mat[3], loc_mat, pchan->chan_mat[3]); } +#endif /* Only rootbones get the cyclic offset (unless user doesn't want that). */ /* XXX That could be a problem for snapping and other "reverse transform" features... */ diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index fe244fbdafa..cf8d2c427fd 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -409,7 +409,7 @@ static short apply_targetless_ik(Object *ob) } for(;segcount;segcount--) { Bone *bone; - float rmat[4][4], tmat[4][4], imat[4][4]; + float rmat[4][4]/*, tmat[4][4], imat[4][4]*/; /* pose_mat(b) = pose_mat(b-1) * offs_bone * channel * constraint * IK */ /* we put in channel the entire result of rmat= (channel * constraint * IK) */ @@ -420,6 +420,8 @@ static short apply_targetless_ik(Object *ob) bone= parchan->bone; bone->flag |= BONE_TRANSFORM; /* ensures it gets an auto key inserted */ + /* XXX Old code. Will remove it later. */ +#if 0 if(parchan->parent) { Bone *parbone= parchan->parent->bone; float offs_bone[4][4]; @@ -462,6 +464,8 @@ static short apply_targetless_ik(Object *ob) } /* result matrix */ mult_m4_m4m4(rmat, imat, parchan->pose_mat); +#endif + armature_mat_pose_to_bone(parchan, parchan->pose_mat, rmat); /* apply and decompose, doesn't work for constraints or non-uniform scale well */ {