diff options
author | Jacques Lucke <jacques@blender.org> | 2021-08-04 13:34:52 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-08-04 13:34:52 +0300 |
commit | 3064492272f87f2c3be674306dab6adee66f2d34 (patch) | |
tree | d6aef87c51b220b3ce44c9373b33ee0bc3f393b9 /source/blender/editors | |
parent | df115dec055535ba3b48929054ccc9e1669b9ce0 (diff) | |
parent | ac6b263906c92d6adaafd014db28e0863cfd13e9 (diff) |
Merge branch 'master' into temp-geometry-nodes-expandable-geometry-socket-prototype
Diffstat (limited to 'source/blender/editors')
26 files changed, 548 insertions, 127 deletions
diff --git a/source/blender/editors/animation/time_scrub_ui.c b/source/blender/editors/animation/time_scrub_ui.c index 6af033f3cf2..8aeb6a57124 100644 --- a/source/blender/editors/animation/time_scrub_ui.c +++ b/source/blender/editors/animation/time_scrub_ui.c @@ -244,6 +244,10 @@ void ED_time_scrub_channel_search_draw(const bContext *C, ARegion *region, bDope UI_block_align_end(block); UI_block_layout_resolve(block, NULL, NULL); + /* Make sure the events are consumed from the search and don't reach other UI blocks since this + * is drawn on top of animation-channels. */ + UI_block_flag_enable(block, UI_BLOCK_CLIP_EVENTS); + UI_block_bounds_set_normal(block, 0); UI_block_end(C, block); UI_block_draw(C, block); diff --git a/source/blender/editors/datafiles/CMakeLists.txt b/source/blender/editors/datafiles/CMakeLists.txt index beb22d43930..4af6e1bdcb8 100644 --- a/source/blender/editors/datafiles/CMakeLists.txt +++ b/source/blender/editors/datafiles/CMakeLists.txt @@ -583,6 +583,7 @@ set(ICON_NAMES uv_facesel uv_islandsel uv_sync_select + fixed_size transform_origins gizmo orientation_cursor diff --git a/source/blender/editors/include/ED_keyframes_keylist.h b/source/blender/editors/include/ED_keyframes_keylist.h index 92b57b89cf8..e7d1b5d4363 100644 --- a/source/blender/editors/include/ED_keyframes_keylist.h +++ b/source/blender/editors/include/ED_keyframes_keylist.h @@ -153,44 +153,44 @@ bool ED_keylist_frame_range(const struct AnimKeylist *keylist, struct Range2f *r /* F-Curve */ void fcurve_to_keylist(struct AnimData *adt, struct FCurve *fcu, - struct AnimKeylist *keys, + struct AnimKeylist *keylist, int saction_flag); /* Action Group */ void agroup_to_keylist(struct AnimData *adt, struct bActionGroup *agrp, - struct AnimKeylist *keys, + struct AnimKeylist *keylist, int saction_flag); /* Action */ void action_to_keylist(struct AnimData *adt, struct bAction *act, - struct AnimKeylist *keys, + struct AnimKeylist *keylist, int saction_flag); /* Object */ void ob_to_keylist(struct bDopeSheet *ads, struct Object *ob, - struct AnimKeylist *keys, + struct AnimKeylist *keylist, int saction_flag); /* Cache File */ void cachefile_to_keylist(struct bDopeSheet *ads, struct CacheFile *cache_file, - struct AnimKeylist *keys, + struct AnimKeylist *keylist, int saction_flag); /* Scene */ void scene_to_keylist(struct bDopeSheet *ads, struct Scene *sce, - struct AnimKeylist *keys, + struct AnimKeylist *keylist, int saction_flag); /* DopeSheet Summary */ -void summary_to_keylist(struct bAnimContext *ac, struct AnimKeylist *keys, int saction_flag); +void summary_to_keylist(struct bAnimContext *ac, struct AnimKeylist *keylist, int saction_flag); /* Grease Pencil datablock summary */ void gpencil_to_keylist(struct bDopeSheet *ads, struct bGPdata *gpd, - struct AnimKeylist *keys, + struct AnimKeylist *keylist, const bool active); /* Grease Pencil Layer */ -void gpl_to_keylist(struct bDopeSheet *ads, struct bGPDlayer *gpl, struct AnimKeylist *keys); +void gpl_to_keylist(struct bDopeSheet *ads, struct bGPDlayer *gpl, struct AnimKeylist *keylist); /* Mask */ -void mask_to_keylist(struct bDopeSheet *ads, struct MaskLayer *masklay, struct AnimKeylist *keys); +void mask_to_keylist(struct bDopeSheet *ads, struct MaskLayer *masklay, struct AnimKeylist *keylist); /* ActKeyColumn API ---------------- */ /* Comparator callback used for ActKeyColumns and cframe float-value pointer */ diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 888dcd9d428..3141c8f707b 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -53,6 +53,7 @@ struct uiLayout; struct wmKeyConfig; struct wmOperator; struct wmOperatorType; +struct wmEvent; /* object_edit.c */ /* context.object */ @@ -199,6 +200,9 @@ void ED_object_parent(struct Object *ob, struct Object *parent, const int type, const char *substr); +char *ED_object_ot_drop_named_material_tooltip(struct bContext *C, + struct PointerRNA *properties, + const struct wmEvent *event); /* bitflags for enter/exit editmode */ enum { diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index 7ccdc49d291..eb893fbe029 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -715,7 +715,7 @@ DEF_ICON(UV_ISLANDSEL) DEF_ICON(UV_SYNC_SELECT) DEF_ICON_BLANK(240) DEF_ICON_BLANK(241) -DEF_ICON_BLANK(242) +DEF_ICON(FIXED_SIZE) DEF_ICON(TRANSFORM_ORIGINS) DEF_ICON(GIZMO) DEF_ICON(ORIENTATION_CURSOR) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index a2b25aed582..d3a3df98d99 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -4017,9 +4017,11 @@ uiBut *ui_but_change_type(uiBut *but, eButType new_type) UNUSED_VARS_NDEBUG(found_layout); ui_button_group_replace_but_ptr(uiLayoutGetBlock(but->layout), old_but_ptr, but); } +#ifdef WITH_PYTHON if (UI_editsource_enable_check()) { UI_editsource_but_replace(old_but_ptr, but); } +#endif } return but; diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 0ffc5659191..6755eded05c 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -2425,6 +2425,7 @@ void UI_icon_draw_ex(float x, ImBuf *UI_icon_alert_imbuf_get(eAlertIcon icon) { #ifdef WITH_HEADLESS + UNUSED_VARS(icon); return NULL; #else const int ALERT_IMG_SIZE = 256; diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index a75cc839ae4..dd10d942fc9 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -998,55 +998,69 @@ static bool copy_to_selected_button(bContext *C, bool all, bool poll) UI_context_active_but_prop_get(C, &ptr, &prop, &index); /* if there is a valid property that is editable... */ - if (ptr.data && prop) { - char *path = NULL; - bool use_path_from_id; - ListBase lb = {NULL}; - - if (UI_context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path) && - !BLI_listbase_is_empty(&lb)) { - LISTBASE_FOREACH (CollectionPointerLink *, link, &lb) { - if (link->ptr.data != ptr.data) { - if (use_path_from_id) { - /* Path relative to ID. */ - lprop = NULL; - RNA_id_pointer_create(link->ptr.owner_id, &idptr); - RNA_path_resolve_property(&idptr, path, &lptr, &lprop); - } - else if (path) { - /* Path relative to elements from list. */ - lprop = NULL; - RNA_path_resolve_property(&link->ptr, path, &lptr, &lprop); - } - else { - lptr = link->ptr; - lprop = prop; - } + if (ptr.data == NULL || prop == NULL) { + return false; + } - if (lptr.data == ptr.data) { - /* lptr might not be the same as link->ptr! */ - continue; - } + char *path = NULL; + bool use_path_from_id; + ListBase lb = {NULL}; - if (lprop == prop) { - if (RNA_property_editable(&lptr, lprop)) { - if (poll) { - success = true; - break; - } - if (RNA_property_copy(bmain, &lptr, &ptr, prop, (all) ? -1 : index)) { - RNA_property_update(C, &lptr, prop); - success = true; - } - } - } - } - } - } + if (!UI_context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path)) { + return false; + } + if (BLI_listbase_is_empty(&lb)) { MEM_SAFE_FREE(path); - BLI_freelistN(&lb); + return false; } + LISTBASE_FOREACH (CollectionPointerLink *, link, &lb) { + if (link->ptr.data == ptr.data) { + continue; + } + + if (use_path_from_id) { + /* Path relative to ID. */ + lprop = NULL; + RNA_id_pointer_create(link->ptr.owner_id, &idptr); + RNA_path_resolve_property(&idptr, path, &lptr, &lprop); + } + else if (path) { + /* Path relative to elements from list. */ + lprop = NULL; + RNA_path_resolve_property(&link->ptr, path, &lptr, &lprop); + } + else { + lptr = link->ptr; + lprop = prop; + } + + if (lptr.data == ptr.data) { + /* lptr might not be the same as link->ptr! */ + continue; + } + + if (lprop != prop) { + continue; + } + + if (!RNA_property_editable(&lptr, lprop)) { + continue; + } + + if (poll) { + success = true; + break; + } + if (RNA_property_copy(bmain, &lptr, &ptr, prop, (all) ? -1 : index)) { + RNA_property_update(C, &lptr, prop); + success = true; + } + } + + MEM_SAFE_FREE(path); + BLI_freelistN(&lb); + return success; } diff --git a/source/blender/editors/io/io_ops.c b/source/blender/editors/io/io_ops.c index 9fa34a1c55d..b2788ee49a2 100644 --- a/source/blender/editors/io/io_ops.c +++ b/source/blender/editors/io/io_ops.c @@ -52,6 +52,7 @@ void ED_operatortypes_io(void) WM_operatortype_append(WM_OT_alembic_export); #endif #ifdef WITH_USD + WM_operatortype_append(WM_OT_usd_import); WM_operatortype_append(WM_OT_usd_export); #endif diff --git a/source/blender/editors/io/io_usd.c b/source/blender/editors/io/io_usd.c index 0eadb38abb5..d0007d9e5be 100644 --- a/source/blender/editors/io/io_usd.c +++ b/source/blender/editors/io/io_usd.c @@ -22,23 +22,30 @@ */ #ifdef WITH_USD +# include "DNA_modifier_types.h" # include "DNA_space_types.h" +# include <string.h> # include "BKE_context.h" # include "BKE_main.h" # include "BKE_report.h" +# include "BLI_blenlib.h" # include "BLI_path_util.h" # include "BLI_string.h" # include "BLI_utildefines.h" # include "BLT_translation.h" +# include "ED_object.h" + # include "MEM_guardedalloc.h" # include "RNA_access.h" # include "RNA_define.h" +# include "RNA_enum_types.h" + # include "UI_interface.h" # include "UI_resources.h" @@ -50,6 +57,8 @@ # include "io_usd.h" # include "usd.h" +# include "stdio.h" + const EnumPropertyItem rna_enum_usd_export_evaluation_mode_items[] = { {DAG_EVAL_RENDER, "RENDER", @@ -242,4 +251,274 @@ void WM_OT_usd_export(struct wmOperatorType *ot) "are different settings for viewport and rendering"); } +/* ====== USD Import ====== */ + +static int wm_usd_import_invoke(bContext *C, wmOperator *op, const wmEvent *event) +{ + eUSDOperatorOptions *options = MEM_callocN(sizeof(eUSDOperatorOptions), "eUSDOperatorOptions"); + options->as_background_job = true; + op->customdata = options; + + return WM_operator_filesel(C, op, event); +} + +static int wm_usd_import_exec(bContext *C, wmOperator *op) +{ + if (!RNA_struct_property_is_set(op->ptr, "filepath")) { + BKE_report(op->reports, RPT_ERROR, "No filename given"); + return OPERATOR_CANCELLED; + } + + char filename[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filename); + + eUSDOperatorOptions *options = (eUSDOperatorOptions *)op->customdata; + const bool as_background_job = (options != NULL && options->as_background_job); + MEM_SAFE_FREE(op->customdata); + + const float scale = RNA_float_get(op->ptr, "scale"); + + const bool set_frame_range = RNA_boolean_get(op->ptr, "set_frame_range"); + + const bool read_mesh_uvs = RNA_boolean_get(op->ptr, "read_mesh_uvs"); + const bool read_mesh_colors = RNA_boolean_get(op->ptr, "read_mesh_colors"); + + char mesh_read_flag = MOD_MESHSEQ_READ_VERT | MOD_MESHSEQ_READ_POLY; + if (read_mesh_uvs) { + mesh_read_flag |= MOD_MESHSEQ_READ_UV; + } + if (read_mesh_colors) { + mesh_read_flag |= MOD_MESHSEQ_READ_COLOR; + } + + const bool import_cameras = RNA_boolean_get(op->ptr, "import_cameras"); + const bool import_curves = RNA_boolean_get(op->ptr, "import_curves"); + const bool import_lights = RNA_boolean_get(op->ptr, "import_lights"); + const bool import_materials = RNA_boolean_get(op->ptr, "import_materials"); + const bool import_meshes = RNA_boolean_get(op->ptr, "import_meshes"); + const bool import_volumes = RNA_boolean_get(op->ptr, "import_volumes"); + + const bool import_subdiv = RNA_boolean_get(op->ptr, "import_subdiv"); + + const bool import_instance_proxies = RNA_boolean_get(op->ptr, "import_instance_proxies"); + + const bool import_visible_only = RNA_boolean_get(op->ptr, "import_visible_only"); + + const bool create_collection = RNA_boolean_get(op->ptr, "create_collection"); + + char *prim_path_mask = malloc(1024); + RNA_string_get(op->ptr, "prim_path_mask", prim_path_mask); + + const bool import_guide = RNA_boolean_get(op->ptr, "import_guide"); + const bool import_proxy = RNA_boolean_get(op->ptr, "import_proxy"); + const bool import_render = RNA_boolean_get(op->ptr, "import_render"); + + const bool import_usd_preview = RNA_boolean_get(op->ptr, "import_usd_preview"); + const bool set_material_blend = RNA_boolean_get(op->ptr, "set_material_blend"); + + const float light_intensity_scale = RNA_float_get(op->ptr, "light_intensity_scale"); + + /* TODO(makowalski): Add support for sequences. */ + const bool is_sequence = false; + int offset = 0; + int sequence_len = 1; + + /* Switch out of edit mode to avoid being stuck in it (T54326). */ + Object *obedit = CTX_data_edit_object(C); + if (obedit) { + ED_object_mode_set(C, OB_MODE_EDIT); + } + + const bool validate_meshes = false; + const bool use_instancing = false; + + struct USDImportParams params = {.scale = scale, + .is_sequence = is_sequence, + .set_frame_range = set_frame_range, + .sequence_len = sequence_len, + .offset = offset, + .validate_meshes = validate_meshes, + .mesh_read_flag = mesh_read_flag, + .import_cameras = import_cameras, + .import_curves = import_curves, + .import_lights = import_lights, + .import_materials = import_materials, + .import_meshes = import_meshes, + .import_volumes = import_volumes, + .prim_path_mask = prim_path_mask, + .import_subdiv = import_subdiv, + .import_instance_proxies = import_instance_proxies, + .create_collection = create_collection, + .import_guide = import_guide, + .import_proxy = import_proxy, + .import_render = import_render, + .import_visible_only = import_visible_only, + .use_instancing = use_instancing, + .import_usd_preview = import_usd_preview, + .set_material_blend = set_material_blend, + .light_intensity_scale = light_intensity_scale}; + + const bool ok = USD_import(C, filename, ¶ms, as_background_job); + + return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED; +} + +static void wm_usd_import_draw(bContext *UNUSED(C), wmOperator *op) +{ + uiLayout *layout = op->layout; + struct PointerRNA *ptr = op->ptr; + + uiLayoutSetPropSep(layout, true); + uiLayoutSetPropDecorate(layout, false); + + uiLayout *box = uiLayoutBox(layout); + uiLayout *col = uiLayoutColumnWithHeading(box, true, IFACE_("Data Types")); + uiItemR(col, ptr, "import_cameras", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "import_curves", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "import_lights", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "import_materials", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "import_meshes", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "import_volumes", 0, NULL, ICON_NONE); + uiItemR(box, ptr, "prim_path_mask", 0, NULL, ICON_NONE); + uiItemR(box, ptr, "scale", 0, NULL, ICON_NONE); + + box = uiLayoutBox(layout); + col = uiLayoutColumnWithHeading(box, true, IFACE_("Mesh Data")); + uiItemR(col, ptr, "read_mesh_uvs", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "read_mesh_colors", 0, NULL, ICON_NONE); + col = uiLayoutColumnWithHeading(box, true, IFACE_("Include")); + uiItemR(col, ptr, "import_subdiv", 0, IFACE_("Subdivision"), ICON_NONE); + uiItemR(col, ptr, "import_instance_proxies", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "import_visible_only", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "import_guide", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "import_proxy", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "import_render", 0, NULL, ICON_NONE); + + col = uiLayoutColumnWithHeading(box, true, IFACE_("Options")); + uiItemR(col, ptr, "set_frame_range", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "relative_path", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "create_collection", 0, NULL, ICON_NONE); + uiItemR(box, ptr, "light_intensity_scale", 0, NULL, ICON_NONE); + + box = uiLayoutBox(layout); + col = uiLayoutColumnWithHeading(box, true, IFACE_("Experimental")); + uiItemR(col, ptr, "import_usd_preview", 0, NULL, ICON_NONE); + uiLayoutSetEnabled(col, RNA_boolean_get(ptr, "import_materials")); + uiLayout *row = uiLayoutRow(col, true); + uiItemR(row, ptr, "set_material_blend", 0, NULL, ICON_NONE); + uiLayoutSetEnabled(row, RNA_boolean_get(ptr, "import_usd_preview")); +} + +void WM_OT_usd_import(struct wmOperatorType *ot) +{ + ot->name = "Import USD"; + ot->description = "Import USD stage into current scene"; + ot->idname = "WM_OT_usd_import"; + + ot->invoke = wm_usd_import_invoke; + ot->exec = wm_usd_import_exec; + ot->poll = WM_operator_winactive; + ot->ui = wm_usd_import_draw; + + WM_operator_properties_filesel(ot, + FILE_TYPE_FOLDER | FILE_TYPE_USD, + FILE_BLENDER, + FILE_OPENFILE, + WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_SHOW_PROPS, + FILE_DEFAULTDISPLAY, + FILE_SORT_ALPHA); + + RNA_def_float( + ot->srna, + "scale", + 1.0f, + 0.0001f, + 1000.0f, + "Scale", + "Value by which to enlarge or shrink the objects with respect to the world's origin", + 0.0001f, + 1000.0f); + + RNA_def_boolean(ot->srna, + "set_frame_range", + true, + "Set Frame Range", + "Update the scene's start and end frame to match those of the USD archive"); + + RNA_def_boolean(ot->srna, "import_cameras", true, "Cameras", ""); + RNA_def_boolean(ot->srna, "import_curves", true, "Curves", ""); + RNA_def_boolean(ot->srna, "import_lights", true, "Lights", ""); + RNA_def_boolean(ot->srna, "import_materials", true, "Materials", ""); + RNA_def_boolean(ot->srna, "import_meshes", true, "Meshes", ""); + RNA_def_boolean(ot->srna, "import_volumes", true, "Volumes", ""); + + RNA_def_boolean(ot->srna, + "import_subdiv", + false, + "Import Subdivision Scheme", + "Create subdivision surface modifiers based on the USD " + "SubdivisionScheme attribute"); + + RNA_def_boolean(ot->srna, + "import_instance_proxies", + true, + "Import Instance Proxies", + "Create unique Blender objects for USD instances"); + + RNA_def_boolean(ot->srna, + "import_visible_only", + true, + "Visible Primitives Only", + "Do not import invisible USD primitives. " + "Only applies to primitives with a non-animated visibility attribute. " + "Primitives with animated visibility will always be imported"); + + RNA_def_boolean(ot->srna, + "create_collection", + false, + "Create Collection", + "Add all imported objects to a new collection"); + + RNA_def_boolean(ot->srna, "read_mesh_uvs", true, "UV Coordinates", "Read mesh UV coordinates"); + + RNA_def_boolean(ot->srna, "read_mesh_colors", false, "Vertex Colors", "Read mesh vertex colors"); + + RNA_def_string(ot->srna, + "prim_path_mask", + NULL, + 1024, + "Path Mask", + "Import only the subset of the USD scene rooted at the given primitive"); + + RNA_def_boolean(ot->srna, "import_guide", false, "Guide", "Import guide geometry"); + + RNA_def_boolean(ot->srna, "import_proxy", true, "Proxy", "Import proxy geometry"); + + RNA_def_boolean(ot->srna, "import_render", true, "Render", "Import final render geometry"); + + RNA_def_boolean(ot->srna, + "import_usd_preview", + false, + "Import USD Preview", + "Convert UsdPreviewSurface shaders to Principled BSDF shader networks"); + + RNA_def_boolean(ot->srna, + "set_material_blend", + true, + "Set Material Blend", + "If the Import USD Preview option is enabled, " + "the material blend method will automatically be set based on the " + "shader's opacity and opacityThreshold inputs"); + + RNA_def_float(ot->srna, + "light_intensity_scale", + 1.0f, + 0.0001f, + 10000.0f, + "Light Intensity Scale", + "Scale for the intensity of imported lights", + 0.0001f, + 1000.0f); +} + #endif /* WITH_USD */ diff --git a/source/blender/editors/io/io_usd.h b/source/blender/editors/io/io_usd.h index 671984b6f34..7424cc0df32 100644 --- a/source/blender/editors/io/io_usd.h +++ b/source/blender/editors/io/io_usd.h @@ -26,3 +26,5 @@ struct wmOperatorType; void WM_OT_usd_export(struct wmOperatorType *ot); + +void WM_OT_usd_import(struct wmOperatorType *ot); diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index 3bb05a27c54..8ddc3758e4e 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -164,8 +164,8 @@ void ED_mask_select_flush_all(Mask *mask) LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { spline->flag &= ~SELECT; - /* intentionally _dont_ do this in the mask layer loop - * so we clear flags on all splines */ + /* Intentionally *don't* do this in the mask layer loop + * so we clear flags on all splines. */ if (mask_layer->restrictflag & MASK_RESTRICT_VIEW) { continue; } diff --git a/source/blender/editors/mesh/editmesh_preselect_edgering.c b/source/blender/editors/mesh/editmesh_preselect_edgering.c index 43e36957dc9..c58f29917b1 100644 --- a/source/blender/editors/mesh/editmesh_preselect_edgering.c +++ b/source/blender/editors/mesh/editmesh_preselect_edgering.c @@ -20,6 +20,8 @@ #include "MEM_guardedalloc.h" +#include "DNA_userdef_types.h" + #include "BLI_math.h" #include "BLI_stack.h" @@ -160,16 +162,21 @@ void EDBM_preselect_edgering_draw(struct EditMesh_PreSelEdgeRing *psel, const fl } GPU_depth_test(GPU_DEPTH_NONE); + GPU_blend(GPU_BLEND_ALPHA); GPU_matrix_push(); GPU_matrix_mul(matrix); uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - immUniformThemeColor3(TH_GIZMO_PRIMARY); - if (psel->edges_len > 0) { + float viewport[4]; + GPU_viewport_size_get_f(viewport); + + immBindBuiltinProgram(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR); + immUniform2fv("viewportSize", &viewport[2]); + immUniformThemeColor3(TH_GIZMO_PRIMARY); + immUniform1f("lineWidth", U.pixelsize); immBegin(GPU_PRIM_LINES, psel->edges_len * 2); for (int i = 0; i < psel->edges_len; i++) { @@ -178,10 +185,18 @@ void EDBM_preselect_edgering_draw(struct EditMesh_PreSelEdgeRing *psel, const fl } immEnd(); + immUnbindProgram(); } if (psel->verts_len > 0) { - GPU_point_size(3.0f); + GPU_program_point_size(true); + immBindBuiltinProgram(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA); + immUniformThemeColor3(TH_GIZMO_PRIMARY); + + /* Same size as an edit mode vertex */ + immUniform1f("size", + 2.0 * U.pixelsize * + (max_ff(1.0f, UI_GetThemeValuef(TH_VERTEX_SIZE) * (float)M_SQRT2 / 2.0f))); immBegin(GPU_PRIM_POINTS, psel->verts_len); @@ -190,14 +205,15 @@ void EDBM_preselect_edgering_draw(struct EditMesh_PreSelEdgeRing *psel, const fl } immEnd(); + immUnbindProgram(); + GPU_program_point_size(false); } - immUnbindProgram(); - GPU_matrix_pop(); /* Reset default */ GPU_depth_test(GPU_DEPTH_LESS_EQUAL); + GPU_blend(GPU_BLEND_NONE); } static void view3d_preselect_mesh_edgering_update_verts_from_edge( diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 830c9abb41e..8e38d41f971 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -1860,10 +1860,16 @@ void MESH_OT_loop_select(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; /* properties */ - RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", "Extend the selection"); - RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Remove from the selection"); - RNA_def_boolean(ot->srna, "toggle", 0, "Toggle Select", "Toggle the selection"); - RNA_def_boolean(ot->srna, "ring", 0, "Select Ring", "Select ring"); + PropertyRNA *prop; + + prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", "Extend the selection"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Remove from the selection"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, "toggle", 0, "Toggle Select", "Toggle the selection"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, "ring", 0, "Select Ring", "Select ring"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } void MESH_OT_edgering_select(wmOperatorType *ot) @@ -1880,10 +1886,16 @@ void MESH_OT_edgering_select(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_UNDO; - RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection"); - RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Remove from the selection"); - RNA_def_boolean(ot->srna, "toggle", 0, "Toggle Select", "Toggle the selection"); - RNA_def_boolean(ot->srna, "ring", 1, "Select Ring", "Select ring"); + /* Properties. */ + PropertyRNA *prop; + prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Remove from the selection"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, "toggle", 0, "Toggle Select", "Toggle the selection"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, "ring", 1, "Select Ring", "Select ring"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /** \} */ diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index f576c0c8517..92d0deb49d0 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -2723,6 +2723,35 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot) /** \name Drop Named Material on Object Operator * \{ */ +char *ED_object_ot_drop_named_material_tooltip(bContext *C, + PointerRNA *properties, + const wmEvent *event) +{ + Base *base = ED_view3d_give_base_under_cursor(C, event->mval); + + char name[MAX_ID_NAME - 2]; + RNA_string_get(properties, "name", name); + + if (base == NULL) { + return BLI_strdup(""); + } + + Object *ob = base->object; + int active_mat_slot = max_ii(ob->actcol, 1); + Material *prev_mat = BKE_object_material_get(ob, active_mat_slot); + + char *result; + if (prev_mat) { + const char *tooltip = TIP_("Drop %s on %s (slot %d, replacing %s)."); + result = BLI_sprintfN(tooltip, name, ob->id.name + 2, active_mat_slot, prev_mat->id.name + 2); + } + else { + const char *tooltip = TIP_("Drop %s on %s (slot %d)."); + result = BLI_sprintfN(tooltip, name, ob->id.name + 2, active_mat_slot); + } + return result; +} + static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent *event) { Main *bmain = CTX_data_main(C); diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 37a56816677..7d9b8583838 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -82,6 +82,9 @@ void ED_file_path_button(bScreen *screen, PointerRNA params_rna_ptr; uiBut *but; + BLI_assert_msg(params != NULL, + "File select parameters not set. The caller is expected to check this."); + RNA_pointer_create(&screen->id, &RNA_FileSelectParams, params, ¶ms_rna_ptr); /* callbacks for operator check functions */ diff --git a/source/blender/editors/space_node/node_select.cc b/source/blender/editors/space_node/node_select.cc index 6c07c41f451..a1068f29624 100644 --- a/source/blender/editors/space_node/node_select.cc +++ b/source/blender/editors/space_node/node_select.cc @@ -664,7 +664,8 @@ void NODE_OT_select(wmOperatorType *ot) /* properties */ WM_operator_properties_generic_select(ot); - RNA_def_boolean(ot->srna, "extend", false, "Extend", ""); + prop = RNA_def_boolean(ot->srna, "extend", false, "Extend", ""); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); RNA_def_boolean(ot->srna, "socket_select", false, "Socket Select", ""); prop = RNA_def_boolean(ot->srna, "deselect_all", diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c index 36b2966dc43..a82f516b125 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.c +++ b/source/blender/editors/space_outliner/outliner_dragdrop.c @@ -868,7 +868,8 @@ static bool datastack_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) static char *datastack_drop_tooltip(bContext *UNUSED(C), wmDrag *drag, - const wmEvent *UNUSED(event)) + const wmEvent *UNUSED(event), + struct wmDropBox *UNUSED(drop)) { StackDropData *drop_data = drag->poin; switch (drop_data->drop_action) { @@ -1103,10 +1104,6 @@ static bool collection_drop_init(bContext *C, if (ID_IS_LINKED(to_collection)) { return false; } - /* Currently this should not be allowed (might be supported in the future though...). */ - if (ID_IS_OVERRIDE_LIBRARY(to_collection)) { - return false; - } /* Get drag datablocks. */ if (drag->type != WM_DRAG_ID) { @@ -1130,6 +1127,11 @@ static bool collection_drop_init(bContext *C, from_collection = NULL; } + /* Currently this should not be allowed, cannot edit items in an override of a Collection. */ + if (from_collection != NULL && ID_IS_OVERRIDE_LIBRARY(from_collection)) { + return false; + } + /* Get collections. */ if (GS(id->name) == ID_GR) { if (id == &to_collection->id) { @@ -1140,6 +1142,12 @@ static bool collection_drop_init(bContext *C, insert_type = TE_INSERT_INTO; } + /* Currently this should not be allowed, cannot edit items in an override of a Collection. */ + if (ID_IS_OVERRIDE_LIBRARY(to_collection) && + !ELEM(insert_type, TE_INSERT_AFTER, TE_INSERT_BEFORE)) { + return false; + } + data->from = from_collection; data->to = to_collection; data->te = te; @@ -1191,7 +1199,10 @@ static bool collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event return false; } -static char *collection_drop_tooltip(bContext *C, wmDrag *drag, const wmEvent *event) +static char *collection_drop_tooltip(bContext *C, + wmDrag *drag, + const wmEvent *event, + wmDropBox *UNUSED(drop)) { CollectionDrop data; if (!event->shift && collection_drop_init(C, drag, event, &data)) { diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index aaa52f6b649..898e66e7a39 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -1682,7 +1682,8 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot) ot->flag |= OPTYPE_REGISTER | OPTYPE_UNDO; PropertyRNA *prop; - RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection for activation"); + prop = RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection for activation"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); prop = RNA_def_boolean( ot->srna, "extend_range", false, "Extend Range", "Select a range from active element"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 5980bfe37cd..333edd0ed5f 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -999,7 +999,9 @@ void SEQUENCER_OT_select_linked_pick(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* Properties. */ - RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection"); + PropertyRNA *prop; + prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /** \} */ @@ -1227,7 +1229,9 @@ void SEQUENCER_OT_select_side_of_frame(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; /* Properties. */ - RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection"); + PropertyRNA *prop; + prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); ot->prop = RNA_def_enum(ot->srna, "side", sequencer_select_left_right_types, 0, "Side", ""); } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index a2564469c16..0803b4c4776 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -53,6 +53,7 @@ #include "BKE_screen.h" #include "BKE_workspace.h" +#include "ED_object.h" #include "ED_render.h" #include "ED_screen.h" #include "ED_space_api.h" @@ -528,6 +529,16 @@ static bool view3d_mat_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event return view3d_drop_id_in_main_region_poll(C, drag, event, ID_MA); } +static char *view3d_mat_drop_tooltip(bContext *C, + wmDrag *drag, + const wmEvent *event, + struct wmDropBox *drop) +{ + wmDragAsset *asset_drag = WM_drag_get_asset_data(drag, ID_MA); + RNA_string_set(drop->ptr, "name", asset_drag->name); + return ED_object_ot_drop_named_material_tooltip(C, drop->ptr, event); +} + static bool view3d_object_data_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) { ID_Type id_type = view3d_drop_id_in_main_region_poll_get_id_type(C, drag, event); @@ -539,7 +550,8 @@ static bool view3d_object_data_drop_poll(bContext *C, wmDrag *drag, const wmEven static char *view3d_object_data_drop_tooltip(bContext *UNUSED(C), wmDrag *UNUSED(drag), - const wmEvent *UNUSED(event)) + const wmEvent *UNUSED(event), + wmDropBox *UNUSED(drop)) { return BLI_strdup(TIP_("Create object instance from object-data")); } @@ -689,7 +701,7 @@ static void view3d_dropboxes(void) view3d_mat_drop_poll, view3d_id_drop_copy, WM_drag_free_imported_drag_ID, - NULL); + view3d_mat_drop_tooltip); WM_dropbox_add(lb, "VIEW3D_OT_background_image_add", view3d_ima_bg_drop_poll, diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index ecf43c734e2..5ec3e9cae5a 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1589,9 +1589,12 @@ void VIEW3D_OT_select_menu(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_HIDDEN | PROP_ENUM_NO_TRANSLATE); ot->prop = prop; - RNA_def_boolean(ot->srna, "extend", 0, "Extend", ""); - RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", ""); - RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", ""); + prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend", ""); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", ""); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", ""); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } static Base *object_mouse_select_menu(bContext *C, @@ -1764,9 +1767,12 @@ void VIEW3D_OT_bone_select_menu(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_HIDDEN | PROP_ENUM_NO_TRANSLATE); ot->prop = prop; - RNA_def_boolean(ot->srna, "extend", 0, "Extend", ""); - RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", ""); - RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", ""); + prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend", ""); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", ""); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", ""); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } static bool bone_mouse_select_menu(bContext *C, const uint *buffer, diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 2c424d8ace3..45c077b8a07 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -371,25 +371,24 @@ static void transformops_exit(bContext *C, wmOperator *op) G.moving = 0; } +static int transformops_mode(wmOperator *op) +{ + for (TransformModeItem *tmode = transform_modes; tmode->idname; tmode++) { + if (op->type->idname == tmode->idname) { + return tmode->mode; + } + } + + return RNA_enum_get(op->ptr, "mode"); +} + static int transformops_data(bContext *C, wmOperator *op, const wmEvent *event) { int retval = 1; if (op->customdata == NULL) { TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data2"); - TransformModeItem *tmode; - int mode = -1; - - for (tmode = transform_modes; tmode->idname; tmode++) { - if (op->type->idname == tmode->idname) { - mode = tmode->mode; - break; - } - } - - if (mode == -1) { - mode = RNA_enum_get(op->ptr, "mode"); - } + int mode = transformops_mode(op); retval = initTransform(C, t, op, event, mode); /* store data */ @@ -556,6 +555,16 @@ static bool transform_poll_property(const bContext *UNUSED(C), } } + /* Orientation Axis. */ + { + if (STREQ(prop_id, "orient_axis")) { + eTfmMode mode = (eTfmMode)transformops_mode(op); + if (mode == TFM_ALIGN) { + return false; + } + } + } + /* Proportional Editing. */ { PropertyRNA *prop_pet = RNA_struct_find_property(op->ptr, "use_proportional_edit"); diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c index 15d672dea56..823837e2a42 100644 --- a/source/blender/editors/util/numinput.c +++ b/source/blender/editors/util/numinput.c @@ -309,7 +309,7 @@ bool user_string_to_number(bContext *C, return success; #else - UNUSED_VARS(C, unit, type); + UNUSED_VARS(C, unit, type, use_single_line_error, r_error); *r_value = atof(str); return true; #endif diff --git a/source/blender/editors/uvedit/uvedit_select.c b/source/blender/editors/uvedit/uvedit_select.c index 20aadb84b7b..4c597d80534 100644 --- a/source/blender/editors/uvedit/uvedit_select.c +++ b/source/blender/editors/uvedit/uvedit_select.c @@ -2140,11 +2140,12 @@ void UV_OT_select(wmOperatorType *ot) /* properties */ PropertyRNA *prop; - RNA_def_boolean(ot->srna, - "extend", - 0, - "Extend", - "Extend selection rather than clearing the existing selection"); + prop = RNA_def_boolean(ot->srna, + "extend", + 0, + "Extend", + "Extend selection rather than clearing the existing selection"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); prop = RNA_def_boolean(ot->srna, "deselect_all", false, @@ -2152,7 +2153,7 @@ void UV_OT_select(wmOperatorType *ot) "Deselect all when nothing under the cursor"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); - RNA_def_float_vector( + prop = RNA_def_float_vector( ot->srna, "location", 2, @@ -2163,6 +2164,7 @@ void UV_OT_select(wmOperatorType *ot) "Mouse location in normalized coordinates, 0.0 to 1.0 is within the image bounds", -100.0f, 100.0f); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /** \} */ @@ -2296,12 +2298,14 @@ void UV_OT_select_loop(wmOperatorType *ot) ot->poll = ED_operator_uvedit; /* requires space image */ /* properties */ - RNA_def_boolean(ot->srna, - "extend", - 0, - "Extend", - "Extend selection rather than clearing the existing selection"); - RNA_def_float_vector( + PropertyRNA *prop; + prop = RNA_def_boolean(ot->srna, + "extend", + 0, + "Extend", + "Extend selection rather than clearing the existing selection"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_float_vector( ot->srna, "location", 2, @@ -2312,6 +2316,7 @@ void UV_OT_select_loop(wmOperatorType *ot) "Mouse location in normalized coordinates, 0.0 to 1.0 is within the image bounds", -100.0f, 100.0f); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /** \} */ @@ -2494,17 +2499,20 @@ void UV_OT_select_linked_pick(wmOperatorType *ot) ot->poll = ED_operator_uvedit; /* requires space image */ /* properties */ - RNA_def_boolean(ot->srna, - "extend", - 0, - "Extend", - "Extend selection rather than clearing the existing selection"); - RNA_def_boolean(ot->srna, - "deselect", - 0, - "Deselect", - "Deselect linked UV vertices rather than selecting them"); - RNA_def_float_vector( + PropertyRNA *prop; + prop = RNA_def_boolean(ot->srna, + "extend", + 0, + "Extend", + "Extend selection rather than clearing the existing selection"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, + "deselect", + 0, + "Deselect", + "Deselect linked UV vertices rather than selecting them"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_float_vector( ot->srna, "location", 2, @@ -2515,6 +2523,7 @@ void UV_OT_select_linked_pick(wmOperatorType *ot) "Mouse location in normalized coordinates, 0.0 to 1.0 is within the image bounds", -100.0f, 100.0f); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /** \} */ diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 535a0e00347..1bcd1fad9d6 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -1769,7 +1769,7 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(region), void GPU_blend(GPU_BLEND_ALPHA); - /* Static Tris */ + /* Static Triangles. */ if (stitch_preview->static_tris) { UI_GetThemeColor4fv(TH_STITCH_PREVIEW_ACTIVE, col); vbo = GPU_vertbuf_create_with_format(&format); |