From 3e8b2288f5bfc8c27a31f8a8ee85803f0e6a63dc Mon Sep 17 00:00:00 2001 From: Aleksandr Zinovev Date: Thu, 27 Jul 2017 10:13:40 +0300 Subject: Fix: use click style if a pie was spawned by release or click event --- source/blender/editors/interface/interface_regions.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 5ed94474726..18ababbb657 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -2952,8 +2952,8 @@ uiPieMenu *UI_pie_menu_begin(struct bContext *C, const char *title, int icon, co pie->block_radial->puphash = ui_popup_menu_hash(title); pie->block_radial->flag |= UI_BLOCK_RADIAL; - /* if pie is spawned by a left click, it is always assumed to be click style */ - if (event->type == LEFTMOUSE) { + /* if pie is spawned by a left click, release or click event, it is always assumed to be click style */ + if (event->type == LEFTMOUSE || ELEM(event->val, KM_RELEASE, KM_CLICK)) { pie->block_radial->pie_data.flags |= UI_PIE_CLICK_STYLE; pie->block_radial->pie_data.event = EVENT_NONE; win->lock_pie_event = EVENT_NONE; -- cgit v1.2.3 From ec228090257d8b742d43d9c52e077e4a9c9a0c50 Mon Sep 17 00:00:00 2001 From: Aleksandr Zinovev Date: Thu, 27 Jul 2017 10:27:29 +0300 Subject: Fix Label colors in popups --- source/blender/editors/include/UI_interface.h | 2 ++ source/blender/editors/interface/interface_layout.c | 15 ++++++++++++++- source/blender/editors/interface/interface_widgets.c | 14 +++++++++----- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 7b4fac08a7b..9376de8c095 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -212,6 +212,8 @@ enum { UI_BUT_ALIGN_STITCH_TOP = (1 << 18), UI_BUT_ALIGN_STITCH_LEFT = (1 << 19), UI_BUT_ALIGN_ALL = (UI_BUT_ALIGN | UI_BUT_ALIGN_STITCH_TOP | UI_BUT_ALIGN_STITCH_LEFT), + + UI_BUT_BOX_ITEM = (1 << 20), /* This but is "inside" a box item (currently used to change theme colors). */ }; /* scale fixed button widths by this to account for DPI */ diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index da43a58bc74..fed9f2d364e 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -128,6 +128,8 @@ typedef struct uiItem { enum { UI_ITEM_FIXED = 1 << 0, UI_ITEM_MIN = 1 << 1, + + UI_ITEM_BOX_ITEM = 1 << 2, /* The item is "inside" a box item */ }; typedef struct uiButtonItem { @@ -2306,6 +2308,9 @@ static void ui_litem_layout_column(uiLayout *litem, bool is_box) if (item->next && (!is_box || item != litem->items.first)) y -= litem->space; + + if (is_box) + item->flag |= UI_ITEM_BOX_ITEM; } litem->h = litem->y - y; @@ -3266,8 +3271,16 @@ static void ui_item_layout(uiItem *item) break; } - for (subitem = litem->items.first; subitem; subitem = subitem->next) + for (subitem = litem->items.first; subitem; subitem = subitem->next) { + if (item->flag & UI_ITEM_BOX_ITEM) + subitem->flag |= UI_ITEM_BOX_ITEM; ui_item_layout(subitem); + } + } else { + if (item->flag & UI_ITEM_BOX_ITEM) { + uiButtonItem *bitem = (uiButtonItem *)item; + bitem->but->drawflag |= UI_BUT_BOX_ITEM; + } } } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index f7f2b422724..51bf09125ba 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -3655,11 +3655,15 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct switch (but->type) { case UI_BTYPE_LABEL: - if (but->block->flag & UI_BLOCK_LOOP) - widget_draw_text_icon(&style->widgetlabel, &tui->wcol_menu_back, but, rect); - else { - wt = widget_type(UI_WTYPE_LABEL); - fstyle = &style->widgetlabel; + wt = widget_type(UI_WTYPE_LABEL); + fstyle = &style->widgetlabel; + if (but->drawflag & UI_BUT_BOX_ITEM) { + wt->wcol_theme = &tui->wcol_box; + wt->state = widget_state; + } + else if (but->block->flag & UI_BLOCK_LOOP) { + wt->wcol_theme = &tui->wcol_menu_back; + wt->state = widget_state; } break; -- cgit v1.2.3 From 129c3ac7b3216fad2ea8bc2eff24fcb6eba8ff73 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Thu, 27 Jul 2017 11:44:51 +0200 Subject: Minor code style corrections --- source/blender/editors/interface/interface_layout.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index fed9f2d364e..99868294a2e 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2309,8 +2309,9 @@ static void ui_litem_layout_column(uiLayout *litem, bool is_box) if (item->next && (!is_box || item != litem->items.first)) y -= litem->space; - if (is_box) + if (is_box) { item->flag |= UI_ITEM_BOX_ITEM; + } } litem->h = litem->y - y; @@ -3272,11 +3273,13 @@ static void ui_item_layout(uiItem *item) } for (subitem = litem->items.first; subitem; subitem = subitem->next) { - if (item->flag & UI_ITEM_BOX_ITEM) + if (item->flag & UI_ITEM_BOX_ITEM) { subitem->flag |= UI_ITEM_BOX_ITEM; + } ui_item_layout(subitem); } - } else { + } + else { if (item->flag & UI_ITEM_BOX_ITEM) { uiButtonItem *bitem = (uiButtonItem *)item; bitem->but->drawflag |= UI_BUT_BOX_ITEM; -- cgit v1.2.3 From 920bff522483cf90a3963a69a2ef967bf0e94b43 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Thu, 27 Jul 2017 11:49:41 +0200 Subject: Fix button text overlapping with shortcut text in popups The purpose of the keymap strings is probably for un-embossed menu items like seen in most pulldowns. I can't see a reason for also adding that string for regularly drawn buttons within popups, we don't add it anywhere else in the UI either. So this commit makes sure shortcut strings are only added to buttons that are drawn like pulldown-menu items. --- source/blender/editors/interface/interface.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 2bf10c1c932..8ea5094998b 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1165,6 +1165,8 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) uiBut *but; char buf[128]; + BLI_assert(block->flag & UI_BLOCK_LOOP); + /* only do it before bounding */ if (block->rect.xmin != block->rect.xmax) return; @@ -1179,6 +1181,9 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) } else { for (but = block->buttons.first; but; but = but->next) { + if (but->dt != UI_EMBOSS_PULLDOWN) { + continue; + } if (ui_but_event_operator_string(C, but, buf, sizeof(buf))) { ui_but_add_shortcut(but, buf, false); -- cgit v1.2.3 From f1d6bad4b6f9f6ae429687f12ae67a175e9c183a Mon Sep 17 00:00:00 2001 From: Jeff Knox Date: Thu, 27 Jul 2017 12:55:17 +0200 Subject: Fix T51776: Make sure button icons are updated on Ctrl-ScrollWheel --- source/blender/editors/interface/interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 8ea5094998b..0dc7c6ccbec 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -684,7 +684,7 @@ static bool ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBu if (oldbut->active) { /* flags from the buttons we want to refresh, may want to add more here... */ - const int flag_copy = UI_BUT_REDALERT; + const int flag_copy = UI_BUT_REDALERT | UI_HAS_ICON; found_active = true; -- cgit v1.2.3 From 4003409430404c1be91d44460a770dfc9ce46135 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 27 Jul 2017 22:22:26 +1000 Subject: Fix factory setup using user scripts path still --- release/scripts/modules/bpy/utils/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/release/scripts/modules/bpy/utils/__init__.py b/release/scripts/modules/bpy/utils/__init__.py index 6d3e807c2b4..966a1fe877c 100644 --- a/release/scripts/modules/bpy/utils/__init__.py +++ b/release/scripts/modules/bpy/utils/__init__.py @@ -331,6 +331,10 @@ def script_paths(subdir=None, user_pref=True, check_all=False, use_user=True): # so the 'BLENDER_SYSTEM_SCRIPTS' environment variable will be used. base_paths = _bpy_script_paths() + # Defined to be (system, user) so we can skip the second if needed. + if not use_user: + base_paths = base_paths[:1] + if check_all: # All possible paths, no duplicates, keep order. if use_user: -- cgit v1.2.3 From 1bd9531fda793b108e0d6868d2e2df930aabfec2 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 27 Jul 2017 15:20:44 +0200 Subject: Fix UI messages... --- source/blender/makesrna/intern/rna_userdef.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 7a978c35810..80e0712aa07 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -3927,17 +3927,17 @@ static void rna_def_userdef_system(BlenderRNA *brna) prop = RNA_def_property(srna, "dpi", PROP_INT, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "DPI", - "DPI for addons to use when drawing custom user interface elements. Controlled by " - "operating system settings and Blender UI scale, with a reference value of 72 DPI. " - "Note that since this value includes a user defined scale, it is not always the " - "actual monitor DPI"); + "DPI for add-ons to use when drawing custom user interface elements, controlled by " + "operating system settings and Blender UI scale, with a reference value of 72 DPI " + "(note that since this value includes a user defined scale, it is not always the " + "actual monitor DPI)"); prop = RNA_def_property(srna, "pixel_size", PROP_FLOAT, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_float_sdna(prop, NULL, "pixelsize"); RNA_def_property_ui_text(prop, "Pixel Size", - "Suggested line thickness and point size in pixels, for addons drawing custom user " - "interface elements. Controlled by operating system settings and Blender UI scale"); + "Suggested line thickness and point size in pixels, for add-ons drawing custom user " + "interface elements, controlled by operating system settings and Blender UI scale"); prop = RNA_def_property(srna, "font_path_ui", PROP_STRING, PROP_FILEPATH); RNA_def_property_string_sdna(prop, NULL, "font_path_ui"); -- cgit v1.2.3 From c694f6e3fa9d6dc09203fba4b1ce5fd5e0973261 Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Thu, 27 Jul 2017 16:04:42 -0400 Subject: Cleanup: Remove gitignore for api images --- .gitignore | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.gitignore b/.gitignore index ed48c3faed4..3418afebb58 100644 --- a/.gitignore +++ b/.gitignore @@ -33,8 +33,3 @@ Desktop.ini /doc/python_api/sphinx-in/ /doc/python_api/sphinx-out/ /doc/python_api/rst/bmesh.ops.rst -/doc/python_api/rst/in_menu.png -/doc/python_api/rst/menu_id.png -/doc/python_api/rst/op_prop.png -/doc/python_api/rst/run_script.png -/doc/python_api/rst/spacebar.png -- cgit v1.2.3 From 304e5541cb6d2874ccca7871d6af295ea073c31a Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 28 Jul 2017 10:38:47 +0200 Subject: Fix T52208: Using UI_BUT_REDALERT flag for UI_BTYPE_KEY_EVENT buttons crashes Blender. but pointer was not assigned in that case... --- source/blender/editors/interface/interface_layout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 99868294a2e..b21dd8112b5 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -702,7 +702,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL); } else if (flag & UI_ITEM_R_EVENT) { - uiDefButR_prop(block, UI_BTYPE_KEY_EVENT, 0, name, x, y, w, h, ptr, prop, index, 0, 0, -1, -1, NULL); + but = uiDefButR_prop(block, UI_BTYPE_KEY_EVENT, 0, name, x, y, w, h, ptr, prop, index, 0, 0, -1, -1, NULL); } else if (flag & UI_ITEM_R_FULL_EVENT) { if (RNA_struct_is_a(ptr->type, &RNA_KeyMapItem)) { -- cgit v1.2.3 From 38eabcb858ac3b7bea90e212aa03019747589a65 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 28 Jul 2017 10:56:41 +0200 Subject: Fix potential 'divide-by-zero' in our UI fitting code. Reported by coverity, better fix even if highly unlikely to happen... --- source/blender/editors/interface/interface_layout.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index b21dd8112b5..c57faf97188 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -194,8 +194,9 @@ static const char *ui_item_name_add_colon(const char *name, char namestr[UI_MAX_ static int ui_item_fit(int item, int pos, int all, int available, bool is_last, int alignment, float *extra_pixel) { /* available == 0 is unlimited */ - if (available == 0) + if (ELEM(0, available, all)) { return item; + } if (all > available) { /* contents is bigger than available space */ @@ -218,8 +219,9 @@ static int ui_item_fit(int item, int pos, int all, int available, bool is_last, return (int)width; } } - else + else { return item; + } } } -- cgit v1.2.3 From d41acacc61a2ae43ce0537d06eb5b256533d08da Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 28 Jul 2017 11:55:24 +0200 Subject: Fix T52212: Vgroups doesn't work after Carve Boolean --- source/blender/modifiers/intern/MOD_boolean_util.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c index 061b1198f7e..49010664aa8 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.c +++ b/source/blender/modifiers/intern/MOD_boolean_util.c @@ -390,6 +390,9 @@ static void exporter_InitGeomArrays(ExportMeshData *export_data, * the operand. Data for those layers will not be allocated or initialized. */ + CustomData_merge(&dm_left->vertData, &dm->vertData, merge_mask, CD_DEFAULT, num_verts); + CustomData_merge(&dm_right->vertData, &dm->vertData, merge_mask, CD_DEFAULT, num_verts); + CustomData_merge(&dm_left->loopData, &dm->loopData, merge_mask, CD_DEFAULT, num_loops); CustomData_merge(&dm_right->loopData, &dm->loopData, merge_mask, CD_DEFAULT, num_loops); -- cgit v1.2.3 From 05f377805bec3b43a78b45662859d085c1c6e6a0 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 28 Jul 2017 12:43:06 +0200 Subject: Fix T52148: Point Density Texture ID User decrement error related to the Object field. Note that fix is not perfect, systematically make refcounting of all IDs assigned to node's id pointer, which breaks the 'do not refcount scene/object/text datablocks' principle... But besides that principle being far from ideal in general, it becomes pretty much impossible to apply when using //generic// ID pointer, unless we add some kind of type data to that pointer somehow. So for now, better to live with that, than having broken usercount. --- source/blender/makesrna/intern/rna_nodetree.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 10422c85579..77b42a5aeca 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -3339,7 +3339,7 @@ static void def_frame(StructRNA *srna) prop = RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "id"); RNA_def_property_struct_type(prop, "Text"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); RNA_def_property_ui_text(prop, "Text", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); @@ -3609,7 +3609,7 @@ static void def_sh_lamp(StructRNA *srna) prop = RNA_def_property(srna, "lamp_object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "id"); RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Lamp_object_poll"); RNA_def_property_ui_text(prop, "Lamp Object", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); @@ -3983,7 +3983,7 @@ static void def_sh_tex_coord(StructRNA *srna) prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "id"); RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); RNA_def_property_ui_text(prop, "Object", "Use coordinates from this object (for object texture coordinates output)"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); @@ -4099,7 +4099,7 @@ static void def_sh_tex_pointdensity(StructRNA *srna) prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "id"); RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); RNA_def_property_ui_text(prop, "Object", "Object to take point data from"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); @@ -4796,7 +4796,7 @@ static void def_cmp_render_layers(StructRNA *srna) RNA_def_property_pointer_sdna(prop, NULL, "id"); RNA_def_property_pointer_funcs(prop, NULL, "rna_Node_scene_set", NULL, NULL); RNA_def_property_struct_type(prop, "Scene"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); RNA_def_property_ui_text(prop, "Scene", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_scene_layer_update"); @@ -5453,7 +5453,7 @@ static void def_cmp_defocus(StructRNA *srna) RNA_def_property_pointer_sdna(prop, NULL, "id"); RNA_def_property_pointer_funcs(prop, NULL, "rna_Node_scene_set", NULL, NULL); RNA_def_property_struct_type(prop, "Scene"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT); RNA_def_property_ui_text(prop, "Scene", "Scene from which to select the active camera (render scene if undefined)"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); -- cgit v1.2.3 From 9b22dbcc0d05e465b7ba2fd353c48350d1a546a6 Mon Sep 17 00:00:00 2001 From: Luca Rood Date: Fri, 28 Jul 2017 15:24:48 +0200 Subject: Fix T52156: Hair dynamics broken with density texture Even strands that were excluded by the density texture were being added to the DM passed to cloth, but these ended up having some invalid data, because they were not fully constructed. This simply excludes `UNEXISTED` particles from the DM generation, as would be expected. --- source/blender/blenkernel/intern/particle_system.c | 144 +++++++++++---------- 1 file changed, 75 insertions(+), 69 deletions(-) diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index b61f6792c89..9ee456227e2 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3042,10 +3042,12 @@ static void hair_create_input_dm(ParticleSimulationData *sim, int totpoint, int /* calculate maximum segment length */ max_length = 0.0f; LOOP_PARTICLES { - for (k=1, key=pa->hair+1; ktotkey; k++,key++) { - float length = len_v3v3(key->co, (key-1)->co); - if (max_length < length) - max_length = length; + if (!(pa->flag & PARS_UNEXIST)) { + for (k=1, key=pa->hair+1; ktotkey; k++,key++) { + float length = len_v3v3(key->co, (key-1)->co); + if (max_length < length) + max_length = length; + } } } @@ -3057,76 +3059,78 @@ static void hair_create_input_dm(ParticleSimulationData *sim, int totpoint, int /* make vgroup for pin roots etc.. */ hair_index = 1; LOOP_PARTICLES { - float root_mat[4][4]; - float bending_stiffness; - bool use_hair; - - pa->hair_index = hair_index; - use_hair = psys_hair_use_simulation(pa, max_length); - - psys_mat_hair_to_object(sim->ob, sim->psmd->dm_final, psys->part->from, pa, hairmat); - mul_m4_m4m4(root_mat, sim->ob->obmat, hairmat); - normalize_m4(root_mat); - - bending_stiffness = CLAMPIS(1.0f - part->bending_random * psys_frand(psys, p + 666), 0.0f, 1.0f); - - for (k=0, key=pa->hair; ktotkey; k++,key++) { - ClothHairData *hair; - float *co, *co_next; - - co = key->co; - co_next = (key+1)->co; - - /* create fake root before actual root to resist bending */ - if (k==0) { - hair = &psys->clmd->hairdata[pa->hair_index - 1]; + if (!(pa->flag & PARS_UNEXIST)) { + float root_mat[4][4]; + float bending_stiffness; + bool use_hair; + + pa->hair_index = hair_index; + use_hair = psys_hair_use_simulation(pa, max_length); + + psys_mat_hair_to_object(sim->ob, sim->psmd->dm_final, psys->part->from, pa, hairmat); + mul_m4_m4m4(root_mat, sim->ob->obmat, hairmat); + normalize_m4(root_mat); + + bending_stiffness = CLAMPIS(1.0f - part->bending_random * psys_frand(psys, p + 666), 0.0f, 1.0f); + + for (k=0, key=pa->hair; ktotkey; k++,key++) { + ClothHairData *hair; + float *co, *co_next; + + co = key->co; + co_next = (key+1)->co; + + /* create fake root before actual root to resist bending */ + if (k==0) { + hair = &psys->clmd->hairdata[pa->hair_index - 1]; + copy_v3_v3(hair->loc, root_mat[3]); + copy_m3_m4(hair->rot, root_mat); + + hair->radius = hair_radius; + hair->bending_stiffness = bending_stiffness; + + add_v3_v3v3(mvert->co, co, co); + sub_v3_v3(mvert->co, co_next); + mul_m4_v3(hairmat, mvert->co); + + medge->v1 = pa->hair_index - 1; + medge->v2 = pa->hair_index; + + dvert = hair_set_pinning(dvert, 1.0f); + + mvert++; + medge++; + } + + /* store root transform in cloth data */ + hair = &psys->clmd->hairdata[pa->hair_index + k]; copy_v3_v3(hair->loc, root_mat[3]); copy_m3_m4(hair->rot, root_mat); - + hair->radius = hair_radius; hair->bending_stiffness = bending_stiffness; - - add_v3_v3v3(mvert->co, co, co); - sub_v3_v3(mvert->co, co_next); + + copy_v3_v3(mvert->co, co); mul_m4_v3(hairmat, mvert->co); - - medge->v1 = pa->hair_index - 1; - medge->v2 = pa->hair_index; - - dvert = hair_set_pinning(dvert, 1.0f); - + + if (k) { + medge->v1 = pa->hair_index + k - 1; + medge->v2 = pa->hair_index + k; + } + + /* roots and disabled hairs should be 1.0, the rest can be anything from 0.0 to 1.0 */ + if (use_hair) + dvert = hair_set_pinning(dvert, key->weight); + else + dvert = hair_set_pinning(dvert, 1.0f); + mvert++; - medge++; + if (k) + medge++; } - - /* store root transform in cloth data */ - hair = &psys->clmd->hairdata[pa->hair_index + k]; - copy_v3_v3(hair->loc, root_mat[3]); - copy_m3_m4(hair->rot, root_mat); - - hair->radius = hair_radius; - hair->bending_stiffness = bending_stiffness; - - copy_v3_v3(mvert->co, co); - mul_m4_v3(hairmat, mvert->co); - - if (k) { - medge->v1 = pa->hair_index + k - 1; - medge->v2 = pa->hair_index + k; - } - - /* roots and disabled hairs should be 1.0, the rest can be anything from 0.0 to 1.0 */ - if (use_hair) - dvert = hair_set_pinning(dvert, key->weight); - else - dvert = hair_set_pinning(dvert, 1.0f); - - mvert++; - if (k) - medge++; + + hair_index += pa->totkey + 1; } - - hair_index += pa->totkey + 1; } } @@ -3152,9 +3156,11 @@ static void do_hair_dynamics(ParticleSimulationData *sim) totpoint = 0; totedge = 0; LOOP_PARTICLES { - /* "out" dm contains all hairs */ - totedge += pa->totkey; - totpoint += pa->totkey + 1; /* +1 for virtual root point */ + if (!(pa->flag & PARS_UNEXIST)) { + /* "out" dm contains all hairs */ + totedge += pa->totkey; + totpoint += pa->totkey + 1; /* +1 for virtual root point */ + } } realloc_roots = false; /* whether hair root info array has to be reallocated */ -- cgit v1.2.3 From 2eb2655181b2d90457cb829d0ad285f193ad5e5c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 29 Jul 2017 01:28:58 +1000 Subject: Cleanup: clear deprecated UI flags Also adds cursor-lock flag, to be used in next commit. --- release/scripts/startup/bl_ui/space_userpref.py | 1 + source/blender/blenkernel/BKE_blender_version.h | 2 +- .../blenloader/intern/versioning_defaults.c | 3 + source/blender/editors/interface/resources.c | 18 ++++ source/blender/makesdna/DNA_userdef_types.h | 112 +++++++++++---------- source/blender/makesrna/intern/rna_userdef.c | 5 + 6 files changed, 86 insertions(+), 55 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 03a40085172..117b59d6d2f 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -249,6 +249,7 @@ class USERPREF_PT_interface(Panel): col = row.column() col.label(text="View Manipulation:") col.prop(view, "use_mouse_depth_cursor") + col.prop(view, "use_cursor_lock_adjust") col.prop(view, "use_mouse_depth_navigate") col.prop(view, "use_zoom_to_mouse") col.prop(view, "use_rotate_around_active") diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 207631d36bd..a5b2259d47e 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -28,7 +28,7 @@ * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 278 -#define BLENDER_SUBVERSION 5 +#define BLENDER_SUBVERSION 6 /* Several breakages with 270, e.g. constraint deg vs rad */ #define BLENDER_MINVERSION 270 #define BLENDER_MINSUBVERSION 6 diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index e7e0054e7a1..0ae8570846e 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -58,6 +58,9 @@ void BLO_update_defaults_userpref_blend(void) U.uiflag |= USER_QUIT_PROMPT; U.uiflag |= USER_CONTINUOUS_MOUSE; + /* See T45301 */ + U.uiflag |= USER_LOCK_CURSOR_ADJUST; + U.versions = 1; U.savetime = 2; diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 539284030c2..fdeafedc328 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -2758,6 +2758,24 @@ void init_userdef_do_versions(void) } } + if (!USER_VERSION_ATLEAST(278, 6)) { + /* Clear preference flags for re-use. */ + U.flag &= ~( + (1 << 1) | (1 << 2) | (1 << 3) | + (1 << 6) | (1 << 7) | + (1 << 9) | (1 << 10)); + U.uiflag &= ~( + (1 << 7)); + U.transopts &= ~( + (1 << 2) | (1 << 3) | (1 << 4) | + (1 << 7)); + U.gameflags &= ~( + (1 << 0) | (1 << 1) | + (1 << 3) | (1 << 4)); + + U.uiflag |= USER_LOCK_CURSOR_ADJUST; + } + /** * Include next version bump. * diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 5e7e7366e35..18b3ca4b325 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -48,7 +48,8 @@ struct ColorBand; #define MAX_STYLE_NAME 64 -/* default uifont_id offered by Blender */ +/* default offered by Blender. + * uiFont.uifont_id */ typedef enum eUIFont_ID { UIFONT_DEFAULT = 0, /* UIFONT_BITMAP = 1 */ /* UNUSED */ @@ -64,7 +65,7 @@ typedef struct uiFont { struct uiFont *next, *prev; char filename[1024];/* 1024 = FILE_MAX */ short blf_id; /* from blfont lib */ - short uifont_id; /* own id */ + short uifont_id; /* own id (eUIFont_ID) */ short r_to_l; /* fonts that read from left to right */ short hinting; } uiFont; @@ -84,7 +85,7 @@ typedef struct uiFontStyle { float shadowcolor; /* 1 value, typically white or black anyway */ } uiFontStyle; -/* uiFontStyle->align */ +/* uiFontStyle.align */ typedef enum eFontStyle_Align { UI_STYLE_TEXT_LEFT = 0, UI_STYLE_TEXT_CENTER = 1, @@ -354,11 +355,11 @@ typedef struct ThemeWireColor { char select[4]; char active[4]; - short flag; + short flag; /* eWireColor_Flags */ short pad; } ThemeWireColor; -/* flags for ThemeWireColor */ +/* ThemeWireColor.flag */ typedef enum eWireColor_Flags { TH_WIRECOLOR_CONSTCOLS = (1 << 0), TH_WIRECOLOR_TEXTCOLS = (1 << 1), @@ -434,7 +435,8 @@ typedef struct UserDef { /* UserDef has separate do-version handling, and can be read from other files */ int versionfile, subversionfile; - int flag, dupflag; + int flag; /* eUserPref_Flag */ + int dupflag; /* eDupli_ID_Flags */ int savetime; char tempdir[768]; /* FILE_MAXDIR length */ char fontdir[768]; @@ -450,14 +452,15 @@ typedef struct UserDef { int anim_player_preset; short v2d_min_gridsize; /* minimum spacing between gridlines in View2D grids */ - short timecode_style; /* style of timecode display */ + short timecode_style; /* eTimecodeStyles, style of timecode display */ short versions; short dbl_click_time; short gameflags; short wheellinescroll; - int uiflag, uiflag2; + int uiflag; /* eUserpref_UI_Flag */ + int uiflag2; /* eUserpref_UI_Flag2 */ int language; short userpref, viewzoom; @@ -473,7 +476,7 @@ typedef struct UserDef { int pad1; char node_margin; /* node insert offset (aka auto-offset) margin, but might be useful for later stuff as well */ char pad2; - short transopts; + short transopts; /* eUserpref_Translation_Flags */ short menuthreshold1, menuthreshold2; /* startup template */ @@ -491,12 +494,12 @@ typedef struct UserDef { short undosteps; short undomemory; short gp_manhattendist, gp_euclideandist, gp_eraser; - short gp_settings; + short gp_settings; /* eGP_UserdefSettings */ short tb_leftmouse, tb_rightmouse; struct SolidLight light[3]; short tw_hotspot, tw_flag, tw_handlesize, tw_size; short textimeout, texcollectrate; - short wmdrawmethod; /* removed wmpad */ + short wmdrawmethod; /* eWM_DrawMethod */ short dragthreshold; int memcachelimit; int prefetchframes; @@ -509,13 +512,13 @@ typedef struct UserDef { short smooth_viewtx; /* miliseconds to spend spinning the view */ short glreslimit; short curssize; - short color_picker_type; + short color_picker_type; /* eColorPicker_Types */ char ipo_new; /* interpolation mode for newly added F-Curves */ char keyhandles_new; /* handle types for newly added keyframes */ char gpu_select_method; char gpu_select_pick_deph; char pad4; - char view_frame_type; + char view_frame_type; /* eZoomFrame_Mode */ int view_frame_keyframes; /* number of keyframes to zoom around current frame */ float view_frame_seconds; /* seconds to zoom around current frame */ @@ -530,15 +533,16 @@ typedef struct UserDef { float ndof_sensitivity; /* overall sensitivity of 3D mouse */ float ndof_orbit_sensitivity; float ndof_deadzone; /* deadzone of 3D mouse */ - int ndof_flag; /* flags for 3D mouse */ + int ndof_flag; /* eNdof_Flag, flags for 3D mouse */ - short ogl_multisamples; /* amount of samples for OpenGL FSA, if zero no FSA */ + short ogl_multisamples; /* eMultiSample_Type, amount of samples for OpenGL FSA, if zero no FSA */ - short image_draw_method; /* Method to be used to draw the images (AUTO, GLSL, Textures or DrawPixels) */ + /* eImageDrawMethod, Method to be used to draw the images (AUTO, GLSL, Textures or DrawPixels) */ + short image_draw_method; float glalphaclip; - short autokey_mode; /* autokeying mode */ + short autokey_mode; /* eAutokey_Mode, autokeying mode */ short autokey_flag; /* flags for autokeying */ short text_render, pad9; /* options for text rendering */ @@ -582,7 +586,7 @@ extern UserDef U; /* from blenkernel blender.c */ /* ***************** USERDEF ****************** */ -/* userpref/section */ +/* UserDef.userpref (UI active_section) */ typedef enum eUserPref_Section { USER_SECTION_INTERFACE = 0, USER_SECTION_EDIT = 1, @@ -593,19 +597,15 @@ typedef enum eUserPref_Section { USER_SECTION_ADDONS = 6, } eUserPref_Section; -/* flag */ +/* UserDef.flag */ typedef enum eUserPref_Flag { USER_AUTOSAVE = (1 << 0), -/* USER_AUTOGRABGRID = (1 << 1), deprecated */ -/* USER_AUTOROTGRID = (1 << 2), deprecated */ -/* USER_AUTOSIZEGRID = (1 << 3), deprecated */ + /* 1..3 */ USER_SCENEGLOBAL = (1 << 4), USER_TRACKBALL = (1 << 5), -/* USER_DUPLILINK = (1 << 6), deprecated */ -/* USER_FSCOLLUM = (1 << 7), deprecated */ + /* 6..7 */ USER_MAT_ON_OB = (1 << 8), -/* USER_NO_CAPSLOCK = (1 << 9), */ /* not used anywhere */ -/* USER_VIEWMOVE = (1 << 10), */ /* not used anywhere */ + /* 9..10 */ USER_TOOLTIPS = (1 << 11), USER_TWOBUTTONMOUSE = (1 << 12), USER_NONUMPAD = (1 << 13), @@ -624,7 +624,7 @@ typedef enum eUserPref_Flag { USER_TOOLTIPS_PYTHON = (1 << 26), } eUserPref_Flag; -/* flag */ +/* bPathCompare.flag */ typedef enum ePathCompare_Flag { USER_PATHCMP_GLOB = (1 << 0), } ePathCompare_Flag; @@ -635,33 +635,34 @@ typedef enum ePathCompare_Flag { cfra = 0; \ } (void)0 -/* viewzoom */ +/* UserDef.viewzoom */ typedef enum eViewZoom_Style { USER_ZOOM_CONT = 0, USER_ZOOM_SCALE = 1, USER_ZOOM_DOLLY = 2 } eViewZoom_Style; -/* navigation_mode */ +/* UserDef.navigation_mode */ typedef enum eViewNavigation_Method { VIEW_NAVIGATION_WALK = 0, VIEW_NAVIGATION_FLY = 1, } eViewNavigation_Method; -/* flag */ +/* UserDef.flag */ typedef enum eWalkNavigation_Flag { USER_WALK_GRAVITY = (1 << 0), USER_WALK_MOUSE_REVERSE = (1 << 1), } eWalkNavigation_Flag; -/* uiflag */ +/* UserDef.uiflag */ typedef enum eUserpref_UI_Flag { /* flags 0 and 1 were old flags (for autokeying) that aren't used anymore */ USER_WHEELZOOMDIR = (1 << 2), USER_FILTERFILEEXTS = (1 << 3), USER_DRAWVIEWINFO = (1 << 4), USER_PLAINMENUS = (1 << 5), - /* flags 6 and 7 were old flags that are no-longer used */ + USER_LOCK_CURSOR_ADJUST = (1 << 6), + /* flag 7 is free */ USER_ALLWINCODECS = (1 << 8), USER_MENUOPENAUTO = (1 << 9), USER_ZBUF_CURSOR = (1 << 10), @@ -688,14 +689,15 @@ typedef enum eUserpref_UI_Flag { USER_HIDE_SYSTEM_BOOKMARKS = (1 << 31) } eUserpref_UI_Flag; -/* uiflag2 */ +/* UserDef.uiflag2 */ typedef enum eUserpref_UI_Flag2 { USER_KEEP_SESSION = (1 << 0), USER_REGION_OVERLAP = (1 << 1), USER_TRACKPAD_NATURAL = (1 << 2), } eUserpref_UI_Flag2; -/* Auto-Keying mode */ +/* Auto-Keying mode. + * UserDef.autokey_mode */ typedef enum eAutokey_Mode { /* AUTOKEY_ON is a bitflag */ AUTOKEY_ON = 1, @@ -705,7 +707,8 @@ typedef enum eAutokey_Mode { AUTOKEY_MODE_EDITKEYS = 5 } eAutokey_Mode; -/* Zoom to frame mode */ +/* Zoom to frame mode. + * UserDef.view_frame_type */ typedef enum eZoomFrame_Mode { ZOOM_FRAME_MODE_KEEP_RANGE = 0, ZOOM_FRAME_MODE_SECONDS = 1, @@ -728,20 +731,18 @@ typedef enum eAutokey_Flag { ANIMRECORD_FLAG_WITHNLA = (1 << 10), } eAutokey_Flag; -/* transopts */ +/* UserDef.transopts */ typedef enum eUserpref_Translation_Flags { USER_TR_TOOLTIPS = (1 << 0), USER_TR_IFACE = (1 << 1), -/* USER_TR_MENUS = (1 << 2), deprecated */ -/* USER_TR_FILESELECT = (1 << 3), deprecated */ -/* USER_TR_TEXTEDIT = (1 << 4), deprecated */ + /* 2..4 */ USER_DOTRANSLATE = (1 << 5), USER_USETEXTUREFONT = (1 << 6), -/* CONVERT_TO_UTF8 = (1 << 7), deprecated */ + /* 7 */ USER_TR_NEWDATANAME = (1 << 8), } eUserpref_Translation_Flags; -/* dupflag */ +/* UserDef.dupflag */ typedef enum eDupli_ID_Flags { USER_DUP_MESH = (1 << 0), USER_DUP_CURVE = (1 << 1), @@ -757,14 +758,9 @@ typedef enum eDupli_ID_Flags { USER_DUP_PSYS = (1 << 11) } eDupli_ID_Flags; -/* gameflags */ +/* UserDef.gameflags */ typedef enum eOpenGL_RenderingOptions { - /* USER_DEPRECATED_FLAG = (1 << 0), */ - /* USER_DISABLE_SOUND = (1 << 1), */ /* deprecated, don't use without checking for */ - /* backwards compatibilty in do_versions! */ USER_DISABLE_MIPMAP = (1 << 2), - /* USER_DISABLE_VBO = (1 << 3), */ /* DEPRECATED we always use vertex buffers now */ - /* USER_DISABLE_AA = (1 << 4), */ /* DEPRECATED */ } eOpenGL_RenderingOptions; /* selection method for opengl gpu_select_method */ @@ -774,7 +770,8 @@ typedef enum eOpenGL_SelectOptions { USER_SELECT_USE_SELECT_RENDERMODE = 2 } eOpenGL_SelectOptions; -/* wm draw method */ +/* wm draw method. + * UserDef.wmdrawmethod */ typedef enum eWM_DrawMethod { USER_DRAW_TRIPLE = 0, USER_DRAW_OVERLAP = 1, @@ -783,20 +780,23 @@ typedef enum eWM_DrawMethod { USER_DRAW_OVERLAP_FLIP = 4, } eWM_DrawMethod; -/* text draw options */ +/* text draw options + * UserDef.text_render */ typedef enum eText_Draw_Options { USER_TEXT_DISABLE_AA = (1 << 0), } eText_Draw_Options; /* tw_flag (transform widget) */ -/* gp_settings (Grease Pencil Settings) */ +/* Grease Pencil Settings. + * UserDef.gp_settings */ typedef enum eGP_UserdefSettings { GP_PAINT_DOSMOOTH = (1 << 0), GP_PAINT_DOSIMPLIFY = (1 << 1), } eGP_UserdefSettings; -/* color picker types */ +/* Color Picker Types. + * UserDef.color_picker_type */ typedef enum eColorPicker_Types { USER_CP_CIRCLE_HSV = 0, USER_CP_SQUARE_SV = 1, @@ -805,7 +805,8 @@ typedef enum eColorPicker_Types { USER_CP_CIRCLE_HSL = 4, } eColorPicker_Types; -/* timecode display styles */ +/* timecode display styles + * UserDef.timecode_style */ typedef enum eTimecodeStyles { /* as little info as is necessary to show relevant info * with '+' to denote the frames @@ -840,7 +841,7 @@ typedef enum eTheme_DrawTypes { TH_SHADED = 4 } eTheme_DrawTypes; -/* ndof_flag (3D mouse options) */ +/* UserDef.ndof_flag (3D mouse options) */ typedef enum eNdof_Flag { NDOF_SHOW_GUIDE = (1 << 0), NDOF_FLY_HELICOPTER = (1 << 1), @@ -873,6 +874,7 @@ typedef enum eNdof_Flag { #define NDOF_PIXELS_PER_SECOND 600.0f +/* UserDef.ogl_multisamples */ typedef enum eMultiSample_Type { USER_MULTISAMPLE_NONE = 0, USER_MULTISAMPLE_2 = 2, @@ -880,7 +882,8 @@ typedef enum eMultiSample_Type { USER_MULTISAMPLE_8 = 8, USER_MULTISAMPLE_16 = 16, } eMultiSample_Type; - + +/* UserDef.image_draw_method */ typedef enum eImageDrawMethod { /* IMAGE_DRAW_METHOD_AUTO = 0, */ /* Currently unused */ IMAGE_DRAW_METHOD_GLSL = 1, @@ -888,6 +891,7 @@ typedef enum eImageDrawMethod { IMAGE_DRAW_METHOD_DRAWPIXELS = 3, } eImageDrawMethod; +/* UserDef.virtual_pixel */ typedef enum eUserpref_VirtualPixel { VIRTUAL_PIXEL_NATIVE = 0, VIRTUAL_PIXEL_DOUBLE = 1, diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 80e0712aa07..4583a2ca2cc 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -3445,6 +3445,11 @@ static void rna_def_userdef_view(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Cursor Depth", "Use the depth under the mouse when placing the cursor"); + prop = RNA_def_property(srna, "use_cursor_lock_adjust", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_LOCK_CURSOR_ADJUST); + RNA_def_property_ui_text(prop, "Cursor Lock Adjust", + "Place the cursor without 'jumping' to the new location (when lock-to-cursor is used)"); + prop = RNA_def_property(srna, "use_camera_lock_parent", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "uiflag", USER_CAM_LOCK_NO_PARENT); RNA_def_property_ui_text(prop, "Camera Parent Lock", -- cgit v1.2.3 From e03883065042412347e7b72a4102532d7b1fc495 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 29 Jul 2017 01:35:07 +1000 Subject: Resolve T45301 by adding option for old behavior Some users really liked previous behavior, so making it an option. Cursor Lock Adjustment can be disabled to give something close to 2.4x behavior of cursor locking. When lock-adjustment is disabled placing the cursor the view. This avoids the issue reported in T40353 where the cursor could get *lost*. --- source/blender/editors/space_view3d/view3d_edit.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 4e3f279e12e..b2af2fe1d49 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -4753,13 +4753,20 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2]) ARegion *ar = CTX_wm_region(C); RegionView3D *rv3d = ar->regiondata; - float co_curr[2], co_prev[2]; + if (U.uiflag & USER_LOCK_CURSOR_ADJUST) { - if ((ED_view3d_project_float_global(ar, fp_prev, co_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) && - (ED_view3d_project_float_global(ar, fp_curr, co_curr, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)) - { - rv3d->ofs_lock[0] += (co_curr[0] - co_prev[0]) / (ar->winx * 0.5f); - rv3d->ofs_lock[1] += (co_curr[1] - co_prev[1]) / (ar->winy * 0.5f); + float co_curr[2], co_prev[2]; + + if ((ED_view3d_project_float_global(ar, fp_prev, co_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) && + (ED_view3d_project_float_global(ar, fp_curr, co_curr, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)) + { + rv3d->ofs_lock[0] += (co_curr[0] - co_prev[0]) / (ar->winx * 0.5f); + rv3d->ofs_lock[1] += (co_curr[1] - co_prev[1]) / (ar->winy * 0.5f); + } + } + else { + /* Cursor may be outside of the view, prevent it getting 'lost', see: T40353 & T45301 */ + zero_v2(rv3d->ofs_lock); } } -- cgit v1.2.3