From ce9e4472eb2941881836926ba46ab11203bc61c0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 23 Aug 2011 09:05:12 +0000 Subject: Make Ctrl+RMB in editmode behave like 2.4x, was re-using center option which worked but used center select too. instead add 'object' option to VIEW3D_OT_select. --- source/blender/editors/space_view3d/view3d_ops.c | 10 +++++++--- source/blender/editors/space_view3d/view3d_select.c | 18 +++++++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) (limited to 'source/blender/editors') 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..f241e640906 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) { @@ -1838,11 +1838,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 +1902,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)."); } -- cgit v1.2.3 From f6a2b8d724646ac357a0eafc2d29b345fdc1ba5f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 23 Aug 2011 15:08:54 +0000 Subject: BLI_strescape for a basic, python like string escaping, currently only use for drag and drop ID's into the console but should eventually be used for the animsys too. --- source/blender/editors/space_console/space_console.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/blender/editors') 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); -- cgit v1.2.3 From 9a9513a9f09f5524235e202a095b04863a07a52b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 23 Aug 2011 19:58:15 +0000 Subject: fix for 3 bugs in bone renaming - renaming a bone could crash if the area had to spaces in it (reported by Sebastian Koenig). - renaming bones wouldn't update inactive 3d views locked bone names. - selecting locked bones in the UI didnt work in editmode. --- source/blender/editors/armature/editarmature.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 628cdbf21e9..bd8f431535e 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -5402,12 +5402,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); + } } } } -- cgit v1.2.3 From f9bffb3ca0ca88a7e774b0ee0da1d384707f0495 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 24 Aug 2011 00:44:58 +0000 Subject: fix [#28340] Can't set image depth, quality from image save --- source/blender/editors/space_image/image_ops.c | 242 ++++++++++++++----------- 1 file changed, 137 insertions(+), 105 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 6e0d1909963..d483dd45f7f 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= 32; + } + + /* 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==32) { ibuf->depth= 32; } - else if(scene->r.planes==24) { + else if(simopts->planes==24) { 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; } -- cgit v1.2.3 From 82e622f1585ff615cc9607f1f9492b961842ce1b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 24 Aug 2011 14:22:41 +0000 Subject: fix [#28356] Import export STL files, problem in script in version r39307 & correct some bad comments. --- source/blender/editors/space_file/file_ops.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 4dd97c63d40..a34335a031d 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; ifiles, 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; ifiles, 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); } } -- cgit v1.2.3 From 7fc26e0123e700113f340068a964c1a12133b7e1 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Wed, 24 Aug 2011 20:28:54 +0000 Subject: Committing patch #25675 "Make "Cast Buffer Shadows" option work in viewport and BGE" by me. Description from the tracker: "It's really handy to be able to prevent an object/material from casting a shadow. So, I made use of the Cast Buffer Shadows option in the material settings, and made it work in the viewport and the BGE." --- source/blender/editors/space_view3d/drawobject.c | 14 +++++++++++++- source/blender/editors/space_view3d/view3d_draw.c | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index ddc10d78cac..3133ad131bb 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2843,8 +2843,20 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D Object *ob= base->object; Object *obedit= scene->obedit; Mesh *me= ob->data; + Material *ma=NULL; 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; itotcol; ++i) + { + 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)); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index f8837594ddb..9249d4d2bf0 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2155,7 +2155,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); -- cgit v1.2.3 From 5f66f37e225eb87532374af6c495a409da4ece66 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Wed, 24 Aug 2011 20:48:37 +0000 Subject: Patch for bug #28289 updated the logic behind node delete with reconnect. When on input and output socket is connected, these two will be reconnected see bug report for example. http://projects.blender.org/tracker/?func=detail&aid=28289&group_id=9&atid=498 --- source/blender/editors/space_node/node_edit.c | 89 +++++++++++++++++++-------- 1 file changed, 63 insertions(+), 26 deletions(-) (limited to 'source/blender/editors') 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)) -- cgit v1.2.3 From b7eac1edcf472df7c705e6c3463e8404f72422df Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 25 Aug 2011 15:49:52 +0000 Subject: picky style edits with screen/view/drawing, also remove own bad example doc. --- source/blender/editors/interface/interface_draw.c | 40 +++++++--------------- .../blender/editors/interface/interface_handlers.c | 3 +- source/blender/editors/interface/interface_icons.c | 3 +- source/blender/editors/screen/screen_edit.c | 3 +- source/blender/editors/screen/screen_ops.c | 15 ++++---- source/blender/editors/space_view3d/drawobject.c | 24 ++++++------- source/blender/editors/space_view3d/view3d_draw.c | 10 +++--- source/blender/editors/space_view3d/view3d_edit.c | 18 +++++----- source/blender/editors/space_view3d/view3d_view.c | 6 ++-- 9 files changed, 48 insertions(+), 74 deletions(-) (limited to 'source/blender/editors') 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 3bd29f8de3e..d7eba8c0ac7 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/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 1410331700f..0ac30853eae 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; @@ -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/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 3133ad131bb..638d197ccf7 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2843,18 +2843,17 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D Object *ob= base->object; Object *obedit= scene->obedit; Mesh *me= ob->data; - Material *ma=NULL; EditMesh *em= me->edit_mesh; 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; itotcol; ++i) - { - ma = give_current_material(ob, i); - if (ma && !(ma->mode & MA_SHADBUF)) + /* 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; itotcol; ++i) { + Material *ma= give_current_material(ob, i); + if (ma && !(ma->mode & MA_SHADBUF)) { return 1; + } } } @@ -6125,8 +6124,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 @@ -6518,7 +6516,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; @@ -6552,8 +6549,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: diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 9249d4d2bf0..80da75bc603 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 diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 979a602b4f5..0e8dd38c02c 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -372,12 +372,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; @@ -1620,8 +1620,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 +1833,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_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; } -- cgit v1.2.3 From 88ba2504c7269c408f400de6637545333641ee1f Mon Sep 17 00:00:00 2001 From: Alexander Kuznetsov Date: Thu, 25 Aug 2011 16:41:08 +0000 Subject: Fix for [#28304] Show A: and B: drives in Windows file browser. --- source/blender/editors/space_file/fsmenu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors') 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]=':'; -- cgit v1.2.3 From 566da261737731a2e58e8e3ab489c2823068ef2b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 26 Aug 2011 01:32:07 +0000 Subject: file-selector: when converting operator arguments to the file selector, wasnt making paths absolute (abs paths are made relative when converting the other way). --- source/blender/editors/space_file/file_ops.c | 32 ++++++++++++++------------ source/blender/editors/space_image/image_ops.c | 8 +++---- 2 files changed, 21 insertions(+), 19 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index a34335a031d..1b0893e50e0 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -657,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_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index d483dd45f7f..d58b78ff6a7 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -983,7 +983,7 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, /* unlikely but just incase */ if (ELEM3(simopts->planes, R_PLANESBW, R_PLANES24, R_PLANES32) == 0) { - simopts->planes= 32; + simopts->planes= R_PLANES32; } /* some formats dont use quality so fallback to scenes quality */ @@ -1000,7 +1000,6 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, } BLI_path_abs(simopts->filepath, G.main->name); } - /* cleanup */ BKE_image_release_renderresult(scene, ima); } @@ -1026,6 +1025,7 @@ static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op) 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); } @@ -1050,10 +1050,10 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI if(ima->type == IMA_TYPE_R_RESULT) { /* enforce user setting for RGB or RGBA, but skip BW */ - if(simopts->planes==32) { + if(simopts->planes==R_PLANES32) { ibuf->depth= 32; } - else if(simopts->planes==24) { + else if(simopts->planes==R_PLANES24) { ibuf->depth= 24; } } -- cgit v1.2.3 From e5ddaefecc1c6df3df15f22d6ce5609bb5c6cc3d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 26 Aug 2011 06:22:12 +0000 Subject: when applying armature object transform now transform the bone roll too. This means you can import a BVH, rotate 90d and apply the rotation, the animation will still work as expected - thanks to Benjy's script for showing how obvious it is that this works :) --- source/blender/editors/armature/editarmature.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index bd8f431535e..451154ce842 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -494,15 +494,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, delta, &ebone->roll); + ebone->rad_head *= scale; ebone->rad_tail *= scale; ebone->dist *= scale; -- cgit v1.2.3 From 1273a1133e13d5703d8ece8ac88ec2fa00cb2cf5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 26 Aug 2011 11:35:33 +0000 Subject: Fix #28370: border select for curve and metaball did not update number of selected vertices in info header. Patch by Julien Duroure, thanks! --- source/blender/editors/space_view3d/view3d_select.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index f241e640906..65914ead899 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -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); -- cgit v1.2.3 From 1439ddccae91898812b3a040b35dedcb639894e5 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 26 Aug 2011 16:38:23 +0000 Subject: Fix #28301: Sculpting a object with rotational have desface Patch from Juha Maki-Kanto - initgrabz was called with local space coord. - Brush radiu was multiplying by 2.0 for grab and snake brushes. Not sure why this was needed. Made some tests and didn't notice any regressions without this multiplication. --- source/blender/editors/sculpt_paint/sculpt.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'source/blender/editors') 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)) { -- cgit v1.2.3 From 8a619a3eee0775d338e41763b219d661a6845dea Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 26 Aug 2011 17:55:03 +0000 Subject: fix for crash when running a python script in a non utf8 blend path, inspecting the exception for the path assumed utf8. --- source/blender/editors/armature/editarmature.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 451154ce842..08f313bfadd 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -518,7 +518,7 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4]) mul_m4_v3(mat, ebone->tail); /* apply the transfiormed roll back */ - mat3_to_vec_roll(tmat, delta, &ebone->roll); + mat3_to_vec_roll(tmat, NULL, &ebone->roll); ebone->rad_head *= scale; ebone->rad_tail *= scale; -- cgit v1.2.3 From 69260601851bfcf1193b95950e37abf1d662b0a4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 27 Aug 2011 03:20:32 +0000 Subject: - fix for BL_Shader::SetUniform() missing out the last part of the matrix. - particle.c wasn't setting all components of the vector when reading cache and setting dummy velocity values. - some functions incorrectly took a float[3] argument when the 4th value was set. - remove a few redundant lines of code. --- source/blender/editors/physics/physics_pointcache.c | 1 - source/blender/editors/sculpt_paint/paint_image.c | 4 ++-- source/blender/editors/space_view3d/drawarmature.c | 5 +---- source/blender/editors/uvedit/uvedit_ops.c | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) (limited to 'source/blender/editors') 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/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/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index ad621257602..103a03eece2 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -316,11 +316,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); @@ -346,7 +344,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/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; -- cgit v1.2.3 From c96f28a718b0c94b52781cc91d384d2aeedf8c02 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 27 Aug 2011 03:25:02 +0000 Subject: - use %u rather tham %d for unsigned ints in string formatting funcs. - replace (strlen(str) == 0) with str[0]=='\0' --- source/blender/editors/animation/anim_markers.c | 2 +- source/blender/editors/animation/fmodifier_ui.c | 2 +- source/blender/editors/object/object_modifier.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index b3338396598..f561bdc6183 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -339,7 +339,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 954928fc486..718188d5800 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -162,7 +162,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/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); -- cgit v1.2.3 From a347f0267b70c35e33d25c05df4a89fa7a95dd04 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 27 Aug 2011 11:41:48 +0000 Subject: Fix [#28341] writing }(alt+n) in text editor creates a new file Change hotkey for new textblock to Ctrl-N. --- source/blender/editors/space_text/space_text.c | 2 +- source/blender/editors/space_text/text_ops.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') 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; -- cgit v1.2.3 From 01230b137438881d2bdd9f651143880c84b85bf1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 27 Aug 2011 11:52:59 +0000 Subject: fix [#28373] "Lock camera to view" doew not work with 3D-mouse --- source/blender/editors/include/ED_view3d.h | 4 +-- source/blender/editors/space_view3d/view3d_edit.c | 35 +++++++++++++++++------ 2 files changed, 29 insertions(+), 10 deletions(-) (limited to 'source/blender/editors') 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/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 0e8dd38c02c..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; } } @@ -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; -- cgit v1.2.3 From fa2ba5fbf5848e4d61b697c624af9b9e9456eb20 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 28 Aug 2011 05:06:30 +0000 Subject: - use static vars and functions where possible. - use NULL rather than 0 when used as pointers. --- source/blender/editors/interface/interface_layout.c | 2 +- source/blender/editors/physics/particle_edit.c | 2 +- source/blender/editors/render/render_preview.c | 1 + source/blender/editors/screen/screen_ops.c | 2 +- source/blender/editors/space_outliner/outliner_tree.c | 2 +- source/blender/editors/space_sequencer/sequencer_draw.c | 8 ++++---- source/blender/editors/space_sequencer/sequencer_select.c | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) (limited to 'source/blender/editors') 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/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/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/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 0ac30853eae..ede17790318 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1702,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; diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 3560bfb9896..74e9e775087 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -231,7 +231,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/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index dc84289a8de..9a904b1a970 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -700,7 +700,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) { @@ -710,14 +710,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_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); -- cgit v1.2.3 From c07bd1439a3f026b8603c52662c3e7ccc364321a Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 28 Aug 2011 14:46:03 +0000 Subject: == Sequencer == This patch adds: * support for proxy building again (missing feature from Blender 2.49) additionally to the way, Blender 2.49 worked, you can select several strips at once and make Blender build proxies in the background (using the job system) Also a new thing: movie proxies are now build into AVI files, and the proxy system is moved into ImBuf-library, so that other parts of blender can also benefit from it. * Timecode support: to fix seeking issues with files, that have a) varying frame rates b) very large GOP lengths c) are broken inbetween d) use different time code tracks the proxy builder can now also build timecode indices, which are used (optionally) for seeking. For the first time, it is possible, to do frame exact seeking on all file types. * Support for different video-streams in one video file (can be selected in sequencer, other parts of blender can also use it, but UI has to be added accordingly) * IMPORTANT: this patch *requires* ffmpeg 0.7 or newer, since older versions don't support the pkt_pts field, that is essential for building timecode indices. Windows and Mac libs are already updated, Linux-users have to build their own ffmpeg verions until distros keep up. --- .../editors/interface/interface_templates.c | 11 +- source/blender/editors/space_image/image_buttons.c | 4 +- source/blender/editors/space_sequencer/SConscript | 3 + .../editors/space_sequencer/sequencer_edit.c | 137 +++++++++++++++++++++ .../editors/space_sequencer/sequencer_intern.h | 2 + .../editors/space_sequencer/sequencer_ops.c | 1 + 6 files changed, 154 insertions(+), 4 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 2faac24fd78..67123476f06 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2369,6 +2369,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) { @@ -2385,6 +2386,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; } } @@ -2406,8 +2410,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/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_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_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index e876da41bd9..18ff33fd8a9 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); -- cgit v1.2.3 From 28feca36d7e0a5f15d9c03f3781ba34cca8c4670 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 28 Aug 2011 18:54:02 +0000 Subject: Missed notifier was found when looking at #28393 --- source/blender/editors/space_buttons/space_buttons.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/editors') 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); -- cgit v1.2.3 From 3dc817840b21a06f161b8c672e61e0a0000adc8f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 28 Aug 2011 21:13:03 +0000 Subject: fix [#28401] OpenGL render option disables border clipping --- source/blender/editors/space_view3d/view3d_draw.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 80da75bc603..98768e369cb 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2272,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; @@ -2320,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; @@ -2328,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; @@ -2363,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; -- cgit v1.2.3 From 0e01fa4863a301f9776b8a6b5459493fc8830008 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 28 Aug 2011 23:24:34 +0000 Subject: patch [#28355] Better Environment Map scripting from Tom Edwards (artfunkel), with minor edits. This patch makes the following improvements to environment map scripting: * Adds a "is_valid" RNA property to envmaps. True if the map is ready for use, False if it needs rendering. * Adds a "clear" RNA function to envmaps. Deletes any envmap image data. * Adds a "save" RNA function to envmaps. Writes the envmap to disc with a configurable layout. (Defaults to the current hard-coded layout.) * Updates bpy.ops.texture.envmap_save with configurable layout support as above. These changes, particularly configurable layouts, make exporting envmaps to other software much easier. --- source/blender/editors/render/render_shading.c | 69 +++++++------------------- 1 file changed, 17 insertions(+), 52 deletions(-) (limited to 'source/blender/editors') 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)) -- cgit v1.2.3 From 88a538048bf7671db6a51fa2791ed1c87fa88611 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 29 Aug 2011 16:07:44 +0000 Subject: Fix #28347: VBO's highlights wrong faces when Mirror modifier is in use Added callback to drawMappedFaces which checks if two faces have got equal draw options. After discussion with Brecht we found it's nicest solution for now: - Disabling VBOs in edit mode for this case wouldn't be nicer for this case - some additional flag stored in DM should be added in this case. - Adding new callback in DM isn't nicer that this solution. - Handling face selection in drawobject would lead to duplicated code which is also not nice. Hopefully, this callback could handle all cases in the future. Also, Brecht mentioned current VBO implementation isn't perfect, so maybe when we'll redesign this area dealing with edit mode wouldn't be so tricky. --- source/blender/editors/space_view3d/drawmesh.c | 2 +- source/blender/editors/space_view3d/drawobject.c | 44 ++++++++++++++++++------ 2 files changed, 34 insertions(+), 12 deletions(-) (limited to 'source/blender/editors') 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 638d197ccf7..8ca352ffe42 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2030,6 +2030,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) { @@ -2039,7 +2061,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) @@ -2449,7 +2471,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); @@ -2678,7 +2700,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 @@ -2758,7 +2780,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); @@ -2766,10 +2788,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); } } } @@ -6459,7 +6481,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)); @@ -6470,7 +6492,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); } } @@ -6499,8 +6521,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); } @@ -6607,7 +6629,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); } -- cgit v1.2.3 From 099760cf1f7969d1cd16c6b5bd1a77d86bc62547 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 29 Aug 2011 17:46:07 +0000 Subject: Fix #28295 Outliner, mouse button on menu's pass through. It was introduced in rev33603 with not good patch -- release event was catching by outliner after clicking on menu item. Use KM_CLICK instead of KM_RELEASE to deal with icon drag/drop. This not changes drag/drop behavior, but prevents unneeded event be handled. Also make consistent behavior of activating and extending selection. --- source/blender/editors/space_outliner/outliner_ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index f3e2c352172..2917aa5ffda 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -90,8 +90,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); -- cgit v1.2.3