diff options
author | Joerg Mueller <nexyon@gmail.com> | 2011-08-30 12:22:03 +0400 |
---|---|---|
committer | Joerg Mueller <nexyon@gmail.com> | 2011-08-30 12:22:03 +0400 |
commit | 43ab8e86247b7889d16d915b4f370ceb618aaad4 (patch) | |
tree | 64b1fec1adcc399eb1de5cd86ebafd753a921d8d /source/blender/editors | |
parent | 5b5e600db6f529ad7e1af9d4bb3a193be2265342 (diff) | |
parent | d049a722fea3d150fbfad06ffdbbb5c150717134 (diff) |
* Merge trunk up to r39790.soc-2011-pepper
* Subversion bump (also for init_userdef_do_versions).
* Minor fix for compilation without ffmpeg.
Diffstat (limited to 'source/blender/editors')
45 files changed, 621 insertions, 353 deletions
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 48ddc8df5ef..5345fcd756d 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -337,7 +337,7 @@ void debug_markers_print_list(ListBase *markers) printf("List of markers follows: -----\n"); for (marker = markers->first; marker; marker = marker->next) { - printf("\t'%s' on %d at %p with %d\n", marker->name, marker->frame, (void *)marker, marker->flag); + printf("\t'%s' on %d at %p with %u\n", marker->name, marker->frame, (void *)marker, marker->flag); } printf("End of list ------------------\n"); diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index b22a8a1cc37..928584966d9 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -160,7 +160,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s if (i == 1) strcpy(xval, "x"); else - sprintf(xval, "x^%d", i); + sprintf(xval, "x^%u", i); uiDefBut(block, LABEL, 1, xval, 0, 0, 50, 20, NULL, 0.0, 0.0, 0, 0, "Power of x"); } diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index ec190f05987..eaaaa12eca1 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -492,15 +492,32 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4]) EditBone *ebone; bArmature *arm= ob->data; float scale = mat4_to_scale(mat); /* store the scale of the matrix here to use on envelopes */ - + float mat3[3][3]; + + copy_m3_m4(mat3, mat); + normalize_m3(mat3); + /* Put the armature into editmode */ ED_armature_to_edit(ob); /* Do the rotations */ - for (ebone = arm->edbo->first; ebone; ebone=ebone->next){ + for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { + float delta[3], tmat[3][3]; + + /* find the current bone's roll matrix */ + sub_v3_v3v3(delta, ebone->tail, ebone->head); + vec_roll_to_mat3(delta, ebone->roll, tmat); + + /* transform the roll matrix */ + mul_m3_m3m3(tmat, mat3, tmat); + + /* transform the bone */ mul_m4_v3(mat, ebone->head); mul_m4_v3(mat, ebone->tail); - + + /* apply the transfiormed roll back */ + mat3_to_vec_roll(tmat, NULL, &ebone->roll); + ebone->rad_head *= scale; ebone->rad_tail *= scale; ebone->dist *= scale; @@ -5403,12 +5420,14 @@ void ED_armature_bone_rename(bArmature *arm, char *oldnamep, char *newnamep) ScrArea *sa; /* add regions */ for(sa= screen->areabase.first; sa; sa= sa->next) { - SpaceLink *sl= sa->spacedata.first; - if(sl->spacetype == SPACE_VIEW3D) { - View3D *v3d= (View3D *)sl; - if(v3d->ob_centre && v3d->ob_centre->data == arm) { - if (!strcmp(v3d->ob_centre_bone, oldname)) { - BLI_strncpy(v3d->ob_centre_bone, newname, MAXBONENAME); + SpaceLink *sl; + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if(sl->spacetype==SPACE_VIEW3D) { + View3D *v3d= (View3D *)sl; + if(v3d->ob_centre && v3d->ob_centre->data == arm) { + if (!strcmp(v3d->ob_centre_bone, oldname)) { + BLI_strncpy(v3d->ob_centre_bone, newname, MAXBONENAME); + } } } } diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index dfe0a304748..f8682d3935b 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -288,7 +288,7 @@ unsigned int ED_viewedit_datamask(struct bScreen *screen); int ED_view3d_camera_lock_check(struct View3D *v3d, struct RegionView3D *rv3d); /* copy the camera to the view before starting a view transformation */ void ED_view3d_camera_lock_init(struct View3D *v3d, struct RegionView3D *rv3d); -/* copy the view to the camera */ -void ED_view3d_camera_lock_sync(struct View3D *v3d, struct RegionView3D *rv3d); +/* copy the view to the camera, return TRUE if */ +int ED_view3d_camera_lock_sync(struct View3D *v3d, struct RegionView3D *rv3d); #endif /* ED_VIEW3D_H */ diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index dd7d2ca765f..76ed9891b8e 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -530,14 +530,11 @@ static void ui_draw_but_CHARTAB(uiBut *but) int charmax = G.charmax; /* FO_BUILTIN_NAME font in use. There are TTF FO_BUILTIN_NAME and non-TTF FO_BUILTIN_NAME fonts */ - if(!strcmp(G.selfont->name, FO_BUILTIN_NAME)) - { - if(G.ui_international == TRUE) - { + if(!strcmp(G.selfont->name, FO_BUILTIN_NAME)) { + if(G.ui_international == TRUE) { charmax = 0xff; } - else - { + else { charmax = 0xff; } } @@ -562,16 +559,13 @@ static void ui_draw_but_CHARTAB(uiBut *but) cs = G.charstart; /* Set the font, in case it is not FO_BUILTIN_NAME font */ - if(G.selfont && strcmp(G.selfont->name, FO_BUILTIN_NAME)) - { + if(G.selfont && strcmp(G.selfont->name, FO_BUILTIN_NAME)) { // Is the font file packed, if so then use the packed file - if(G.selfont->packedfile) - { + if(G.selfont->packedfile) { pf = G.selfont->packedfile; FTF_SetFont(pf->data, pf->size, 14.0); } - else - { + else { char tmpStr[256]; int err; @@ -580,10 +574,8 @@ static void ui_draw_but_CHARTAB(uiBut *but) err = FTF_SetFont((unsigned char *)tmpStr, 0, 14.0); } } - else - { - if(G.ui_international == TRUE) - { + else { + if(G.ui_international == TRUE) { FTF_SetFont((unsigned char *) datatoc_bfont_ttf, datatoc_bfont_ttf_size, 14.0); } } @@ -595,8 +587,7 @@ static void ui_draw_but_CHARTAB(uiBut *but) glRectf((rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax)); glColor3ub(0, 0, 0); - for(y = 0; y < 6; y++) - { + for(y = 0; y < 6; y++) { // Do not draw more than the category allows if(cs > charmax) break; @@ -676,23 +667,19 @@ static void ui_draw_but_CHARTAB(uiBut *but) glShadeModel(GL_FLAT); /* Return Font Settings to original */ - if(U.fontsize && U.fontname[0]) - { + if(U.fontsize && U.fontname[0]) { result = FTF_SetFont((unsigned char *)U.fontname, 0, U.fontsize); } - else if (U.fontsize) - { + else if (U.fontsize) { result = FTF_SetFont((unsigned char *) datatoc_bfont_ttf, datatoc_bfont_ttf_size, U.fontsize); } - if (result == 0) - { + if (result == 0) { result = FTF_SetFont((unsigned char *) datatoc_bfont_ttf, datatoc_bfont_ttf_size, 11); } /* resets the font size */ - if(G.ui_international == TRUE) - { + if(G.ui_international == TRUE) { // uiSetCurFont(but->block, UI_HELV); } } @@ -1604,7 +1591,6 @@ void ui_dropshadow(rctf *rct, float radius, float aspect, int UNUSED(select)) #endif { a= i*aspect; - } for(; i--; a-=aspect) { diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 173aa98374c..7661fa5994b 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -800,8 +800,7 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to) if(!act_iter) return; /* (3) add a new controller */ - if (WM_operator_name_call(C, "LOGIC_OT_controller_add", WM_OP_EXEC_DEFAULT, NULL) & OPERATOR_FINISHED) - { + if (WM_operator_name_call(C, "LOGIC_OT_controller_add", WM_OP_EXEC_DEFAULT, NULL) & OPERATOR_FINISHED) { cont = (bController *)ob->controllers.last; /* (4) link the sensor->controller->actuator */ diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 412c0233c35..c3a0f438fbe 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -1103,8 +1103,7 @@ int ui_id_icon_get(bContext *C, ID *id, int big) int iconid= 0; /* icon */ - switch(GS(id->name)) - { + switch(GS(id->name)) { case ID_BR: iconid= ui_id_brush_get_icon(C, id); break; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 3575a8527fc..ef88bb0bbb6 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1361,7 +1361,7 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna static void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt) { MenuType *mt= (MenuType*)arg_mt; - Menu menu = {0}; + Menu menu = {NULL}; menu.type= mt; menu.layout= layout; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 9aaba786050..d2cee11c755 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2373,6 +2373,7 @@ void uiTemplateOperatorSearch(uiLayout *layout) #define B_STOPCAST 2 #define B_STOPANIM 3 #define B_STOPCOMPO 4 +#define B_STOPSEQ 5 static void do_running_jobs(bContext *C, void *UNUSED(arg), int event) { @@ -2389,6 +2390,9 @@ static void do_running_jobs(bContext *C, void *UNUSED(arg), int event) case B_STOPCOMPO: WM_jobs_stop(CTX_wm_manager(C), CTX_wm_area(C), NULL); break; + case B_STOPSEQ: + WM_jobs_stop(CTX_wm_manager(C), CTX_wm_area(C), NULL); + break; } } @@ -2410,8 +2414,11 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) if(WM_jobs_test(wm, sa)) owner = sa; handle_event= B_STOPCOMPO; - } - else { + } else if (sa->spacetype==SPACE_SEQ) { + if(WM_jobs_test(wm, sa)) + owner = sa; + handle_event = B_STOPSEQ; + } else { Scene *scene; /* another scene can be rendering too, for example via compositor */ for(scene= CTX_data_main(C)->scene.first; scene; scene= scene->id.next) diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 02054fbe90f..692c8940a21 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1588,6 +1588,14 @@ void init_userdef_do_versions(void) } } + if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 1)) { + bTheme *btheme; + + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + btheme->tv3d.speaker[3] = 255; + } + } + /* GL Texture Garbage Collection (variable abused above!) */ if (U.textimeout == 0) { U.texcollectrate = 60; @@ -1625,13 +1633,6 @@ void init_userdef_do_versions(void) NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE; } - { - bTheme *btheme; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { - btheme->tv3d.speaker[3] = 255; - } - } - /* funny name, but it is GE stuff, moves userdef stuff to engine */ // XXX space_set_commmandline_options(); /* this timer uses U */ diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 2ac9161ffa3..c96d7c1fd10 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1280,7 +1280,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; if(mmd->bindcagecos) { - if(mmd->bindcagecos) MEM_freeN(mmd->bindcagecos); + MEM_freeN(mmd->bindcagecos); if(mmd->dyngrid) MEM_freeN(mmd->dyngrid); if(mmd->dyninfluences) MEM_freeN(mmd->dyninfluences); if(mmd->bindinfluences) MEM_freeN(mmd->bindinfluences); diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index b8cdc18e739..4b0c1cb1222 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -3988,7 +3988,7 @@ static void PTCacheUndo_clear(PTCacheEdit *edit) { PTCacheUndo *undo; - if(edit==0) return; + if(edit==NULL) return; undo= edit->undo.first; while(undo) { diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index 797ead3cd90..34f4a1e472b 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -172,7 +172,6 @@ void PTCACHE_OT_free_bake_all(wmOperatorType *ot) { /* identifiers */ ot->name= "Free All Physics Bakes"; - ot->name= "Free all physics bakes"; ot->idname= "PTCACHE_OT_free_bake_all"; /* api callbacks */ diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 007ae96ae59..b937f9a4104 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -64,6 +64,7 @@ #include "DNA_brush_types.h" #include "DNA_screen_types.h" +#include "BKE_brush.h" #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_global.h" diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index fbdcf7ba9b3..1b24d660411 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -85,6 +85,8 @@ #include "UI_interface.h" +#include "RE_pipeline.h" + #include "render_intern.h" // own include /********************** material slot operators *********************/ @@ -661,60 +663,21 @@ void TEXTURE_OT_slot_move(wmOperatorType *ot) /********************** environment map operators *********************/ -static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *str, int imtype) +static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *path, int imtype) { - ImBuf *ibuf=NULL; - int dx; - int retval; - int relative= (RNA_struct_find_property(op->ptr, "relative_path") && RNA_boolean_get(op->ptr, "relative_path")); - - if(env->cube[1]==NULL) { - BKE_report(op->reports, RPT_ERROR, "There is no generated environment map available to save"); - return OPERATOR_CANCELLED; - } - - dx= env->cube[1]->x; - - if (env->type == ENV_CUBE) { - ibuf = IMB_allocImBuf(3*dx, 2*dx, 24, IB_rectfloat); - - IMB_rectcpy(ibuf, env->cube[0], 0, 0, 0, 0, dx, dx); - IMB_rectcpy(ibuf, env->cube[1], dx, 0, 0, 0, dx, dx); - IMB_rectcpy(ibuf, env->cube[2], 2*dx, 0, 0, 0, dx, dx); - IMB_rectcpy(ibuf, env->cube[3], 0, dx, 0, 0, dx, dx); - IMB_rectcpy(ibuf, env->cube[4], dx, dx, 0, 0, dx, dx); - IMB_rectcpy(ibuf, env->cube[5], 2*dx, dx, 0, 0, dx, dx); - } - else if (env->type == ENV_PLANE) { - ibuf = IMB_allocImBuf(dx, dx, 24, IB_rectfloat); - IMB_rectcpy(ibuf, env->cube[1], 0, 0, 0, 0, dx, dx); + float layout[12]; + if ( RNA_struct_find_property(op->ptr, "layout") ) + RNA_float_get_array(op->ptr, "layout",layout); + else + memcpy(layout, default_envmap_layout, sizeof(layout)); + + if (RE_WriteEnvmapResult(op->reports, scene, env, path, imtype, layout)) { + return OPERATOR_FINISHED; } else { - BKE_report(op->reports, RPT_ERROR, "Invalid environment map type"); return OPERATOR_CANCELLED; } - - if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) - ibuf->profile = IB_PROFILE_LINEAR_RGB; - - /* to save, we first get absolute path */ - BLI_path_abs(str, G.main->name); - - if (BKE_write_ibuf(ibuf, str, imtype, scene->r.subimtype, scene->r.quality)) { - retval = OPERATOR_FINISHED; - } - else { - BKE_reportf(op->reports, RPT_ERROR, "Error saving environment map to %s.", str); - retval = OPERATOR_CANCELLED; - } - /* in case we were saving with relative paths, change back again */ - if(relative) - BLI_path_rel(str, G.main->name); - - IMB_freeImBuf(ibuf); - ibuf = NULL; - - return retval; + } static int envmap_save_exec(bContext *C, wmOperator *op) @@ -753,7 +716,6 @@ static int envmap_save_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event return envmap_save_exec(C, op); //RNA_enum_set(op->ptr, "file_type", scene->r.imtype); - RNA_string_set(op->ptr, "filepath", G.main->name); WM_event_add_fileselect(C, op); @@ -776,6 +738,7 @@ static int envmap_save_poll(bContext *C) void TEXTURE_OT_envmap_save(wmOperatorType *ot) { + PropertyRNA *prop; /* identifiers */ ot->name= "Save Environment Map"; ot->idname= "TEXTURE_OT_envmap_save"; @@ -790,8 +753,10 @@ void TEXTURE_OT_envmap_save(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER; /* no undo since this doesnt modify the env-map */ /* properties */ - //RNA_def_enum(ot->srna, "file_type", image_file_type_items, R_PNG, "File Type", "File type to save image as."); - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); + prop= RNA_def_float_array(ot->srna, "layout", 12, default_envmap_layout, 0.0f, 0.0f, "File layout", "Flat array describing the X,Y position of each cube face in the output image, where 1 is the size of a face. Order is [+Z -Z +Y -X -Y +X]. Use -1 to skip a face.", 0.0f, 0.0f); + RNA_def_property_flag(prop, PROP_HIDDEN); + + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH); } static int envmap_clear_exec(bContext *C, wmOperator *UNUSED(op)) diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 80a65d3224e..5e875e40f14 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -533,8 +533,7 @@ int screen_area_join(bContext *C, bScreen* scr, ScrArea *sa1, ScrArea *sa2) dir = area_getorientation(sa1, sa2); /*printf("dir is : %i \n", dir);*/ - if (dir < 0) - { + if (dir < 0) { if (sa1 ) sa1->flag &= ~AREA_FLAG_DRAWJOINFROM; if (sa2 ) sa2->flag &= ~AREA_FLAG_DRAWJOINTO; return 0; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index b9b82dad6ca..66a67d7c4f2 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1544,8 +1544,7 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge) /* subtractwidth of regions on opposite side * prevents dragging regions into other opposite regions */ - for (ar=sa->regionbase.first; ar; ar=ar->next) - { + for (ar=sa->regionbase.first; ar; ar=ar->next) { if (ar == scalear) continue; @@ -1703,7 +1702,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_RUNNING_MODAL; } -int region_scale_cancel(bContext *UNUSED(C), wmOperator *op) +static int region_scale_cancel(bContext *UNUSED(C), wmOperator *op) { MEM_freeN(op->customdata); op->customdata = NULL; @@ -2021,12 +2020,12 @@ static void SCREEN_OT_screen_full_area(wmOperatorType *ot) */ typedef struct sAreaJoinData - { - ScrArea *sa1; /* first area to be considered */ - ScrArea *sa2; /* second area to be considered */ - ScrArea *scr; /* designed for removal */ - - } sAreaJoinData; +{ + ScrArea *sa1; /* first area to be considered */ + ScrArea *sa2; /* second area to be considered */ + ScrArea *scr; /* designed for removal */ + +} sAreaJoinData; /* validate selection inside screen, set variables OK */ diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 32004fd4525..d69c1d9c447 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -512,7 +512,7 @@ static float VecZDepthOrtho(float pt[2], float v1[3], float v2[3], float v3[3], return (v1[2]*w[0]) + (v2[2]*w[1]) + (v3[2]*w[2]); } -static float VecZDepthPersp(float pt[2], float v1[3], float v2[3], float v3[3], float w[3]) +static float VecZDepthPersp(float pt[2], float v1[4], float v2[4], float v3[4], float w[3]) { float wtot_inv, wtot; float w_tmp[3]; @@ -1193,7 +1193,7 @@ static void screen_px_from_ortho( * the perspective W coord for each vert */ static void screen_px_from_persp( float uv[2], - float v1co[3], float v2co[3], float v3co[3], /* screenspace coords */ + float v1co[4], float v2co[4], float v3co[4], /* screenspace coords */ float uv1co[2], float uv2co[2], float uv3co[2], float pixelScreenCo[4], float w[3]) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index be985342ea8..2ee49f71a78 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2979,7 +2979,7 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush) SCULPT_TOOL_GRAB, SCULPT_TOOL_NUDGE, SCULPT_TOOL_CLAY_TUBES, SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)) { - float grab_location[3], imat[4][4], delta[3]; + float grab_location[3], imat[4][4], delta[3], loc[3]; if(cache->first_time) { copy_v3_v3(cache->orig_grab_location, @@ -2989,10 +2989,8 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush) add_v3_v3(cache->true_location, cache->grab_delta); /* compute 3d coordinate at same z from original location + mouse */ - initgrabz(cache->vc->rv3d, - cache->orig_grab_location[0], - cache->orig_grab_location[1], - cache->orig_grab_location[2]); + mul_v3_m4v3(loc, ob->obmat, cache->orig_grab_location); + initgrabz(cache->vc->rv3d, loc[0], loc[1], loc[2]); ED_view3d_win_to_delta(cache->vc->ar, cache->mouse, grab_location); @@ -3088,9 +3086,6 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, st else { cache->initial_radius= brush_unprojected_radius(brush); } - - if (ELEM(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK)) - cache->initial_radius *= 2.0f; } if(brush_use_size_pressure(brush)) { diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index e2d80e9e775..ef927fd69fc 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -269,6 +269,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) buttons_area_redraw(sa, BCONTEXT_DATA); /* autotexpace flag */ break; case ND_POSE: + buttons_area_redraw(sa, BCONTEXT_DATA); case ND_BONE_ACTIVE: case ND_BONE_SELECT: buttons_area_redraw(sa, BCONTEXT_BONE); diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 890a6cf545a..52c5100900d 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -165,8 +165,11 @@ static void id_drop_copy(wmDrag *drag, wmDropBox *drop) { char text[64]; ID *id= drag->poin; + char id_esc[(sizeof(id->name) - 2) * 2]; - snprintf(text, sizeof(text), "bpy.data.%s['%s']", BKE_idcode_to_name_plural(GS(id->name)), id->name+2); + BLI_strescape(id_esc, id->name+2, sizeof(id_esc)); + + snprintf(text, sizeof(text), "bpy.data.%s[\"%s\"]", BKE_idcode_to_name_plural(GS(id->name)), id_esc); /* copy drag path to properties */ RNA_string_set(drop->ptr, "text", text); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 4dd97c63d40..1b0893e50e0 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -621,25 +621,31 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath) } /* some ops have multiple files to select */ + /* this is called on operators check() so clear collections first since + * they may be already set. */ { PointerRNA itemptr; + PropertyRNA *prop_files= RNA_struct_find_property(op->ptr, "files"); + PropertyRNA *prop_dirs= RNA_struct_find_property(op->ptr, "dirs"); int i, numfiles = filelist_numfiles(sfile->files); - if(RNA_struct_find_property(op->ptr, "files")) { + if(prop_files) { + RNA_property_collection_clear(op->ptr, prop_files); for (i=0; i<numfiles; i++) { if (filelist_is_selected(sfile->files, i, CHECK_FILES)) { struct direntry *file= filelist_file(sfile->files, i); - RNA_collection_add(op->ptr, "files", &itemptr); + RNA_property_collection_add(op->ptr, prop_files, &itemptr); RNA_string_set(&itemptr, "name", file->relname); } } } - - if(RNA_struct_find_property(op->ptr, "dirs")) { + + if(prop_dirs) { + RNA_property_collection_clear(op->ptr, prop_dirs); for (i=0; i<numfiles; i++) { if (filelist_is_selected(sfile->files, i, CHECK_DIRS)) { struct direntry *file= filelist_file(sfile->files, i); - RNA_collection_add(op->ptr, "dirs", &itemptr); + RNA_property_collection_add(op->ptr, prop_dirs, &itemptr); RNA_string_set(&itemptr, "name", file->relname); } } @@ -651,25 +657,27 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath) void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op) { - int change= FALSE; - if(RNA_struct_find_property(op->ptr, "filename")) { - RNA_string_get(op->ptr, "filename", sfile->params->file); - change= TRUE; - } - if(RNA_struct_find_property(op->ptr, "directory")) { - RNA_string_get(op->ptr, "directory", sfile->params->dir); - change= TRUE; - } - + PropertyRNA *prop; + /* If neither of the above are set, split the filepath back */ - if(RNA_struct_find_property(op->ptr, "filepath")) { - if(change==FALSE) { - char filepath[FILE_MAX]; - RNA_string_get(op->ptr, "filepath", filepath); - BLI_split_dirfile(filepath, sfile->params->dir, sfile->params->file); + if((prop= RNA_struct_find_property(op->ptr, "filepath"))) { + char filepath[FILE_MAX]; + RNA_property_string_get(op->ptr, prop, filepath); + BLI_split_dirfile(filepath, sfile->params->dir, sfile->params->file); + } + else { + if((prop= RNA_struct_find_property(op->ptr, "filename"))) { + RNA_property_string_get(op->ptr, prop, sfile->params->file); + } + if((prop= RNA_struct_find_property(op->ptr, "directory"))) { + RNA_property_string_get(op->ptr, prop, sfile->params->dir); } } + /* we could check for relative_path property which is used when converting + * in the other direction but doesnt hurt to do this every time */ + BLI_path_abs(sfile->params->dir, G.main->name); + /* XXX, files and dirs updates missing, not really so important though */ } diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index a6e84b0c41d..aa2ea124fe0 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -300,7 +300,7 @@ void fsmenu_read_system(struct FSMenu* fsmenu) tmp= GetLogicalDrives(); - for (i=2; i < 26; i++) { + for (i=0; i < 26; i++) { if ((tmp>>i) & 1) { tmps[0]='A'+i; tmps[1]=':'; diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 66e844e67a8..4011f038be8 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -113,7 +113,7 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, if(ima->source==IMA_SRC_MOVIE) { ofs+= sprintf(str, "Movie"); if(ima->anim) - ofs+= sprintf(str+ofs, "%d frs", IMB_anim_get_duration(ima->anim)); + ofs+= sprintf(str+ofs, "%d frs", IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN)); } else ofs+= sprintf(str, "Image"); @@ -428,7 +428,7 @@ static void set_frames_cb(bContext *C, void *ima_v, void *iuser_v) ImageUser *iuser= iuser_v; if(ima->anim) { - iuser->frames = IMB_anim_get_duration(ima->anim); + iuser->frames = IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN); BKE_image_user_calc_frame(iuser, scene->r.cfra, 0); } } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 6e0d1909963..d58b78ff6a7 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -938,9 +938,100 @@ void IMAGE_OT_replace(wmOperatorType *ot) /******************** save image as operator ********************/ +typedef struct { + /* matching scene->r settings */ + short planes, imtype, subimtype, quality; + char filepath[FILE_MAX]; /* keep absolute */ +} SaveImageOptions; + +static void save_image_options_defaults(SaveImageOptions *simopts) +{ + simopts->planes= R_PLANES24; + simopts->imtype= R_PNG; + simopts->subimtype= 0; + simopts->quality= 90; + simopts->filepath[0]= '\0'; +} + +static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, Scene *scene, const short guess_path) +{ + void *lock; + ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock); + + if(ibuf) { + Image *ima= sima->image; + RenderResult *rr= BKE_image_acquire_renderresult(scene, ima); + + simopts->planes= ibuf->depth; + + /* cant save multilayer sequence, ima->rr isn't valid for a specific frame */ + if(rr && !(ima->source==IMA_SRC_SEQUENCE && ima->type==IMA_TYPE_MULTILAYER)) + simopts->imtype= R_MULTILAYER; + else if(ima->type==IMA_TYPE_R_RESULT) + simopts->imtype= scene->r.imtype; + else if (ima->source == IMA_SRC_GENERATED) + simopts->imtype= R_PNG; + else + simopts->imtype= BKE_ftype_to_imtype(ibuf->ftype); + + simopts->subimtype= scene->r.subimtype; /* XXX - this is lame, we need to make these available too! */ + simopts->quality= ibuf->ftype & 0xff; + + BLI_strncpy(simopts->filepath, ibuf->name, sizeof(simopts->filepath)); + + /* sanitize all settings */ + + /* unlikely but just incase */ + if (ELEM3(simopts->planes, R_PLANESBW, R_PLANES24, R_PLANES32) == 0) { + simopts->planes= R_PLANES32; + } + + /* some formats dont use quality so fallback to scenes quality */ + if (simopts->quality == 0) { + simopts->quality= scene->r.quality; + } + + /* check for empty path */ + if(guess_path && simopts->filepath[0]==0) { + if ( (G.ima[0] == '/') && (G.ima[1] == '/') && (G.ima[2] == '\0') ) { + BLI_strncpy(simopts->filepath, "//untitled", FILE_MAX); + } else { + BLI_strncpy(simopts->filepath, G.ima, FILE_MAX); + } + BLI_path_abs(simopts->filepath, G.main->name); + } + /* cleanup */ + BKE_image_release_renderresult(scene, ima); + } + + ED_space_image_release_buffer(sima, lock); + + return (ibuf != NULL); +} + +static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op) +{ + if (RNA_property_is_set(op->ptr, "color_mode")) simopts->planes= RNA_enum_get(op->ptr, "color_mode"); + if (RNA_property_is_set(op->ptr, "file_format")) simopts->imtype= RNA_enum_get(op->ptr, "file_format"); + // if (RNA_property_is_set(op->ptr, "subimtype")) simopts->subimtype= RNA_enum_get(op->ptr, "subimtype"); // XXX + if (RNA_property_is_set(op->ptr, "file_quality")) simopts->quality= RNA_int_get(op->ptr, "file_quality"); + + if (RNA_property_is_set(op->ptr, "filepath")) RNA_string_get(op->ptr, "filepath", simopts->filepath); +} + +static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op) +{ + RNA_enum_set(op->ptr, "color_mode", simopts->planes); + RNA_enum_set(op->ptr, "file_format", simopts->imtype); + // RNA_enum_set(op->ptr, "subimtype", simopts->subimtype); + RNA_int_set(op->ptr, "file_quality", simopts->quality); + + RNA_string_set(op->ptr, "filepath", simopts->filepath); +} + /* assumes name is FILE_MAX */ /* ima->name and ibuf->name should end up the same */ -static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOperator *op, char *path, int do_newpath) +static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveImageOptions *simopts, int do_newpath) { Image *ima= ED_space_image(sima); void *lock; @@ -952,18 +1043,17 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera const short save_copy= (RNA_struct_find_property(op->ptr, "copy") && RNA_boolean_get(op->ptr, "copy")); short ok= FALSE; - BLI_path_abs(path, bmain->name); /* old global to ensure a 2nd save goes to same dir */ - BLI_strncpy(G.ima, path, sizeof(G.ima)); + BLI_strncpy(G.ima, simopts->filepath, sizeof(G.ima)); WM_cursor_wait(1); if(ima->type == IMA_TYPE_R_RESULT) { /* enforce user setting for RGB or RGBA, but skip BW */ - if(scene->r.planes==32) { + if(simopts->planes==R_PLANES32) { ibuf->depth= 32; } - else if(scene->r.planes==24) { + else if(simopts->planes==R_PLANES24) { ibuf->depth= 24; } } @@ -974,15 +1064,12 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera ibuf->depth= BKE_alphatest_ibuf(ibuf) ? 32 : 24; } } - - if(scene->r.scemode & R_EXTENSION) { - BKE_add_image_extension(path, sima->imtypenr); - } - if(sima->imtypenr==R_MULTILAYER) { + if(simopts->imtype==R_MULTILAYER) { + Scene *scene= CTX_data_scene(C); RenderResult *rr= BKE_image_acquire_renderresult(scene, ima); if(rr) { - RE_WriteRenderResult(rr, path, scene->r.quality); + RE_WriteRenderResult(rr, simopts->filepath, simopts->quality); ok= TRUE; } else { @@ -990,23 +1077,23 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera } BKE_image_release_renderresult(scene, ima); } - else if (BKE_write_ibuf(ibuf, path, sima->imtypenr, scene->r.subimtype, scene->r.quality)) { + else if (BKE_write_ibuf(ibuf, simopts->filepath, simopts->imtype, simopts->subimtype, simopts->quality)) { ok= TRUE; } if(ok) { if(relative) - BLI_path_rel(path, bmain->name); /* only after saving */ + BLI_path_rel(simopts->filepath, bmain->name); /* only after saving */ if(ibuf->name[0]==0) { - BLI_strncpy(ibuf->name, path, sizeof(ibuf->name)); - BLI_strncpy(ima->name, path, sizeof(ima->name)); + BLI_strncpy(ibuf->name, simopts->filepath, sizeof(ibuf->name)); + BLI_strncpy(ima->name, simopts->filepath, sizeof(ima->name)); } if(!save_copy) { if(do_newpath) { - BLI_strncpy(ima->name, path, sizeof(ima->name)); - BLI_strncpy(ibuf->name, path, sizeof(ibuf->name)); + BLI_strncpy(ima->name, simopts->filepath, sizeof(ima->name)); + BLI_strncpy(ibuf->name, simopts->filepath, sizeof(ibuf->name)); } ibuf->userflags &= ~IB_BITMAPDIRTY; @@ -1034,7 +1121,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera } } else { - BKE_reportf(op->reports, RPT_ERROR, "Couldn't write image: %s", path); + BKE_reportf(op->reports, RPT_ERROR, "Couldn't write image: %s", simopts->filepath); } @@ -1049,17 +1136,14 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera static int save_as_exec(bContext *C, wmOperator *op) { SpaceImage *sima= CTX_wm_space_image(C); - Scene *scene= CTX_data_scene(C); - Image *ima = ED_space_image(sima); - char str[FILE_MAX]; + SaveImageOptions simopts; - if(!ima) - return OPERATOR_CANCELLED; + /* just incase to initialize values, + * these should be set on invoke or by the caller. */ + save_image_options_defaults(&simopts); + save_image_options_from_op(&simopts, op); - sima->imtypenr= RNA_enum_get(op->ptr, "file_type"); - RNA_string_get(op->ptr, "filepath", str); - - save_image_doit(C, sima, scene, op, str, TRUE); + save_image_doit(C, sima, op, &simopts, TRUE); return OPERATOR_FINISHED; } @@ -1069,7 +1153,7 @@ static int save_as_check(bContext *UNUSED(C), wmOperator *op) { char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); - if(BKE_add_image_extension(filepath, RNA_enum_get(op->ptr, "file_type"))) { + if(BKE_add_image_extension(filepath, RNA_enum_get(op->ptr, "file_format"))) { RNA_string_set(op->ptr, "filepath", filepath); return TRUE; } @@ -1081,65 +1165,33 @@ static int save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) SpaceImage *sima= CTX_wm_space_image(C); Image *ima = ED_space_image(sima); Scene *scene= CTX_data_scene(C); - ImBuf *ibuf; - char filename[FILE_MAX]; - - void *lock; + SaveImageOptions simopts; if(!RNA_property_is_set(op->ptr, "relative_path")) RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS); if(RNA_property_is_set(op->ptr, "filepath")) return save_as_exec(C, op); - - if(!ima) - return OPERATOR_CANCELLED; - /* always opens fileselect */ - ibuf= ED_space_image_acquire_buffer(sima, &lock); - - if(ibuf) { - /* cant save multilayer sequence, ima->rr isn't valid for a specific frame */ - if(ima->rr && !(ima->source==IMA_SRC_SEQUENCE && ima->type==IMA_TYPE_MULTILAYER)) - sima->imtypenr= R_MULTILAYER; - else if(ima->type==IMA_TYPE_R_RESULT) - sima->imtypenr= scene->r.imtype; - else if (ima->source == IMA_SRC_GENERATED) - sima->imtypenr= R_PNG; - else - sima->imtypenr= BKE_ftype_to_imtype(ibuf->ftype); - - RNA_enum_set(op->ptr, "file_type", sima->imtypenr); - - if(ibuf->name[0]==0) - if ( (G.ima[0] == '/') && (G.ima[1] == '/') && (G.ima[2] == '\0') ) { - BLI_strncpy(filename, "//untitled", FILE_MAX); - } else { - BLI_strncpy(filename, G.ima, FILE_MAX); - } - else - BLI_strncpy(filename, ibuf->name, FILE_MAX); - - /* enable save_copy by default for render results */ - if(ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE) && !RNA_property_is_set(op->ptr, "copy")) { - RNA_boolean_set(op->ptr, "copy", TRUE); - } - - // XXX note: we can give default menu enums to operator for this - image_filesel(C, op, filename); + if (save_image_options_init(&simopts, sima, scene, TRUE) == 0) + return OPERATOR_CANCELLED; + save_image_options_to_op(&simopts, op); - ED_space_image_release_buffer(sima, lock); - - return OPERATOR_RUNNING_MODAL; + /* enable save_copy by default for render results */ + if(ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE) && !RNA_property_is_set(op->ptr, "copy")) { + RNA_boolean_set(op->ptr, "copy", TRUE); } - ED_space_image_release_buffer(sima, lock); + // XXX note: we can give default menu enums to operator for this + image_filesel(C, op, simopts.filepath); - return OPERATOR_CANCELLED; + return OPERATOR_RUNNING_MODAL; } void IMAGE_OT_save_as(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name= "Save As Image"; ot->idname= "IMAGE_OT_save_as"; @@ -1154,7 +1206,13 @@ void IMAGE_OT_save_as(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "file_type", image_file_type_items, R_PNG, "File Type", "File type to save image as."); + + /* format options */ + RNA_def_enum(ot->srna, "file_format", image_file_type_items, R_PNG, "File Type", "File type to save image as."); + RNA_def_enum(ot->srna, "color_mode", image_color_mode_items, R_PLANES24, "Channels", "Image channels to save"); + prop= RNA_def_int(ot->srna, "file_quality", 90, 0, 100, "Quality", "", 0, 100); + RNA_def_property_subtype(prop, PROP_PERCENTAGE); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); RNA_def_boolean(ot->srna, "copy", 0, "Copy", "Create a new image file without modifying the current image in blender"); @@ -1164,45 +1222,19 @@ void IMAGE_OT_save_as(wmOperatorType *ot) static int save_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); SpaceImage *sima= CTX_wm_space_image(C); - Image *ima = ED_space_image(sima); - void *lock; - ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock); Scene *scene= CTX_data_scene(C); - RenderResult *rr; - char name[FILE_MAX]; + SaveImageOptions simopts; - if(!ima || !ibuf) { - ED_space_image_release_buffer(sima, lock); + if (save_image_options_init(&simopts, sima, scene, FALSE) == 0) return OPERATOR_CANCELLED; - } - - /* if exists, saves over without fileselect */ - - BLI_strncpy(name, ima->name, FILE_MAX); - if(name[0]==0) - BLI_strncpy(name, G.ima, FILE_MAX); - else - BLI_path_abs(name, bmain->name); - - if(BLI_exists(name) && BLI_is_writable(name)) { - rr= BKE_image_acquire_renderresult(scene, ima); + save_image_options_from_op(&simopts, op); - if(rr) - sima->imtypenr= R_MULTILAYER; - else - sima->imtypenr= BKE_ftype_to_imtype(ibuf->ftype); - - BKE_image_release_renderresult(scene, ima); - ED_space_image_release_buffer(sima, lock); - - save_image_doit(C, sima, scene, op, name, FALSE); + if (BLI_exists(simopts.filepath) && BLI_is_writable(simopts.filepath)) { + save_image_doit(C, sima, op, &simopts, FALSE); } else { - ED_space_image_release_buffer(sima, lock); - - BKE_report(op->reports, RPT_ERROR, "Can not save image."); + BKE_reportf(op->reports, RPT_ERROR, "Can not save image, path '%s' is not writable.", simopts.filepath); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 011f9a31c93..508cb82ee1b 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -3080,78 +3080,115 @@ void NODE_OT_delete(wmOperatorType *ot) } /* ****************** Delete with reconnect ******************* */ +static int is_connected_to_input_socket(bNode* node, bNodeLink* link) { + bNodeSocket *sock; + if (link->tonode == node) { + for(sock= node->inputs.first; sock; sock= sock->next) { + if (link->tosock == sock) { + return sock->type; + } + } + } + return -1; +} -/* note: in cmp_util.c is similar code, for node_compo_pass_on() */ -/* used for disabling node (similar code in node_draw.c for disable line) */ static void node_delete_reconnect(bNodeTree* tree, bNode* node) { - bNodeLink *link, *next; + bNodeLink *link, *next, *first = NULL; bNodeSocket *valsocket= NULL, *colsocket= NULL, *vecsocket= NULL; bNodeSocket *deliveringvalsocket= NULL, *deliveringcolsocket= NULL, *deliveringvecsocket= NULL; bNode *deliveringvalnode= NULL, *deliveringcolnode= NULL, *deliveringvecnode= NULL; bNodeSocket *sock; - - /* test the inputs */ - for(sock= node->inputs.first; sock; sock= sock->next) { - int type = sock->type; - if(type==SOCK_VALUE && valsocket==NULL) valsocket = sock; - if(type==SOCK_VECTOR && vecsocket==NULL) vecsocket = sock; - if(type==SOCK_RGBA && colsocket==NULL) colsocket = sock; - } - // we now have the input sockets for the 'data types' - // now find the output sockets (and nodes) in the tree that delivers data to these input sockets + int type; + int numberOfConnectedOutputSockets = 0; + int numberOfReconnections = 0; + int numberOfConnectedInputSockets = 0; + + /* + test the inputs, not really correct when a node has multiple input sockets of the same type + the first link evaluated will be used to determine the possible connection. + */ for(link= tree->links.first; link; link=link->next) { - if (valsocket != NULL) { - if (link->tosock == valsocket) { - deliveringvalnode = link->fromnode; - deliveringvalsocket = link->fromsock; + if (link->tonode == node) { numberOfConnectedInputSockets++; } + type = is_connected_to_input_socket(node, link); + switch (type) { + case SOCK_RGBA: + if (colsocket == NULL) { + colsocket = link->tosock; + deliveringcolnode = link->fromnode; + deliveringcolsocket = link->fromsock; } - } - if (vecsocket != NULL) { - if (link->tosock == vecsocket) { + break; + case SOCK_VECTOR: + if (vecsocket == NULL) { + vecsocket = link->tosock; deliveringvecnode = link->fromnode; deliveringvecsocket = link->fromsock; } - } - if (colsocket != NULL) { - if (link->tosock == colsocket) { - deliveringcolnode = link->fromnode; - deliveringcolsocket = link->fromsock; + break; + case SOCK_VALUE: + if (valsocket == NULL) { + valsocket = link->tosock; + deliveringvalnode = link->fromnode; + deliveringvalsocket = link->fromsock; } + break; + default: + break; } } + // we now have the sockets+nodes that fill the inputsockets be aware for group nodes these can be NULL // now make the links for all outputlinks of the node to be reconnected for(link= tree->links.first; link; link=next) { next= link->next; if (link->fromnode == node) { sock = link->fromsock; + numberOfConnectedOutputSockets ++; + if (!first) first = link; switch(sock->type) { case SOCK_VALUE: if (deliveringvalsocket) { link->fromnode = deliveringvalnode; link->fromsock = deliveringvalsocket; + numberOfReconnections++; } break; case SOCK_VECTOR: if (deliveringvecsocket) { link->fromnode = deliveringvecnode; link->fromsock = deliveringvecsocket; + numberOfReconnections++; } break; case SOCK_RGBA: if (deliveringcolsocket) { link->fromnode = deliveringcolnode; link->fromsock = deliveringcolsocket; + numberOfReconnections++; } break; } } } + + /* when no connections have been made, and if only one delivering input socket type and one output socket we will connect those two */ + if (numberOfConnectedOutputSockets == 1 && numberOfReconnections == 0 && numberOfConnectedInputSockets == 1) { + if (deliveringcolsocket) { + first->fromnode = deliveringcolnode; + first->fromsock = deliveringcolsocket; + } else if (deliveringvecsocket) { + first->fromnode = deliveringvecnode; + first->fromsock = deliveringvecsocket; + } else if (deliveringvalsocket) { + first->fromnode = deliveringvalnode; + first->fromsock = deliveringvalsocket; + } + } + if(node->id) node->id->us--; nodeFreeNode(tree, node); - } static int node_delete_reconnect_exec(bContext *C, wmOperator *UNUSED(op)) diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index 3e83da13e55..0d3f2e85414 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -83,8 +83,8 @@ void outliner_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "OUTLINER_OT_item_rename", LEFTMOUSE, KM_DBL_CLICK, 0, 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_activate", LEFTMOUSE, KM_RELEASE, 0, 0)->ptr, "extend", 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_activate", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", 1); + RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_activate", LEFTMOUSE, KM_CLICK, 0, 0)->ptr, "extend", 0); + RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_activate", LEFTMOUSE, KM_CLICK, KM_SHIFT, 0)->ptr, "extend", 1); RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_openclose", RETKEY, KM_PRESS, 0, 0)->ptr, "all", 0); RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_openclose", RETKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "all", 1); diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 24b7085e2f4..0b07c824f3e 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -223,7 +223,7 @@ void outliner_free_tree(ListBase *lb) } /* Find ith item from the treestore */ -TreeElement *outliner_find_tree_element(ListBase *lb, int store_index) +static TreeElement *outliner_find_tree_element(ListBase *lb, int store_index) { TreeElement *te= lb->first, *tes; while(te) { diff --git a/source/blender/editors/space_sequencer/SConscript b/source/blender/editors/space_sequencer/SConscript index 65bbf900556..3430c10b766 100644 --- a/source/blender/editors/space_sequencer/SConscript +++ b/source/blender/editors/space_sequencer/SConscript @@ -8,4 +8,7 @@ incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../makesrna ../../blenloader' incs += ' #/intern/audaspace/intern' +if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): + incs += ' ' + env['BF_PTHREADS_INC'] + env.BlenderLib ( 'bf_editors_space_sequencer', sources, Split(incs), [], libtype=['core'], priority=[100] ) diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index a7b2250e37d..299fe9df460 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -733,7 +733,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline } } -static Sequence *special_seq_update= 0; +static Sequence *special_seq_update= NULL; static void UNUSED_FUNCTION(set_special_seq_update)(int val) { @@ -743,14 +743,14 @@ static void UNUSED_FUNCTION(set_special_seq_update)(int val) if(val) { // XXX special_seq_update= find_nearest_seq(&x); } - else special_seq_update= 0; + else special_seq_update= NULL; } void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs) { struct Main *bmain= CTX_data_main(C); - struct ImBuf *ibuf = 0; - struct ImBuf *scope = 0; + struct ImBuf *ibuf= NULL; + struct ImBuf *scope= NULL; struct View2D *v2d = &ar->v2d; int rectx, recty; float viewrectx, viewrecty; diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 876280d5b0f..df347506e74 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -47,6 +47,7 @@ #include "BLI_math.h" #include "BLI_storage_types.h" #include "BLI_utildefines.h" +#include "BLI_threads.h" #include "DNA_scene_types.h" #include "DNA_userdef_types.h" @@ -125,6 +126,111 @@ typedef struct TransSeq { int len; } TransSeq; +/* ********************************************************************** */ + +/* ***************** proxy job manager ********************** */ + +typedef struct ProxyBuildJob { + Scene *scene; + struct Main * main; + ListBase queue; + ThreadMutex queue_lock; +} ProxyJob; + +static void proxy_freejob(void *pjv) +{ + ProxyJob *pj= pjv; + Sequence * seq; + + for (seq = pj->queue.first; seq; seq = seq->next) { + BLI_remlink(&pj->queue, seq); + seq_free_sequence_recurse(pj->scene, seq); + } + + BLI_mutex_end(&pj->queue_lock); + + MEM_freeN(pj); +} + +/* only this runs inside thread */ +static void proxy_startjob(void *pjv, short *stop, short *do_update, float *progress) +{ + ProxyJob *pj = pjv; + + while (!*stop) { + Sequence * seq; + + BLI_mutex_lock(&pj->queue_lock); + + if (!pj->queue.first) { + BLI_mutex_unlock(&pj->queue_lock); + break; + } + + seq = pj->queue.first; + + BLI_remlink(&pj->queue, seq); + BLI_mutex_unlock(&pj->queue_lock); + + seq_proxy_rebuild(pj->main, pj->scene, seq, + stop, do_update, progress); + seq_free_sequence_recurse(pj->scene, seq); + } + + if (*stop) { + fprintf(stderr, + "Canceling proxy rebuild on users request...\n"); + } +} + +static void proxy_endjob(void *UNUSED(customdata)) +{ + +} + +void seq_proxy_build_job(const bContext *C, Sequence * seq) +{ + wmJob * steve; + ProxyJob *pj; + Scene *scene= CTX_data_scene(C); + ScrArea * sa= CTX_wm_area(C); + + seq = seq_dupli_recursive(scene, scene, seq, 0); + + steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), + sa, "Building Proxies", WM_JOB_PROGRESS); + + pj = WM_jobs_get_customdata(steve); + + if (!pj) { + pj = MEM_callocN(sizeof(ProxyJob), "proxy rebuild job"); + + pj->scene= scene; + pj->main = CTX_data_main(C); + + BLI_mutex_init(&pj->queue_lock); + + WM_jobs_customdata(steve, pj, proxy_freejob); + WM_jobs_timer(steve, 0.1, NC_SCENE|ND_SEQUENCER, + NC_SCENE|ND_SEQUENCER); + WM_jobs_callbacks(steve, proxy_startjob, NULL, NULL, + proxy_endjob); + } + + BLI_mutex_lock(&pj->queue_lock); + BLI_addtail(&pj->queue, seq); + BLI_mutex_unlock(&pj->queue_lock); + + if (!WM_jobs_is_running(steve)) { + G.afbreek = 0; + WM_jobs_start(CTX_wm_manager(C), steve); + } + + ED_area_tag_redraw(CTX_wm_area(C)); +} + +/* ********************************************************************** */ + void seq_rectf(Sequence *seq, rctf *rectf) { if(seq->startstill) rectf->xmin= seq->start; @@ -2690,6 +2796,37 @@ void SEQUENCER_OT_view_ghost_border(wmOperatorType *ot) WM_operator_properties_gesture_border(ot, FALSE); } +/* rebuild_proxy operator */ +static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + Editing *ed = seq_give_editing(scene, FALSE); + Sequence * seq; + + SEQP_BEGIN(ed, seq) { + if ((seq->flag & SELECT)) { + seq_proxy_build_job(C, seq); + } + } + SEQ_END + + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_rebuild_proxy(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Rebuild Proxy and Timecode Indices"; + ot->idname= "SEQUENCER_OT_rebuild_proxy"; + ot->description="Rebuild all selected proxies and timecode indeces using the job system"; + + /* api callbacks */ + ot->exec= sequencer_rebuild_proxy_exec; + ot->poll= ED_operator_sequencer_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER; +} /* change ops */ diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 7ab76f9b6d7..89e9a22c9a1 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -118,6 +118,8 @@ void SEQUENCER_OT_change_path(struct wmOperatorType *ot); void SEQUENCER_OT_copy(struct wmOperatorType *ot); void SEQUENCER_OT_paste(struct wmOperatorType *ot); +void SEQUENCER_OT_rebuild_proxy(struct wmOperatorType *ot); + /* preview specific operators */ void SEQUENCER_OT_view_all_preview(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index df33ce73b9c..5c13b57cca8 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -87,6 +87,7 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_view_zoom_ratio); WM_operatortype_append(SEQUENCER_OT_view_ghost_border); + WM_operatortype_append(SEQUENCER_OT_rebuild_proxy); WM_operatortype_append(SEQUENCER_OT_change_effect_input); WM_operatortype_append(SEQUENCER_OT_change_effect_type); WM_operatortype_append(SEQUENCER_OT_change_path); diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 0ac23765167..86b28f5e89e 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -846,7 +846,7 @@ static int sequencer_borderselect_exec(bContext *C, wmOperator *op) for(seq= ed->seqbasep->first; seq; seq= seq->next) { seq_rectf(seq, &rq); - if(BLI_isect_rctf(&rq, &rectf, 0)) { + if(BLI_isect_rctf(&rq, &rectf, NULL)) { if(selecting) seq->flag |= SELECT; else seq->flag &= ~SEQ_ALLSEL; recurs_sel_seq(seq); diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 550f2c937fd..c7d4d78422e 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -274,7 +274,7 @@ static void text_keymap(struct wmKeyConfig *keyconf) RNA_string_set(kmi->ptr, "data_path", "space_data.font_size"); RNA_boolean_set(kmi->ptr, "reverse", 1); - WM_keymap_add_item(keymap, "TEXT_OT_new", NKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "TEXT_OT_new", NKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "TEXT_OT_open", OKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_reload", RKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "TEXT_OT_save", SKEY, KM_PRESS, KM_ALT, 0); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 13eb24ed1f2..617bbf62e92 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -192,11 +192,12 @@ static int new_exec(bContext *C, wmOperator *UNUSED(op)) void TEXT_OT_new(wmOperatorType *ot) { /* identifiers */ - ot->name= "New"; + ot->name= "Create Text Block"; ot->idname= "TEXT_OT_new"; ot->description= "Create a new text data block"; /* api callbacks */ + ot->invoke= WM_operator_confirm; ot->exec= new_exec; ot->poll= text_new_poll; diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index de35be13c43..ecf5df4af7c 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -315,11 +315,9 @@ static float cube[8][3] = { static void drawsolidcube_size(float xsize, float ysize, float zsize) { static GLuint displist=0; - float n[3]; + float n[3]= {0.0f}; glScalef(xsize, ysize, zsize); - - n[0]=0; n[1]=0; n[2]=0; if(displist==0) { displist= glGenLists(1); @@ -345,7 +343,6 @@ static void drawsolidcube_size(float xsize, float ysize, float zsize) n[2]= 1.0; glNormal3fv(n); glVertex3fv(cube[1]); glVertex3fv(cube[5]); glVertex3fv(cube[6]); glVertex3fv(cube[2]); - n[2]=0; n[2]= -1.0; glNormal3fv(n); glVertex3fv(cube[7]); glVertex3fv(cube[4]); glVertex3fv(cube[0]); glVertex3fv(cube[3]); diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 71c85483244..6e02ecbd5a8 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -607,7 +607,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o } else if(faceselect) { if(ob->mode & OB_MODE_WEIGHT_PAINT) - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me, 1, GPU_enable_material); + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me, 1, GPU_enable_material, NULL); else dm->drawMappedFacesTex(dm, me->mface ? draw_tface_mapped__set_draw : NULL, me); } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 2ab33669e4a..b4ccea71aa2 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2077,6 +2077,28 @@ static int draw_dm_faces_sel__setDrawOptions(void *userData, int index, int *UNU return 0; } +static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int next_index) +{ + struct { unsigned char *cols[3]; EditFace *efa_act; } * data = userData; + EditFace *efa = EM_get_face_for_index(index); + EditFace *next_efa = EM_get_face_for_index(next_index); + unsigned char *col, *next_col; + + if(efa == next_efa) + return 1; + + if(efa == data->efa_act || next_efa == data->efa_act) + return 0; + + col = data->cols[(efa->f&SELECT)?1:0]; + next_col = data->cols[(next_efa->f&SELECT)?1:0]; + + if(col[3]==0 || next_col[3]==0) + return 0; + + return col == next_col; +} + /* also draws the active face */ static void draw_dm_faces_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol, unsigned char *actCol, EditFace *efa_act) { @@ -2086,7 +2108,7 @@ static void draw_dm_faces_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned data.cols[2] = actCol; data.efa_act = efa_act; - dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, &data, 0, GPU_enable_material); + dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, &data, 0, GPU_enable_material, draw_dm_faces_sel__compareDrawOptions); } static int draw_dm_creases__setDrawOptions(void *UNUSED(userData), int index) @@ -2496,7 +2518,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object glEnable(GL_LIGHTING); glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); - finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, NULL, 0, GPU_enable_material); + finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, NULL, 0, GPU_enable_material, NULL); glFrontFace(GL_CCW); glDisable(GL_LIGHTING); @@ -2725,7 +2747,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D /* weight paint in solid mode, special case. focus on making the weights clear * rather than the shading, this is also forced in wire view */ GPU_enable_material(0, NULL); - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me->mface, 1, GPU_enable_material); + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me->mface, 1, GPU_enable_material, NULL); bglPolygonOffset(rv3d->dist, 1.0); glDepthMask(0); // disable write in zbuffer, selected edge wires show better @@ -2805,7 +2827,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me->mface, 1, GPU_enable_material); + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me->mface, 1, GPU_enable_material, NULL); glDisable(GL_COLOR_MATERIAL); glDisable(GL_LIGHTING); @@ -2813,10 +2835,10 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } else if(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_TEXTURE_PAINT)) { if(me->mcol) - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 1, GPU_enable_material); + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 1, GPU_enable_material, NULL); else { glColor3f(1.0f, 1.0f, 1.0f); - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 0, GPU_enable_material); + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 0, GPU_enable_material, NULL); } } } @@ -2891,7 +2913,18 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D Object *obedit= scene->obedit; Mesh *me= ob->data; EditMesh *em= me->edit_mesh; - int do_alpha_pass= 0, drawlinked= 0, retval= 0, glsl, check_alpha; + int do_alpha_pass= 0, drawlinked= 0, retval= 0, glsl, check_alpha, i; + + /* If we are drawing shadows and any of the materials don't cast a shadow, + * then don't draw the object */ + if (v3d->flag2 & V3D_RENDER_SHADOW) { + for(i=0; i<ob->totcol; ++i) { + Material *ma= give_current_material(ob, i); + if (ma && !(ma->mode & MA_SHADBUF)) { + return 1; + } + } + } if(obedit && ob!=obedit && ob->data==obedit->data) { if(ob_get_key(ob) || ob_get_key(obedit)); @@ -6165,8 +6198,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } /* draw code for smoke */ - if((md = modifiers_findByType(ob, eModifierType_Smoke))) - { + if((md = modifiers_findByType(ob, eModifierType_Smoke))) { SmokeModifierData *smd = (SmokeModifierData *)md; // draw collision objects @@ -6501,7 +6533,7 @@ static void bbs_mesh_solid_EM(Scene *scene, View3D *v3d, Object *ob, DerivedMesh cpack(0); if (facecol) { - dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, (void*)(intptr_t) 1, 0, GPU_enable_material); + dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, (void*)(intptr_t) 1, 0, GPU_enable_material, NULL); if(check_ob_drawface_dot(scene, v3d, ob->dt)) { glPointSize(UI_GetThemeValuef(TH_FACEDOT_SIZE)); @@ -6512,7 +6544,7 @@ static void bbs_mesh_solid_EM(Scene *scene, View3D *v3d, Object *ob, DerivedMesh } } else { - dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, (void*) 0, 0, GPU_enable_material); + dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, (void*) 0, 0, GPU_enable_material, NULL); } } @@ -6541,8 +6573,8 @@ static void bbs_mesh_solid(Scene *scene, Object *ob) glColor3ub(0, 0, 0); - if((me->editflag & ME_EDIT_PAINT_MASK)) dm->drawMappedFaces(dm, bbs_mesh_solid_hide__setDrawOpts, me, 0, GPU_enable_material); - else dm->drawMappedFaces(dm, bbs_mesh_solid__setDrawOpts, me, 0, GPU_enable_material); + if((me->editflag & ME_EDIT_PAINT_MASK)) dm->drawMappedFaces(dm, bbs_mesh_solid_hide__setDrawOpts, me, 0, GPU_enable_material, NULL); + else dm->drawMappedFaces(dm, bbs_mesh_solid__setDrawOpts, me, 0, GPU_enable_material, NULL); dm->release(dm); } @@ -6558,7 +6590,6 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec switch( ob->type) { case OB_MESH: - { if(ob->mode & OB_MODE_EDIT) { Mesh *me= ob->data; EditMesh *em= me->edit_mesh; @@ -6592,8 +6623,9 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec EM_free_index_arrays(); } - else bbs_mesh_solid(scene, ob); - } + else { + bbs_mesh_solid(scene, ob); + } break; case OB_CURVE: case OB_SURF: @@ -6649,7 +6681,7 @@ static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *r GPU_end_object_materials(); } else if(edm) - edm->drawMappedFaces(edm, NULL, NULL, 0, GPU_enable_material); + edm->drawMappedFaces(edm, NULL, NULL, 0, GPU_enable_material, NULL); glDisable(GL_LIGHTING); } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index f8837594ddb..98768e369cb 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1141,12 +1141,10 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) glRectf(x1i, y1i, x2i, y2i); #ifdef VIEW3D_CAMERA_BORDER_HACK - { - if(view3d_camera_border_hack_test == TRUE) { - glColor4fv(view3d_camera_border_hack_col); - glRectf(x1i+1, y1i+1, x2i-1, y2i-1); - view3d_camera_border_hack_test= FALSE; - } + if(view3d_camera_border_hack_test == TRUE) { + glColor4fv(view3d_camera_border_hack_col); + glRectf(x1i+1, y1i+1, x2i-1, y2i-1); + view3d_camera_border_hack_test= FALSE; } #endif @@ -2155,7 +2153,7 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d) v3d->drawtype = OB_SOLID; v3d->lay &= GPU_lamp_shadow_layer(shadow->lamp); v3d->flag2 &= ~V3D_SOLID_TEX; - v3d->flag2 |= V3D_RENDER_OVERRIDE; + v3d->flag2 |= V3D_RENDER_OVERRIDE | V3D_RENDER_SHADOW; GPU_lamp_shadow_buffer_bind(shadow->lamp, viewmat, &winsize, winmat); @@ -2274,6 +2272,7 @@ static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar, void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, int winy, float viewmat[][4], float winmat[][4]) { + RegionView3D *rv3d= ar->regiondata; Base *base; float backcol[3]; int bwinx, bwiny; @@ -2322,6 +2321,9 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, /* setup view matrices */ view3d_main_area_setup_view(scene, v3d, ar, viewmat, winmat); + if(rv3d->rflag & RV3D_CLIPPING) + view3d_draw_clipping(rv3d); + /* set zbuffer */ if(v3d->drawtype > OB_WIRE) { v3d->zbuf= TRUE; @@ -2330,6 +2332,9 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, else v3d->zbuf= FALSE; + if(rv3d->rflag & RV3D_CLIPPING) + view3d_set_clipping(rv3d); + /* draw set first */ if(scene->set) { Scene *sce_iter; @@ -2365,6 +2370,9 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, if(v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used! if(v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1); + if(rv3d->rflag & RV3D_CLIPPING) + view3d_clr_clipping(); + /* cleanup */ if(v3d->zbuf) { v3d->zbuf= FALSE; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 979a602b4f5..e9ed5dac3de 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -97,7 +97,8 @@ void ED_view3d_camera_lock_init(View3D *v3d, RegionView3D *rv3d) } } -void ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) +/* return TRUE if the camera is moved */ +int ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) { if(ED_view3d_camera_lock_check(v3d, rv3d)) { Object *root_parent; @@ -132,6 +133,11 @@ void ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); WM_main_add_notifier(NC_OBJECT|ND_TRANSFORM, v3d->camera); } + + return TRUE; + } + else { + return FALSE; } } @@ -372,12 +378,12 @@ static void calctrackballvec(rcti *rect, int mx, int my, float *vec) y/= (float)((rect->ymax - rect->ymin)/2); d = sqrt(x*x + y*y); - if (d < radius * (float)M_SQRT1_2) /* Inside sphere */ - z = sqrt(radius*radius - d*d); - else - { /* On hyperbola */ - t = radius / (float)M_SQRT2; - z = t*t / d; + if (d < radius * (float)M_SQRT1_2) { /* Inside sphere */ + z= sqrt(radius*radius - d*d); + } + else { /* On hyperbola */ + t= radius / (float)M_SQRT2; + z= t*t / d; } vec[0]= x; @@ -944,17 +950,22 @@ void ndof_to_quat(struct wmNDOFMotionData* ndof, float q[4]) axis_angle_to_quat(q, axis, angle); } +/* -- "orbit" navigation (trackball/turntable) + * -- zooming + * -- panning in rotationally-locked views + */ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) -// -- "orbit" navigation (trackball/turntable) -// -- zooming -// -- panning in rotationally-locked views { - if (event->type != NDOF_MOTION) + if (event->type != NDOF_MOTION) { return OPERATOR_CANCELLED; + } else { + View3D *v3d= CTX_wm_view3d(C); RegionView3D* rv3d = CTX_wm_region_view3d(C); wmNDOFMotionData* ndof = (wmNDOFMotionData*) event->customdata; + ED_view3d_camera_lock_init(v3d, rv3d); + rv3d->rot_angle = 0.f; // off by default, until changed later this function if (ndof->progress != P_FINISHING) { @@ -1064,6 +1075,8 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event } } + ED_view3d_camera_lock_sync(v3d, rv3d); + ED_region_tag_redraw(CTX_wm_region(C)); return OPERATOR_FINISHED; @@ -1085,16 +1098,20 @@ void VIEW3D_OT_ndof_orbit(struct wmOperatorType *ot) ot->flag = 0; } +/* -- "pan" navigation + * -- zoom or dolly? + */ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) -// -- "pan" navigation -// -- zoom or dolly? { - if (event->type != NDOF_MOTION) + if (event->type != NDOF_MOTION) { return OPERATOR_CANCELLED; + } else { + View3D *v3d= CTX_wm_view3d(C); RegionView3D* rv3d = CTX_wm_region_view3d(C); wmNDOFMotionData* ndof = (wmNDOFMotionData*) event->customdata; + ED_view3d_camera_lock_init(v3d, rv3d); rv3d->rot_angle = 0.f; // we're panning here! so erase any leftover rotation from other operators @@ -1141,6 +1158,8 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) sub_v3_v3(rv3d->ofs, pan_vec); } + ED_view3d_camera_lock_sync(v3d, rv3d); + ED_region_tag_redraw(CTX_wm_region(C)); return OPERATOR_FINISHED; @@ -1620,8 +1639,7 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event) vod= op->customdata; /* if one or the other zoom position aren't set, set from event */ - if (!RNA_property_is_set(op->ptr, "mx") || !RNA_property_is_set(op->ptr, "my")) - { + if (!RNA_property_is_set(op->ptr, "mx") || !RNA_property_is_set(op->ptr, "my")) { RNA_int_set(op->ptr, "mx", event->x); RNA_int_set(op->ptr, "my", event->y); } @@ -1834,8 +1852,7 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, wmEvent *event) vod= op->customdata; /* if one or the other zoom position aren't set, set from event */ - if (!RNA_property_is_set(op->ptr, "mx") || !RNA_property_is_set(op->ptr, "my")) - { + if (!RNA_property_is_set(op->ptr, "mx") || !RNA_property_is_set(op->ptr, "my")) { RNA_int_set(op->ptr, "mx", event->x); RNA_int_set(op->ptr, "my", event->y); } diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index e47cb1db753..8416b37fd5e 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -263,9 +263,13 @@ void view3d_keymap(wmKeyConfig *keyconf) /* selection*/ WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", TRUE); - RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "center", TRUE); - RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "enumerate", TRUE); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + kmi= WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL, 0); + RNA_boolean_set(kmi->ptr, "center", TRUE); + RNA_boolean_set(kmi->ptr, "object", TRUE); /* use Ctrl+Select for 2 purposes */ + kmi= WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "enumerate", TRUE); /* selection key-combinations */ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 86112a42d99..65914ead899 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1231,8 +1231,8 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce if(BASACT && BASACT->next) startbase= BASACT->next; /* This block uses the control key to make the object selected by its center point rather than its contents */ - /* XXX later on, in editmode do not activate */ - if(vc.obedit==NULL && obcenter) { + /* in editmode do not activate */ + if(obcenter) { /* note; shift+alt goes to group-flush-selecting */ if(enumerate) { @@ -1765,9 +1765,15 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) case OB_CURVE: case OB_SURF: ret= do_nurbs_box_select(&vc, &rect, select, extend); + if(ret & OPERATOR_FINISHED) { + WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data); + } break; case OB_MBALL: ret= do_meta_box_select(&vc, &rect, select, extend); + if(ret & OPERATOR_FINISHED) { + WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data); + } break; case OB_ARMATURE: ret= do_armature_box_select(&vc, &rect, select, extend); @@ -1838,11 +1844,22 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event) short extend= RNA_boolean_get(op->ptr, "extend"); short center= RNA_boolean_get(op->ptr, "center"); short enumerate= RNA_boolean_get(op->ptr, "enumerate"); + short object= RNA_boolean_get(op->ptr, "object"); int retval = 0; view3d_operator_needs_opengl(C); - if(obedit && center==FALSE) { + if(object) { + obedit= NULL; + obact= NULL; + + /* ack, this is incorrect but to do this correctly we would need an + * alternative editmode/objectmode keymap, this copies the functionality + * from 2.4x where Ctrl+Select in editmode does object select only */ + center= FALSE; + } + + if(obedit && object==FALSE) { if(obedit->type==OB_MESH) retval = mouse_mesh(C, event->mval, extend); else if(obedit->type==OB_ARMATURE) @@ -1891,6 +1908,7 @@ void VIEW3D_OT_select(wmOperatorType *ot) RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everything first."); RNA_def_boolean(ot->srna, "center", 0, "Center", "Use the object center when selecting, in editmode used to extend object selection."); RNA_def_boolean(ot->srna, "enumerate", 0, "Enumerate", "List objects under the mouse (object mode only)."); + RNA_def_boolean(ot->srna, "object", 0, "Object", "Use object selection (editmode only)."); } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index ed0b2645c99..c48459108eb 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -840,8 +840,7 @@ void project_int_noclip(ARegion *ar, const float vec[3], int adr[2]) adr[0] = (int)floor(fx); adr[1] = (int)floor(fy); } - else - { + else { adr[0] = ar->winx / 2; adr[1] = ar->winy / 2; } @@ -904,8 +903,7 @@ void project_float_noclip(ARegion *ar, const float vec[3], float adr[2]) adr[0] = (float)(ar->winx/2.0f)+(ar->winx/2.0f)*vec4[0]/vec4[3]; adr[1] = (float)(ar->winy/2.0f)+(ar->winy/2.0f)*vec4[1]/vec4[3]; } - else - { + else { adr[0] = ar->winx / 2.0f; adr[1] = ar->winy / 2.0f; } diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 70659994c55..05159414975 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -833,7 +833,7 @@ static int select_edgeloop(Scene *scene, Image *ima, EditMesh *em, NearestHit *h if(extend) { tf= CustomData_em_get(&em->fdata, hit->efa->data, CD_MTFACE); - if(uvedit_uv_selected(scene, hit->efa, tf, hit->edge) && uvedit_uv_selected(scene, hit->efa, tf, hit->edge)) + if(uvedit_uv_selected(scene, hit->efa, tf, hit->edge)) select= 0; else select= 1; |