diff options
author | Hans Goudey <h.goudey@me.com> | 2020-09-13 01:42:27 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-09-13 01:42:27 +0300 |
commit | 3eaca737531a917e60350bd74d52849b612831da (patch) | |
tree | 8950b659cbafcaa55e4ebfee64999a2fc382a606 /source/blender/editors | |
parent | 5545d833154e017f3948db9970b8d770ea8e8f9b (diff) | |
parent | 8f6740b2754ff1f5c936ee95e2cd7ed837627608 (diff) |
Merge branch 'property-search-single-tab' into property-search-start-end-operators
Diffstat (limited to 'source/blender/editors')
64 files changed, 484 insertions, 591 deletions
diff --git a/source/blender/editors/animation/CMakeLists.txt b/source/blender/editors/animation/CMakeLists.txt index ce6778a1ff9..1ca9a844feb 100644 --- a/source/blender/editors/animation/CMakeLists.txt +++ b/source/blender/editors/animation/CMakeLists.txt @@ -30,9 +30,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC anim_channels_defines.c @@ -69,6 +66,5 @@ if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_animation "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/armature/CMakeLists.txt b/source/blender/editors/armature/CMakeLists.txt index 71c7febe192..98c050950be 100644 --- a/source/blender/editors/armature/CMakeLists.txt +++ b/source/blender/editors/armature/CMakeLists.txt @@ -31,10 +31,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC armature_add.c armature_edit.c @@ -67,6 +63,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_armature "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/curve/CMakeLists.txt b/source/blender/editors/curve/CMakeLists.txt index ff80c47baa8..877c2d99102 100644 --- a/source/blender/editors/curve/CMakeLists.txt +++ b/source/blender/editors/curve/CMakeLists.txt @@ -31,10 +31,6 @@ set(INC ../../../../extern/curve_fit_nd ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC curve_ops.c editcurve.c @@ -59,6 +55,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_curve "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 2b3df79476a..e6815582a04 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -3640,9 +3640,8 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts) * degree of the functions used to build the NURB. The * expression * - * degree = #knots - #controlpoints + 1 (J Walter piece) - * degree = #knots - #controlpoints (Blender - * implementation) + * `degree = knots - controlpoints + 1` (J Walter piece) + * `degree = knots - controlpoints` (Blender implementation) * ( this is confusing.... what is true? Another concern * is that the JW piece allows the curve to become * explicitly 1st order derivative discontinuous, while @@ -3651,12 +3650,12 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts) * is an invariant for a single NURB curve. Raising the degree * of the NURB is done elsewhere; the degree is assumed * constant during this operation. Degree is a property shared - * by all controlpoints in a curve (even though it is stored + * by all control-points in a curve (even though it is stored * per control point - this can be misleading). * Adding a knot is done by searching for the place in the * knot vector where a certain knot value must be inserted, or * by picking an appropriate knot value between two existing - * ones. The number of controlpoints that is influenced by the + * ones. The number of control-points that is influenced by the * insertion depends on the order of the curve. A certain * minimum number of knots is needed to form high-order * curves, as can be seen from the equation above. In Blender, diff --git a/source/blender/editors/curve/editcurve_add.c b/source/blender/editors/curve/editcurve_add.c index 19b05f0af0c..4d72e90b89b 100644 --- a/source/blender/editors/curve/editcurve_add.c +++ b/source/blender/editors/curve/editcurve_add.c @@ -508,7 +508,10 @@ Nurb *ED_curve_add_nurbs_primitive( static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) { - Object *obedit = CTX_data_edit_object(C); + struct Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); ListBase *editnurb; Nurb *nu; bool newob = false; @@ -565,7 +568,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) /* userdef */ if (newob && !enter_editmode) { - ED_object_editmode_exit(C, EM_FREEDATA); + ED_object_editmode_exit_ex(bmain, scene, obedit, EM_FREEDATA); } WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); diff --git a/source/blender/editors/gizmo_library/CMakeLists.txt b/source/blender/editors/gizmo_library/CMakeLists.txt index 1f3edf31b19..eeb1e60166b 100644 --- a/source/blender/editors/gizmo_library/CMakeLists.txt +++ b/source/blender/editors/gizmo_library/CMakeLists.txt @@ -32,10 +32,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC gizmo_draw_utils.c gizmo_geometry.h @@ -59,6 +55,5 @@ set(SRC set(LIB ) -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_gizmo_library "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/gpencil/CMakeLists.txt b/source/blender/editors/gpencil/CMakeLists.txt index 735ad8bc039..20408327105 100644 --- a/source/blender/editors/gpencil/CMakeLists.txt +++ b/source/blender/editors/gpencil/CMakeLists.txt @@ -31,10 +31,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC annotate_draw.c annotate_paint.c @@ -75,6 +71,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_gpencil "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h index 47b8eb543f4..341f97943a5 100644 --- a/source/blender/editors/include/ED_fileselect.h +++ b/source/blender/editors/include/ED_fileselect.h @@ -150,6 +150,7 @@ int ED_file_extension_icon(const char *path); void ED_file_read_bookmarks(void); +void ED_file_change_dir_ex(struct bContext *C, struct bScreen *screen, struct ScrArea *area); void ED_file_change_dir(struct bContext *C); void ED_file_path_button(struct bScreen *screen, diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index ad9446f92c7..64b4a058ca2 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -2374,10 +2374,7 @@ uiPropertySplitWrapper uiItemPropertySplitWrapperCreate(uiLayout *parent_layout) void uiItemL(uiLayout *layout, const char *name, int icon); /* label */ void uiItemL_ex( uiLayout *layout, const char *name, int icon, const bool highlight, const bool redalert); -uiBut *uiItemL_respect_property_split(uiLayout *layout, - const char *text, - int icon, - uiLayout **r_layout); +uiLayout *uiItemL_respect_property_split(uiLayout *layout, const char *text, int icon); /* label icon for dragging */ void uiItemLDrag(uiLayout *layout, struct PointerRNA *ptr, const char *name, int icon); /* menu */ diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt index e4fb0631f06..680cf3ea01a 100644 --- a/source/blender/editors/interface/CMakeLists.txt +++ b/source/blender/editors/interface/CMakeLists.txt @@ -34,10 +34,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC interface.c interface_align.c @@ -113,6 +109,5 @@ if(WIN32) endif() endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_interface "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 8c564ecd1d4..b0530c797a8 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -6700,7 +6700,7 @@ static void operator_enum_search_update_fn(const struct bContext *C, } } - MEM_freeN(filtered_items); + MEM_freeN((void *)filtered_items); BLI_string_search_free(search); if (do_free) { diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index c91b4d826a7..d22ddb5f2b7 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -256,7 +256,7 @@ static void def_internal_vicon(int icon_id, VectorDrawFunc drawFunc) /* Utilities */ -static void viconutil_set_point(GLint pt[2], int x, int y) +static void viconutil_set_point(int pt[2], int x, int y) { pt[0] = x; pt[1] = y; @@ -264,7 +264,7 @@ static void viconutil_set_point(GLint pt[2], int x, int y) static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float alpha) { - GLint pts[3][2]; + int pts[3][2]; const int cx = x + w / 2 - 4; const int cy = y + w / 2; const int d = w / 5, d2 = w / 7; diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index a423f0705bb..ac5230c551a 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -275,14 +275,6 @@ struct uiBut { uiButPushedStateFunc pushed_state_func; void *pushed_state_arg; - /** - * Used for property search, so that a button's label and decorator can be filtered and - * unfiltered along with it. Due to the sometimes arbitrary nature of which button to choose - * for these values, they aren't always filled. - */ - uiBut *label_but; - uiBut *decorator_but; - /* pointer back */ uiBlock *block; }; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 613e91fc03a..59807dce8be 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -80,6 +80,17 @@ /* uiLayoutRoot */ +/** + * A group of button references, used by property search to keep track of sets of buttons that + * should be searched together. For example, in property split layouts number buttons and their + * labels (and even their decorators) are separate buttons, but they must be searched and + * highlighted together. + */ +typedef struct uiButtonGroup { + void *next, *prev; + ListBase buttons; /* #LinkData with #uiBut data field. */ +} uiButtonGroup; + typedef struct uiLayoutRoot { struct uiLayoutRoot *next, *prev; @@ -93,6 +104,8 @@ typedef struct uiLayoutRoot { */ bool search_only; + ListBase button_groups; /* #uiButtonGroup. */ + int emw, emh; int padding; @@ -227,8 +240,6 @@ typedef struct uiLayoutItemRoot { /** \} */ -static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon); - /* -------------------------------------------------------------------- */ /** \name Item * \{ */ @@ -424,6 +435,43 @@ static void ui_item_move(uiItem *item, int delta_xmin, int delta_xmax) /** \} */ /* -------------------------------------------------------------------- */ +/** \name Button Groups + * \{ */ + +/** + * Every function that adds a set of buttons must create another group, + * then #ui_def_but adds buttons to the current group (the last). + */ +static void layout_root_new_button_group(uiLayoutRoot *root) +{ + uiButtonGroup *new_group = MEM_mallocN(sizeof(uiButtonGroup), __func__); + BLI_listbase_clear(&new_group->buttons); + BLI_addtail(&root->button_groups, new_group); +} + +static void button_group_add_but(uiLayoutRoot *root, uiBut *but) +{ + BLI_assert(root != NULL); + + uiButtonGroup *current_button_group = root->button_groups.last; + BLI_assert(current_button_group != NULL); + + /* We can't use the button directly because adding it to + * this list would mess with its prev and next pointers. */ + LinkData *button_link = MEM_mallocN(sizeof(LinkData), __func__); + button_link->data = but; + BLI_addtail(¤t_button_group->buttons, button_link); +} + +static void button_group_free(uiButtonGroup *button_group) +{ + BLI_freelistN(&button_group->buttons); + MEM_freeN(button_group); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ /** \name Special RNA Items * \{ */ @@ -504,8 +552,7 @@ static void ui_item_array(uiLayout *layout, int toggle, bool icon_only, bool compact, - bool show_text, - uiBut *label_but) + bool show_text) { const uiStyle *style = layout->root->style; uiBut *but; @@ -670,10 +717,7 @@ static void ui_item_array(uiLayout *layout, /* special case, boolean array in a menu, this could be used in a more generic way too */ if (ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA) && !expand && ELEM(len, 3, 4)) { - but = uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, 0, 0, w, UI_UNIT_Y); - if (label_but != NULL) { - but->label_but = label_but; - } + uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, 0, 0, w, UI_UNIT_Y); } else { bool *boolarr = NULL; @@ -724,13 +768,6 @@ static void ui_item_array(uiLayout *layout, if ((a == 0) && (subtype == PROP_AXISANGLE)) { UI_but_unit_type_set(but, PROP_UNIT_ROTATION); } - - /* Set the label button for the array item. */ - if (label_but != NULL) { - but->label_but = label_but; - label_but = label_but->next; - BLI_assert(label_but != NULL); - } } if (boolarr) { @@ -773,8 +810,7 @@ static void ui_item_enum_expand_elem_exec(uiLayout *layout, const eButType but_type, const bool icon_only, const EnumPropertyItem *item, - const bool is_first, - uiBut *label_but) + const bool is_first) { const char *name = (!uiname || uiname[0]) ? item->name : ""; const int icon = item->icon; @@ -813,10 +849,6 @@ static void ui_item_enum_expand_elem_exec(uiLayout *layout, if (but_type == UI_BTYPE_TAB) { but->flag |= UI_BUT_DRAG_LOCK; } - - if (label_but != NULL) { - but->label_but = label_but; - } } static void ui_item_enum_expand_exec(uiLayout *layout, @@ -826,8 +858,7 @@ static void ui_item_enum_expand_exec(uiLayout *layout, const char *uiname, const int h, const eButType but_type, - const bool icon_only, - uiBut *label_but) + const bool icon_only) { /* XXX: The way this function currently handles uiname parameter * is insane and inconsistent with general UI API: @@ -903,7 +934,7 @@ static void ui_item_enum_expand_exec(uiLayout *layout, } ui_item_enum_expand_elem_exec( - layout, block, ptr, prop, uiname, h, but_type, icon_only, item, is_first, label_but); + layout, block, ptr, prop, uiname, h, but_type, icon_only, item, is_first); } UI_block_layout_set_current(block, layout); @@ -918,11 +949,9 @@ static void ui_item_enum_expand(uiLayout *layout, PropertyRNA *prop, const char *uiname, const int h, - const bool icon_only, - uiBut *label_but) + const bool icon_only) { - ui_item_enum_expand_exec( - layout, block, ptr, prop, uiname, h, UI_BTYPE_ROW, icon_only, label_but); + ui_item_enum_expand_exec(layout, block, ptr, prop, uiname, h, UI_BTYPE_ROW, icon_only); } static void ui_item_enum_expand_tabs(uiLayout *layout, bContext *C, @@ -935,7 +964,7 @@ static void ui_item_enum_expand_tabs(uiLayout *layout, { uiBut *last = block->buttons.last; - ui_item_enum_expand_exec(layout, block, ptr, prop, uiname, h, UI_BTYPE_TAB, icon_only, NULL); + ui_item_enum_expand_exec(layout, block, ptr, prop, uiname, h, UI_BTYPE_TAB, icon_only); BLI_assert(last != block->buttons.last); for (uiBut *tab = last ? last->next : block->buttons.first; tab; tab = tab->next) { UI_but_drawflag_enable(tab, ui_but_align_opposite_to_area_align_get(CTX_wm_region(C))); @@ -974,12 +1003,10 @@ static uiBut *ui_item_with_label(uiLayout *layout, { uiLayout *sub = layout; uiBut *but = NULL; - uiBut *label_but = NULL; PropertyType type; PropertySubType subtype; int prop_but_width = w_hint; #ifdef UI_PROP_DECORATE - uiBut *decorator_but = NULL; uiLayout *layout_prop_decorate = NULL; const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0); const bool use_prop_decorate = use_prop_sep && (layout->item.flag & UI_ITEM_PROP_DECORATE) && @@ -1000,7 +1027,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, #ifdef UI_PROP_DECORATE if (name[0]) { if (use_prop_sep) { - label_but = uiItemL_respect_property_split(layout, name, 0, &layout_prop_decorate); + layout_prop_decorate = uiItemL_respect_property_split(layout, name, 0); } else #endif @@ -1016,8 +1043,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, else { w_label = w_hint / 3; } - label_but = uiDefBut( - block, UI_BTYPE_LABEL, 0, name, x, y, w_label, h, NULL, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, UI_BTYPE_LABEL, 0, name, x, y, w_label, h, NULL, 0.0, 0.0, 0, 0, ""); } } @@ -1095,15 +1121,10 @@ static uiBut *ui_item_with_label(uiLayout *layout, #ifdef UI_PROP_DECORATE /* Only for alignment. */ if (use_prop_decorate) { /* Note that sep flag may have been unset meanwhile. */ - decorator_but = uiItemL_(layout_prop_decorate ? layout_prop_decorate : sub, NULL, ICON_BLANK1); + uiItemL(layout_prop_decorate ? layout_prop_decorate : sub, NULL, ICON_BLANK1); } #endif /* UI_PROP_DECORATE */ - /* Set the button's label and decorator even if they are NULL. They can be changed - * further with the return value of this function anyway. */ - but->label_but = label_but; - but->decorator_but = decorator_but; - UI_block_layout_set_current(block, layout); return but; } @@ -1942,34 +1963,28 @@ static uiLayout *ui_layout_heading_find(uiLayout *cur_layout) return NULL; } -/** - * \return The label button added. - */ -static uiBut *ui_layout_heading_label_add(uiLayout *layout, - uiLayout *heading_layout, - bool right_align, - bool respect_prop_split) +static void ui_layout_heading_label_add(uiLayout *layout, + uiLayout *heading_layout, + bool right_align, + bool respect_prop_split) { const int prev_alignment = layout->alignment; - uiBut *label_but = NULL; if (right_align) { uiLayoutSetAlignment(layout, UI_LAYOUT_ALIGN_RIGHT); } if (respect_prop_split) { - label_but = uiItemL_respect_property_split(layout, heading_layout->heading, ICON_NONE, NULL); + uiItemL_respect_property_split(layout, heading_layout->heading, ICON_NONE); } else { - label_but = uiItemL_(layout, heading_layout->heading, ICON_NONE); + uiItemL(layout, heading_layout->heading, ICON_NONE); } /* After adding the heading label, we have to mark it somehow as added, so it's not added again * for other items in this layout. For now just clear it. */ heading_layout->heading[0] = '\0'; layout->alignment = prev_alignment; - - return label_but; } /** @@ -2030,6 +2045,7 @@ void uiItemFullR(uiLayout *layout, #endif /* UI_PROP_DECORATE */ UI_block_layout_set_current(block, layout); + layout_root_new_button_group(layout->root); /* retrieve info */ const PropertyType type = RNA_property_type(prop); @@ -2151,10 +2167,6 @@ void uiItemFullR(uiLayout *layout, } uiBut *but = NULL; - /* Store the label to assign it to the button afterwards. This is the first - * label button if the item is an array and there are a series of buttons. - * Decorators are assigned as they are built later on. */ - uiBut *label_but = NULL; /* Split the label / property. */ uiLayout *layout_parent = layout; @@ -2174,7 +2186,7 @@ void uiItemFullR(uiLayout *layout, layout = uiLayoutColumn(layout_row ? layout_row : layout, true); layout->space = 0; if (heading_layout) { - label_but = ui_layout_heading_label_add(layout, heading_layout, false, false); + ui_layout_heading_label_add(layout, heading_layout, false, false); } } else { @@ -2201,43 +2213,39 @@ void uiItemFullR(uiLayout *layout, *s++ = str[0]; *s++ = '\0'; } - uiBut *new_label = uiDefBut(block, - UI_BTYPE_LABEL, - 0, - use_prefix ? name_with_suffix : str, - 0, - 0, - w, - UI_UNIT_Y, - NULL, - 0.0, - 0.0, - 0, - 0, - ""); - new_label->drawflag |= UI_BUT_TEXT_RIGHT; - new_label->drawflag &= ~UI_BUT_TEXT_LEFT; - - if (a == 0) { - label_but = new_label; - } + but = uiDefBut(block, + UI_BTYPE_LABEL, + 0, + use_prefix ? name_with_suffix : str, + 0, + 0, + w, + UI_UNIT_Y, + NULL, + 0.0, + 0.0, + 0, + 0, + ""); + but->drawflag |= UI_BUT_TEXT_RIGHT; + but->drawflag &= ~UI_BUT_TEXT_LEFT; + label_added = true; } } else { if (name) { - label_but = uiDefBut( + but = uiDefBut( block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); - label_but->drawflag |= UI_BUT_TEXT_RIGHT; - label_but->drawflag &= ~UI_BUT_TEXT_LEFT; + but->drawflag |= UI_BUT_TEXT_RIGHT; + but->drawflag &= ~UI_BUT_TEXT_LEFT; label_added = true; } } if (!label_added && heading_layout) { - label_but = ui_layout_heading_label_add(layout_sub, heading_layout, true, false); - label_added = true; + ui_layout_heading_label_add(layout_sub, heading_layout, true, false); } layout_split = ui_item_prop_split_layout_hack(layout_parent, layout_split); @@ -2280,7 +2288,7 @@ void uiItemFullR(uiLayout *layout, else if (heading_layout) { /* Could not add heading to split layout, fallback to inserting it to the layout with the * heading itself. */ - label_but = ui_layout_heading_label_add(heading_layout, heading_layout, false, false); + ui_layout_heading_label_add(heading_layout, heading_layout, false, false); } /* array property */ @@ -2307,29 +2315,26 @@ void uiItemFullR(uiLayout *layout, toggle, icon_only, compact, - !use_prop_sep_split_label, - label_but); + !use_prop_sep_split_label); } /* enum item */ else if (type == PROP_ENUM && index == RNA_ENUM_VALUE) { if (icon && name[0] && !icon_only) { - but = uiDefIconTextButR_prop( + uiDefIconTextButR_prop( block, UI_BTYPE_ROW, 0, icon, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); } else if (icon) { - but = uiDefIconButR_prop( + uiDefIconButR_prop( block, UI_BTYPE_ROW, 0, icon, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); } else { - but = uiDefButR_prop( + uiDefButR_prop( block, UI_BTYPE_ROW, 0, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); } - BLI_assert(but != NULL); - but->label_but = label_but; } /* expanded enum */ else if (type == PROP_ENUM && expand) { - ui_item_enum_expand(layout, block, ptr, prop, name, h, icon_only, label_but); + ui_item_enum_expand(layout, block, ptr, prop, name, h, icon_only); } /* property with separate label */ else if (type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) { @@ -2343,8 +2348,6 @@ void uiItemFullR(uiLayout *layout, if (layout->activate_init) { UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT); } - BLI_assert(but != NULL); - but->label_but = label_but; } /* single button */ else { @@ -2378,8 +2381,6 @@ void uiItemFullR(uiLayout *layout, if (layout->activate_init) { UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT); } - - but->label_but = label_but; } /* The resulting button may have the icon set since boolean button drawing @@ -2415,16 +2416,13 @@ void uiItemFullR(uiLayout *layout, /* The icons are set in 'ui_but_anim_flag' */ uiItemDecoratorR_prop(layout_col, ptr_dec, prop_dec, but_decorate->rnaindex); - uiBut *decorator = block->buttons.last; - but_decorate->decorator_but = decorator; + but = block->buttons.last; /* Order the decorator after the button we decorate, this is used so we can always * do a quick lookup. */ - BLI_remlink(&block->buttons, decorator); - BLI_insertlinkafter(&block->buttons, but_decorate, decorator); - - /* Assign decorator to the property's button so that they can be filtered together. */ - but_decorate = decorator->next; + BLI_remlink(&block->buttons, but); + BLI_insertlinkafter(&block->buttons, but_decorate, but); + but_decorate = but->next; } BLI_assert(ELEM(i, 1, ui_decorate.len)); @@ -2798,6 +2796,8 @@ void uiItemPointerR_prop(uiLayout *layout, char namestr[UI_MAX_NAME_STR]; const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0); + layout_root_new_button_group(layout->root); + type = RNA_property_type(prop); if (!ELEM(type, PROP_POINTER, PROP_STRING, PROP_ENUM)) { RNA_warning("Property %s.%s must be a pointer, string or enum", @@ -2903,6 +2903,7 @@ static uiBut *ui_item_menu(uiLayout *layout, int w, h; UI_block_layout_set_current(block, layout); + layout_root_new_button_group(layout->root); if (!name) { name = ""; @@ -3170,6 +3171,7 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon) int w; UI_block_layout_set_current(block, layout); + layout_root_new_button_group(layout->root); if (!name) { name = ""; @@ -3253,42 +3255,29 @@ uiPropertySplitWrapper uiItemPropertySplitWrapperCreate(uiLayout *parent_layout) return split_wrapper; } -/** +/* * Helper to add a label and creates a property split layout if needed. - * - * \param r_layout: Returns a column to put decorators in if property separate is on, otherwise - * returns the original layout. */ -uiBut *uiItemL_respect_property_split(uiLayout *layout, - const char *text, - int icon, - uiLayout **r_layout) +uiLayout *uiItemL_respect_property_split(uiLayout *layout, const char *text, int icon) { - uiBut *label_but; if (layout->item.flag & UI_ITEM_PROP_SEP) { uiBlock *block = uiLayoutGetBlock(layout); const uiPropertySplitWrapper split_wrapper = uiItemPropertySplitWrapperCreate(layout); /* Further items added to 'layout' will automatically be added to split_wrapper.property_row */ - label_but = uiItemL_(split_wrapper.label_column, text, icon); + uiItemL_(split_wrapper.label_column, text, icon); UI_block_layout_set_current(block, split_wrapper.property_row); - if (r_layout != NULL) { - *r_layout = split_wrapper.decorate_column; - } + return split_wrapper.decorate_column; } - else { - char namestr[UI_MAX_NAME_STR]; - if (text) { - text = ui_item_name_add_colon(text, namestr); - } - label_but = uiItemL_(layout, text, icon); - if (r_layout != NULL) { - *r_layout = layout; - } + char namestr[UI_MAX_NAME_STR]; + if (text) { + text = ui_item_name_add_colon(text, namestr); } - return label_but; + uiItemL_(layout, text, icon); + + return layout; } void uiItemLDrag(uiLayout *layout, PointerRNA *ptr, const char *name, int icon) @@ -5220,38 +5209,43 @@ static bool button_matches_search_filter(uiBut *but, const char *search_filter) } /** - * Apply the search filter, tagging all buttons with whether they match or not. + * Test for a search result within the a specific button group. */ -static bool block_search_filter_tag_buttons(uiBlock *block) +static bool button_group_has_search_match(uiButtonGroup *button_group, const char *search_filter) { - bool has_result = false; - LISTBASE_FOREACH (uiBut *, but, &block->buttons) { - /* First match regular buttons. */ - if (!ELEM(but->type, UI_BTYPE_LABEL) && - button_matches_search_filter(but, block->search_filter)) { - has_result = true; - but->flag |= UI_SEARCH_FILTER_MATCHES; - } - /* Then match their labels. */ - if (but->label_but != NULL && - button_matches_search_filter(but->label_but, block->search_filter)) { - has_result = true; - but->flag |= UI_SEARCH_FILTER_MATCHES; + LISTBASE_FOREACH (LinkData *, link, &button_group->buttons) { + uiBut *but = link->data; + if (button_matches_search_filter(but, search_filter)) { + return true; } } - /* Remove filter from labels and decorators that correspond to un-filtered buttons. */ - LISTBASE_FOREACH (uiBut *, but, &block->buttons) { - if (but->flag & UI_SEARCH_FILTER_MATCHES) { - if (but->label_but != NULL) { - but->label_but->flag |= UI_SEARCH_FILTER_MATCHES; - } - if (but->decorator_but != NULL) { - but->decorator_but->flag |= UI_SEARCH_FILTER_MATCHES; + return false; +} + +/** + * Apply the search filter, tagging all buttons with whether they match or not. + * Tag every button in the group as a search match if any button matches. + * + * \note It would be great to return early here if we found a match, but because + * the results could be visible we have to continue searching the entire block. + * + * \return Whether the block has any search results. + */ +static bool block_search_filter_tag_buttons(uiBlock *block) +{ + bool has_result = false; + LISTBASE_FOREACH (uiLayoutRoot *, root, &block->layouts) { + LISTBASE_FOREACH (uiButtonGroup *, button_group, &root->button_groups) { + if (button_group_has_search_match(button_group, block->search_filter)) { + LISTBASE_FOREACH (LinkData *, link, &button_group->buttons) { + uiBut *but = link->data; + but->flag |= UI_SEARCH_FILTER_MATCHES; + } + has_result = true; } } } - return has_result; } @@ -5534,6 +5528,16 @@ static void ui_layout_free(uiLayout *layout) MEM_freeN(layout); } +static void layout_root_free(uiLayoutRoot *root) +{ + ui_layout_free(root->layout); + + LISTBASE_FOREACH_MUTABLE (uiButtonGroup *, button_group, &root->button_groups) { + button_group_free(button_group); + } + MEM_freeN(root); +} + static void ui_layout_add_padding_button(uiLayoutRoot *root) { if (root->padding) { @@ -5568,6 +5572,9 @@ uiLayout *UI_block_layout(uiBlock *block, root->padding = padding; root->opcontext = WM_OP_INVOKE_REGION_WIN; + BLI_listbase_clear(&root->button_groups); + layout_root_new_button_group(root); + layout = MEM_callocN(sizeof(uiLayout), "uiLayout"); layout->item.type = (type == UI_LAYOUT_VERT_BAR) ? ITEM_LAYOUT_COLUMN : ITEM_LAYOUT_ROOT; @@ -5652,6 +5659,8 @@ void ui_layout_add_but(uiLayout *layout, uiBut *but) if (layout->emboss != UI_EMBOSS_UNDEFINED) { but->emboss = layout->emboss; } + + button_group_add_but(layout->root, but); } bool ui_layout_replace_but_ptr(uiLayout *layout, const void *old_but_ptr, uiBut *new_but) @@ -5717,7 +5726,7 @@ void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y) block->curlayout = NULL; - LISTBASE_FOREACH (uiLayoutRoot *, root, &block->layouts) { + LISTBASE_FOREACH_MUTABLE (uiLayoutRoot *, root, &block->layouts) { /* Seach only roots should be removed by #UI_block_apply_search_filter. */ BLI_assert(!root->search_only); @@ -5725,10 +5734,10 @@ void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y) /* NULL in advance so we don't interfere when adding button */ ui_layout_end(block, root->layout, r_x, r_y); - ui_layout_free(root->layout); + layout_root_free(root); } - BLI_freelistN(&block->layouts); + BLI_listbase_clear(&block->layouts); /* XXX silly trick, interface_templates.c doesn't get linked * because it's not used by other files in this module? */ diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 9141a46499e..77a9d9f549a 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -897,7 +897,7 @@ static void template_ID(const bContext *C, if (text) { /* Add label resepecting the separated layout property split state. */ - uiItemL_respect_property_split(layout, text, ICON_NONE, NULL); + uiItemL_respect_property_split(layout, text, ICON_NONE); } if (flag & UI_ID_BROWSE) { diff --git a/source/blender/editors/mask/CMakeLists.txt b/source/blender/editors/mask/CMakeLists.txt index 66c055d9426..dd04732a814 100644 --- a/source/blender/editors/mask/CMakeLists.txt +++ b/source/blender/editors/mask/CMakeLists.txt @@ -30,10 +30,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC mask_add.c mask_draw.c @@ -51,6 +47,5 @@ set(SRC set(LIB ) -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_mask "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt index 589b51ce942..035af772a55 100644 --- a/source/blender/editors/mesh/CMakeLists.txt +++ b/source/blender/editors/mesh/CMakeLists.txt @@ -35,10 +35,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC editface.c editmesh_add.c @@ -97,6 +93,5 @@ if(WITH_GMP) add_definitions(-DWITH_GMP) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_mesh "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index 3c426e5d2b1..b7bf6230f22 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -104,7 +104,7 @@ static void make_prim_finish(bContext *C, /* userdef */ if (exit_editmode) { - ED_object_editmode_exit(C, EM_FREEDATA); + ED_object_editmode_exit_ex(CTX_data_main(C), CTX_data_scene(C), obedit, EM_FREEDATA); } WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); } diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index 953ef8114f9..be6c0658b1f 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -39,10 +39,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC object_add.c object_bake.c @@ -81,7 +77,6 @@ set(LIB bf_windowmanager ) -add_definitions(${GL_DEFINITIONS}) if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 4de48fba494..fa1d147dc5e 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -529,9 +529,12 @@ Object *ED_object_add_type_with_obdata(bContext *C, ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob; - /* for as long scene has editmode... */ - if (CTX_data_edit_object(C)) { - ED_object_editmode_exit(C, EM_FREEDATA); + /* For as long scene has editmode... */ + { + Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); + if (obedit != NULL) { + ED_object_editmode_exit_ex(bmain, scene, obedit, EM_FREEDATA); + } } /* deselects all, sets active object */ @@ -778,18 +781,20 @@ static int effector_add_exec(bContext *C, wmOperator *op) dia = RNA_float_get(op->ptr, "radius"); if (type == PFIELD_GUIDE) { + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); Curve *cu; ob = ED_object_add_type( C, OB_CURVE, get_effector_defname(type), loc, rot, false, local_view_bits); cu = ob->data; cu->flag |= CU_PATH | CU_3D; - ED_object_editmode_enter(C, 0); + ED_object_editmode_enter_ex(bmain, scene, ob, 0); ED_object_new_primitive_matrix(C, ob, loc, rot, mat); BLI_addtail(&cu->editnurb->nurbs, ED_curve_add_nurbs_primitive(C, ob, mat, CU_NURBS | CU_PRIM_PATH, dia)); if (!enter_editmode) { - ED_object_editmode_exit(C, EM_FREEDATA); + ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA); } } else { @@ -900,7 +905,10 @@ void OBJECT_OT_camera_add(wmOperatorType *ot) static int object_metaball_add_exec(bContext *C, wmOperator *op) { - Object *obedit = CTX_data_edit_object(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); bool newob = false; bool enter_editmode; ushort local_view_bits; @@ -931,7 +939,7 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) /* userdef */ if (newob && !enter_editmode) { - ED_object_editmode_exit(C, EM_FREEDATA); + ED_object_editmode_exit_ex(bmain, scene, obedit, EM_FREEDATA); } WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); @@ -1017,7 +1025,11 @@ void OBJECT_OT_text_add(wmOperatorType *ot) static int object_armature_add_exec(bContext *C, wmOperator *op) { - Object *obedit = CTX_data_edit_object(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); + RegionView3D *rv3d = CTX_wm_region_view3d(C); bool newob = false; bool enter_editmode; @@ -1032,7 +1044,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) } if ((obedit == NULL) || (obedit->type != OB_ARMATURE)) { obedit = ED_object_add_type(C, OB_ARMATURE, NULL, loc, rot, true, local_view_bits); - ED_object_editmode_enter(C, 0); + ED_object_editmode_enter_ex(bmain, scene, obedit, 0); newob = true; } else { @@ -1049,7 +1061,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) /* userdef */ if (newob && !enter_editmode) { - ED_object_editmode_exit(C, EM_FREEDATA); + ED_object_editmode_exit_ex(bmain, scene, obedit, EM_FREEDATA); } WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 8b10a865a68..85522209e29 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -80,8 +80,10 @@ /** \name Constraint Data Accessors * \{ */ -/* If object is in posemode, return active bone constraints, else object constraints. No - * constraints are returned for a bone on an inactive bonelayer. */ +/** + * If object is in pose-mode, return active bone constraints, else object constraints. + * No constraints are returned for a bone on an inactive bone-layer. + */ ListBase *ED_object_constraint_active_list(Object *ob) { if (ob == NULL) { @@ -103,8 +105,10 @@ ListBase *ED_object_constraint_active_list(Object *ob) return NULL; } -/* Get the constraints for the active pose bone. Bone may be on an inactive bonelayer (unlike - * ED_object_constraint_active_list, such constraints are not excluded here). */ +/** + * Get the constraints for the active pose bone. Bone may be on an inactive bone-layer + * (unlike #ED_object_constraint_active_list, such constraints are not excluded here). + */ ListBase *ED_object_pose_constraint_list(const bContext *C) { bPoseChannel *pose_bone = CTX_data_pointer_get(C, "active_pose_bone").data; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 966aeed75ab..7e0df736228 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -769,14 +769,14 @@ bool ED_object_editmode_enter(bContext *C, int flag) static int editmode_toggle_exec(bContext *C, wmOperator *op) { - struct wmMsgBus *mbus = CTX_wm_message_bus(C); - const int mode_flag = OB_MODE_EDIT; - const bool is_mode_set = (CTX_data_edit_object(C) != NULL); Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); + ViewLayer *view_layer = CTX_data_view_layer(C); Object *obact = OBACT(view_layer); + const int mode_flag = OB_MODE_EDIT; + const bool is_mode_set = (obact->mode & mode_flag) != 0; + struct wmMsgBus *mbus = CTX_wm_message_bus(C); if (!is_mode_set) { if (!ED_object_mode_compat_set(C, obact, mode_flag, op->reports)) { @@ -785,7 +785,7 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op) } if (!is_mode_set) { - ED_object_editmode_enter(C, 0); + ED_object_editmode_enter_ex(bmain, scene, obact, 0); if (obact->mode & mode_flag) { FOREACH_SELECTED_OBJECT_BEGIN (view_layer, v3d, ob) { if ((ob != obact) && (ob->type == obact->type)) { @@ -796,7 +796,8 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op) } } else { - ED_object_editmode_exit(C, EM_FREEDATA); + ED_object_editmode_exit_ex(bmain, scene, obact, EM_FREEDATA); + if ((obact->mode & mode_flag) == 0) { FOREACH_OBJECT_BEGIN (view_layer, ob) { if ((ob != obact) && (ob->type == obact->type)) { @@ -859,6 +860,9 @@ void OBJECT_OT_editmode_toggle(wmOperatorType *ot) static int posemode_exec(bContext *C, wmOperator *op) { struct wmMsgBus *mbus = CTX_wm_message_bus(C); + struct Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); Base *base = CTX_data_active_base(C); /* If the base is NULL it means we have an active object, but the object itself is hidden. */ @@ -880,16 +884,17 @@ static int posemode_exec(bContext *C, wmOperator *op) return OPERATOR_PASS_THROUGH; } - if (obact == CTX_data_edit_object(C)) { - ED_object_editmode_exit(C, EM_FREEDATA); - is_mode_set = false; + { + Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); + if (obact == obedit) { + ED_object_editmode_exit_ex(bmain, scene, obedit, EM_FREEDATA); + is_mode_set = false; + } } if (is_mode_set) { bool ok = ED_object_posemode_exit(C, obact); if (ok) { - struct Main *bmain = CTX_data_main(C); - ViewLayer *view_layer = CTX_data_view_layer(C); FOREACH_OBJECT_BEGIN (view_layer, ob) { if ((ob != obact) && (ob->type == OB_ARMATURE) && (ob->mode & mode_flag)) { ED_object_posemode_exit_ex(bmain, ob); @@ -901,9 +906,7 @@ static int posemode_exec(bContext *C, wmOperator *op) else { bool ok = ED_object_posemode_enter(C, obact); if (ok) { - struct Main *bmain = CTX_data_main(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - View3D *v3d = CTX_wm_view3d(C); + const View3D *v3d = CTX_wm_view3d(C); FOREACH_SELECTED_OBJECT_BEGIN (view_layer, v3d, ob) { if ((ob != obact) && (ob->type == OB_ARMATURE) && (ob->mode == OB_MODE_OBJECT) && (!ID_IS_LINKED(ob))) { diff --git a/source/blender/editors/physics/CMakeLists.txt b/source/blender/editors/physics/CMakeLists.txt index 0998280c381..2b9d9aaa0e1 100644 --- a/source/blender/editors/physics/CMakeLists.txt +++ b/source/blender/editors/physics/CMakeLists.txt @@ -30,10 +30,6 @@ set(INC ../../../../intern/mantaflow/extern ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC dynamicpaint_ops.c particle_boids.c @@ -74,6 +70,5 @@ if(WITH_BULLET) add_definitions(-DWITH_BULLET) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_physics "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/render/CMakeLists.txt b/source/blender/editors/render/CMakeLists.txt index 7f7748bf52f..642e92592f1 100644 --- a/source/blender/editors/render/CMakeLists.txt +++ b/source/blender/editors/render/CMakeLists.txt @@ -34,10 +34,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC render_internal.c render_opengl.c @@ -61,7 +57,6 @@ else() ) endif() -add_definitions(${GL_DEFINITIONS}) if(WITH_FREESTYLE) list(APPEND INC diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 25b4ddc15fd..509097c7a70 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -604,6 +604,7 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec ED_draw_imbuf_method(ibuf) != IMAGE_DRAW_METHOD_GLSL) { image_buffer_rect_update(rj, rr, ibuf, &rj->iuser, renrect, viewname); } + ima->gpuflag |= IMA_GPU_REFRESH; /* make jobs timer to send notifier */ *(rj->do_update) = true; diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt index dc355148ad3..1de5ad729c5 100644 --- a/source/blender/editors/screen/CMakeLists.txt +++ b/source/blender/editors/screen/CMakeLists.txt @@ -33,10 +33,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC area.c area_query.c @@ -64,6 +60,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_screen "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index 51cfb912722..930f9890dd9 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -36,10 +36,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC paint_cursor.c paint_curve.c @@ -90,6 +86,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_sculpt_paint "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 3d8c718c8a9..55abb269660 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -142,7 +142,7 @@ typedef struct LoadTexData { ViewContext *vc; MTex *mtex; - GLubyte *buffer; + uchar *buffer; bool col; struct ImagePool *pool; @@ -160,7 +160,7 @@ static void load_tex_task_cb_ex(void *__restrict userdata, ViewContext *vc = data->vc; MTex *mtex = data->mtex; - GLubyte *buffer = data->buffer; + uchar *buffer = data->buffer; const bool col = data->col; struct ImagePool *pool = data->pool; @@ -230,7 +230,7 @@ static void load_tex_task_cb_ex(void *__restrict userdata, /* Clamp to avoid precision overflow. */ CLAMP(avg, 0.0f, 1.0f); - buffer[index] = 255 - (GLubyte)(255 * avg); + buffer[index] = 255 - (uchar)(255 * avg); } } else { @@ -254,7 +254,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima MTex *mtex = (primary) ? &br->mtex : &br->mask_mtex; ePaintOverlayControlFlags overlay_flags = BKE_paint_get_overlay_flags(); - GLubyte *buffer = NULL; + uchar *buffer = NULL; int size; bool refresh; @@ -309,10 +309,10 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima target->old_col = col; } if (col) { - buffer = MEM_mallocN(sizeof(GLubyte) * size * size * 4, "load_tex"); + buffer = MEM_mallocN(sizeof(uchar) * size * size * 4, "load_tex"); } else { - buffer = MEM_mallocN(sizeof(GLubyte) * size * size, "load_tex"); + buffer = MEM_mallocN(sizeof(uchar) * size * size, "load_tex"); } pool = BKE_image_pool_new(); @@ -381,7 +381,7 @@ static void load_tex_cursor_task_cb(void *__restrict userdata, LoadTexData *data = userdata; Brush *br = data->br; - GLubyte *buffer = data->buffer; + uchar *buffer = data->buffer; const int size = data->size; @@ -398,7 +398,7 @@ static void load_tex_cursor_task_cb(void *__restrict userdata, /* Falloff curve. */ float avg = BKE_brush_curve_strength_clamped(br, len, 1.0f); - buffer[index] = (GLubyte)(255 * avg); + buffer[index] = (uchar)(255 * avg); } else { buffer[index] = 0; @@ -411,7 +411,7 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) bool init; ePaintOverlayControlFlags overlay_flags = BKE_paint_get_overlay_flags(); - GLubyte *buffer = NULL; + uchar *buffer = NULL; int size; const bool refresh = !cursor_snap.overlay_texture || @@ -452,7 +452,7 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) cursor_snap.size = size; } - buffer = MEM_mallocN(sizeof(GLubyte) * size * size, "load_tex"); + buffer = MEM_mallocN(sizeof(uchar) * size * size, "load_tex"); BKE_curvemapping_init(br->curve); diff --git a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c index f07d22ed639..9b4b5b8d1e2 100644 --- a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c +++ b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c @@ -36,6 +36,7 @@ #include "BKE_brush.h" #include "BKE_context.h" +#include "BKE_global.h" #include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_mesh_mapping.h" @@ -58,6 +59,7 @@ #include "ED_object.h" #include "ED_screen.h" #include "ED_sculpt.h" +#include "ED_undo.h" #include "ED_view3d.h" #include "paint_intern.h" #include "sculpt_intern.h" @@ -285,11 +287,17 @@ void sculpt_dynamic_topology_disable_with_undo(Main *bmain, Object *ob) { SculptSession *ss = ob->sculpt; - if (ss->bm) { - SCULPT_undo_push_begin("Dynamic topology disable"); - SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_END); + if (ss->bm != NULL) { + /* May be false in background mode. */ + const bool use_undo = G.background ? (ED_undo_stack_get() != NULL) : true; + if (use_undo) { + SCULPT_undo_push_begin("Dynamic topology disable"); + SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_END); + } SCULPT_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, NULL); - SCULPT_undo_push_end(); + if (use_undo) { + SCULPT_undo_push_end(); + } } } @@ -300,10 +308,16 @@ static void sculpt_dynamic_topology_enable_with_undo(Main *bmain, { SculptSession *ss = ob->sculpt; if (ss->bm == NULL) { - SCULPT_undo_push_begin("Dynamic topology enable"); + /* May be false in background mode. */ + const bool use_undo = G.background ? (ED_undo_stack_get() != NULL) : true; + if (use_undo) { + SCULPT_undo_push_begin("Dynamic topology enable"); + } SCULPT_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob); - SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN); - SCULPT_undo_push_end(); + if (use_undo) { + SCULPT_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN); + SCULPT_undo_push_end(); + } } } diff --git a/source/blender/editors/space_action/CMakeLists.txt b/source/blender/editors/space_action/CMakeLists.txt index 6c43f8b9549..10dcc77fc24 100644 --- a/source/blender/editors/space_action/CMakeLists.txt +++ b/source/blender/editors/space_action/CMakeLists.txt @@ -28,10 +28,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC action_buttons.c action_data.c @@ -49,6 +45,5 @@ set(LIB bf_blenlib ) -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_action "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_api/CMakeLists.txt b/source/blender/editors/space_api/CMakeLists.txt index d948d84f1c3..573afb76f0e 100644 --- a/source/blender/editors/space_api/CMakeLists.txt +++ b/source/blender/editors/space_api/CMakeLists.txt @@ -20,6 +20,7 @@ set(INC ../io ../../blenkernel ../../blenlib + ../../gpu ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 29ad314cd65..2a18ffafc6c 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -33,6 +33,8 @@ #include "BKE_context.h" #include "BKE_screen.h" +#include "GPU_state.h" + #include "UI_interface.h" #include "UI_view2d.h" @@ -269,12 +271,18 @@ void ED_region_draw_cb_exit(ARegionType *art, void *handle) void ED_region_draw_cb_draw(const bContext *C, ARegion *region, int type) { RegionDrawCB *rdc; + bool has_drawn_something = false; for (rdc = region->type->drawcalls.first; rdc; rdc = rdc->next) { if (rdc->type == type) { rdc->draw(C, region, rdc->customdata); + has_drawn_something = true; } } + if (has_drawn_something) { + /* This is needed until we get rid of BGL which can change the states we are tracking. */ + GPU_force_state(); + } } /* ********************* space template *********************** */ diff --git a/source/blender/editors/space_buttons/CMakeLists.txt b/source/blender/editors/space_buttons/CMakeLists.txt index 75d91174470..ce0787dbdb9 100644 --- a/source/blender/editors/space_buttons/CMakeLists.txt +++ b/source/blender/editors/space_buttons/CMakeLists.txt @@ -28,10 +28,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC buttons_context.c buttons_ops.c @@ -48,7 +44,6 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) diff --git a/source/blender/editors/space_clip/CMakeLists.txt b/source/blender/editors/space_clip/CMakeLists.txt index 2ea4bc97d18..8c7f59d61dd 100644 --- a/source/blender/editors/space_clip/CMakeLists.txt +++ b/source/blender/editors/space_clip/CMakeLists.txt @@ -33,10 +33,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC clip_buttons.c clip_dopesheet_draw.c @@ -68,7 +64,6 @@ set(LIB bf_blenlib ) -add_definitions(${GL_DEFINITIONS}) if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) diff --git a/source/blender/editors/space_console/CMakeLists.txt b/source/blender/editors/space_console/CMakeLists.txt index 33934832ccc..e5aedd0d0de 100644 --- a/source/blender/editors/space_console/CMakeLists.txt +++ b/source/blender/editors/space_console/CMakeLists.txt @@ -28,10 +28,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC console_draw.c console_ops.c @@ -49,6 +45,5 @@ if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_console "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_file/CMakeLists.txt b/source/blender/editors/space_file/CMakeLists.txt index 84df11ea39c..dcacf5e2504 100644 --- a/source/blender/editors/space_file/CMakeLists.txt +++ b/source/blender/editors/space_file/CMakeLists.txt @@ -33,10 +33,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC file_draw.c file_ops.c @@ -95,7 +91,6 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h index 44131693628..b459c02d9e5 100644 --- a/source/blender/editors/space_file/file_intern.h +++ b/source/blender/editors/space_file/file_intern.h @@ -39,6 +39,7 @@ struct View2D; void file_calc_previews(const bContext *C, ARegion *region); void file_draw_list(const bContext *C, ARegion *region); +void file_draw_check_ex(bContext *C, struct ScrArea *area); void file_draw_check(bContext *C); void file_draw_check_cb(bContext *C, void *arg1, void *arg2); bool file_draw_check_exists(SpaceFile *sfile); @@ -80,13 +81,13 @@ void file_filename_enter_handle(bContext *C, void *arg_unused, void *arg_but); int file_highlight_set(struct SpaceFile *sfile, struct ARegion *region, int mx, int my); void file_sfile_filepath_set(struct SpaceFile *sfile, const char *filepath); -void file_sfile_to_operator_ex(bContext *C, +void file_sfile_to_operator_ex(struct Main *bmain, struct wmOperator *op, struct SpaceFile *sfile, char *filepath); -void file_sfile_to_operator(bContext *C, struct wmOperator *op, struct SpaceFile *sfile); +void file_sfile_to_operator(struct Main *bmain, struct wmOperator *op, struct SpaceFile *sfile); -void file_operator_to_sfile(bContext *C, struct SpaceFile *sfile, struct wmOperator *op); +void file_operator_to_sfile(struct Main *bmain, struct SpaceFile *sfile, struct wmOperator *op); /* filesel.c */ void fileselect_file_set(SpaceFile *sfile, const int index); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 8c4b2a1b8a6..b3587fc7f97 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -1432,9 +1432,8 @@ void FILE_OT_cancel(struct wmOperatorType *ot) /** \name Operator Utilities * \{ */ -void file_sfile_to_operator_ex(bContext *C, wmOperator *op, SpaceFile *sfile, char *filepath) +void file_sfile_to_operator_ex(Main *bmain, wmOperator *op, SpaceFile *sfile, char *filepath) { - Main *bmain = CTX_data_main(C); PropertyRNA *prop; /* XXX, not real length */ @@ -1507,16 +1506,15 @@ void file_sfile_to_operator_ex(bContext *C, wmOperator *op, SpaceFile *sfile, ch } } } -void file_sfile_to_operator(bContext *C, wmOperator *op, SpaceFile *sfile) +void file_sfile_to_operator(Main *bmain, wmOperator *op, SpaceFile *sfile) { - char filepath[FILE_MAX]; + char filepath_dummy[FILE_MAX]; - file_sfile_to_operator_ex(C, op, sfile, filepath); + file_sfile_to_operator_ex(bmain, op, sfile, filepath_dummy); } -void file_operator_to_sfile(bContext *C, SpaceFile *sfile, wmOperator *op) +void file_operator_to_sfile(Main *bmain, SpaceFile *sfile, wmOperator *op) { - Main *bmain = CTX_data_main(C); PropertyRNA *prop; /* If neither of the above are set, split the filepath back */ @@ -1569,25 +1567,37 @@ void file_sfile_filepath_set(SpaceFile *sfile, const char *filepath) } } -void file_draw_check(bContext *C) +void file_draw_check_ex(bContext *C, ScrArea *area) { - SpaceFile *sfile = CTX_wm_space_file(C); + /* May happen when manipulating non-active spaces. */ + if (UNLIKELY(area->spacetype != SPACE_FILE)) { + return; + } + SpaceFile *sfile = area->spacedata.first; wmOperator *op = sfile->op; if (op) { /* fail on reload */ if (op->type->check) { - file_sfile_to_operator(C, op, sfile); + Main *bmain = CTX_data_main(C); + file_sfile_to_operator(bmain, op, sfile); /* redraw */ if (op->type->check(C, op)) { - file_operator_to_sfile(C, sfile, op); + file_operator_to_sfile(bmain, sfile, op); /* redraw, else the changed settings wont get updated */ - ED_area_tag_redraw(CTX_wm_area(C)); + ED_area_tag_redraw(area); } } } } +void file_draw_check(bContext *C) +{ + SpaceFile *sfile = CTX_wm_space_file(C); + ScrArea *area = CTX_wm_area(C); + file_draw_check_ex(C, area); +} + /* for use with; UI_block_func_set */ void file_draw_check_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) { @@ -1675,7 +1685,7 @@ static int file_exec(bContext *C, wmOperator *exec_op) sfile->op = NULL; - file_sfile_to_operator_ex(C, op, sfile, filepath); + file_sfile_to_operator_ex(bmain, op, sfile, filepath); if (BLI_exists(sfile->params->dir)) { fsmenu_insert_entry(ED_fsmenu_get(), @@ -2091,6 +2101,7 @@ void FILE_OT_smoothscroll(wmOperatorType *ot) static int filepath_drop_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); SpaceFile *sfile = CTX_wm_space_file(C); if (sfile) { @@ -2105,7 +2116,7 @@ static int filepath_drop_exec(bContext *C, wmOperator *op) file_sfile_filepath_set(sfile, filepath); if (sfile->op) { - file_sfile_to_operator(C, sfile->op, sfile); + file_sfile_to_operator(bmain, sfile->op, sfile); file_draw_check(C); } diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 306d6cba50e..9fc4e8936f4 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -828,13 +828,23 @@ FileLayout *ED_fileselect_get_layout(struct SpaceFile *sfile, ARegion *region) return sfile->layout; } -void ED_file_change_dir(bContext *C) +/** + * Support updating the directory even when this isn't the active space + * needed so RNA properties update function isn't context sensitive, see T70255. + */ +void ED_file_change_dir_ex(bContext *C, bScreen *screen, ScrArea *area) { - wmWindowManager *wm = CTX_wm_manager(C); - SpaceFile *sfile = CTX_wm_space_file(C); - + /* May happen when manipulating non-active spaces. */ + if (UNLIKELY(area->spacetype != SPACE_FILE)) { + return; + } + SpaceFile *sfile = area->spacedata.first; if (sfile->params) { - ED_fileselect_clear(wm, CTX_data_scene(C), sfile); + wmWindowManager *wm = CTX_wm_manager(C); + Scene *scene = WM_windows_scene_get_from_screen(wm, screen); + if (LIKELY(scene != NULL)) { + ED_fileselect_clear(wm, scene, sfile); + } /* Clear search string, it is very rare to want to keep that filter while changing dir, * and usually very annoying to keep it actually! */ @@ -853,10 +863,17 @@ void ED_file_change_dir(bContext *C) folderlist_pushdir(sfile->folders_prev, sfile->params->dir); - file_draw_check(C); + file_draw_check_ex(C, area); } } +void ED_file_change_dir(bContext *C) +{ + bScreen *screen = CTX_wm_screen(C); + ScrArea *area = CTX_wm_area(C); + ED_file_change_dir_ex(C, screen, area); +} + int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matched_file) { int match = 0; diff --git a/source/blender/editors/space_graph/CMakeLists.txt b/source/blender/editors/space_graph/CMakeLists.txt index 8170c920990..fd5c5863608 100644 --- a/source/blender/editors/space_graph/CMakeLists.txt +++ b/source/blender/editors/space_graph/CMakeLists.txt @@ -29,10 +29,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC graph_buttons.c graph_draw.c @@ -67,6 +63,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_graph "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index ba3ed620ff1..47f910402fe 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -423,7 +423,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel) col = uiLayoutColumn(layout, true); /* keyframe itself */ { - uiItemL_respect_property_split(col, IFACE_("Key Frame"), ICON_NONE, NULL); + uiItemL_respect_property_split(col, IFACE_("Key Frame"), ICON_NONE); but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, @@ -441,7 +441,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel) 0, NULL); - uiItemL_respect_property_split(col, IFACE_("Value"), ICON_NONE, NULL); + uiItemL_respect_property_split(col, IFACE_("Value"), ICON_NONE); but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, @@ -468,7 +468,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel) if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ)) { col = uiLayoutColumn(layout, true); - uiItemL_respect_property_split(col, IFACE_("Left Handle Type"), ICON_NONE, NULL); + uiItemL_respect_property_split(col, IFACE_("Left Handle Type"), ICON_NONE); but = uiDefButR(block, UI_BTYPE_MENU, B_REDR, @@ -487,7 +487,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel) "Type of left handle"); UI_but_func_set(but, graphedit_activekey_handles_cb, fcu, bezt); - uiItemL_respect_property_split(col, IFACE_("Frame"), ICON_NONE, NULL); + uiItemL_respect_property_split(col, IFACE_("Frame"), ICON_NONE); but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, @@ -506,7 +506,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel) NULL); UI_but_func_set(but, graphedit_activekey_left_handle_coord_cb, fcu, bezt); - uiItemL_respect_property_split(col, IFACE_("Value"), ICON_NONE, NULL); + uiItemL_respect_property_split(col, IFACE_("Value"), ICON_NONE); but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, @@ -532,7 +532,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel) /* NOTE: special update callbacks are needed on the coords here due to T39911 */ col = uiLayoutColumn(layout, true); - uiItemL_respect_property_split(col, IFACE_("Right Handle Type"), ICON_NONE, NULL); + uiItemL_respect_property_split(col, IFACE_("Right Handle Type"), ICON_NONE); but = uiDefButR(block, UI_BTYPE_MENU, B_REDR, @@ -551,7 +551,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel) "Type of right handle"); UI_but_func_set(but, graphedit_activekey_handles_cb, fcu, bezt); - uiItemL_respect_property_split(col, IFACE_("Frame"), ICON_NONE, NULL); + uiItemL_respect_property_split(col, IFACE_("Frame"), ICON_NONE); but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, @@ -570,7 +570,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel) NULL); UI_but_func_set(but, graphedit_activekey_right_handle_coord_cb, fcu, bezt); - uiItemL_respect_property_split(col, IFACE_("Value"), ICON_NONE, NULL); + uiItemL_respect_property_split(col, IFACE_("Value"), ICON_NONE); but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt index 24ec7a89397..96aab8b5d1a 100644 --- a/source/blender/editors/space_image/CMakeLists.txt +++ b/source/blender/editors/space_image/CMakeLists.txt @@ -35,10 +35,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC image_buttons.c image_draw.c @@ -81,6 +77,5 @@ if(WITH_IMAGE_CINEON) add_definitions(-DWITH_CINEON) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_image "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 058436a46bf..60dd134646d 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -55,6 +55,7 @@ #include "BIF_glutil.h" +#include "GPU_framebuffer.h" #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" @@ -570,7 +571,8 @@ static void draw_image_buffer(const bContext *C, float zoomy) { /* Image are still drawn in display space. */ - glDisable(GL_FRAMEBUFFER_SRGB); + GPUFrameBuffer *fb = GPU_framebuffer_active_get(); + GPU_framebuffer_bind_no_srgb(fb); int x, y; int sima_flag = sima->flag & ED_space_image_get_display_channel_mask(ibuf); @@ -660,7 +662,7 @@ static void draw_image_buffer(const bContext *C, } } - glEnable(GL_FRAMEBUFFER_SRGB); + GPU_framebuffer_bind(fb); } static void draw_image_buffer_repeated(const bContext *C, @@ -865,7 +867,7 @@ void draw_image_main(const bContext *C, ARegion *region) Image *ima; ImBuf *ibuf; float zoomx, zoomy; - bool show_viewer, show_render, show_paint, show_stereo3d, show_multilayer; + bool show_viewer, show_stereo3d, show_multilayer; void *lock; /* XXX can we do this in refresh? */ @@ -898,9 +900,6 @@ void draw_image_main(const bContext *C, ARegion *region) } show_viewer = (ima && ima->source == IMA_SRC_VIEWER) != 0; - show_render = (show_viewer && ima->type == IMA_TYPE_R_RESULT) != 0; - show_paint = (ima && (sima->mode == SI_MODE_PAINT) && (show_viewer == false) && - (show_render == false)); show_stereo3d = (ima && BKE_image_is_stereo(ima) && (sima->iuser.flag & IMA_SHOW_STEREO)); show_multilayer = ima && BKE_image_is_multilayer(ima); @@ -998,16 +997,32 @@ void draw_image_main(const bContext *C, ARegion *region) } draw_udim_tile_grids(region, sima, ima); - - /* paint helpers */ - if (show_paint) { - draw_image_paint_helpers(C, region, scene, zoomx, zoomy); - } + draw_image_main_helpers(C, region); if (show_viewer) { BLI_thread_unlock(LOCK_DRAW_IMAGE); } +} + +void draw_image_main_helpers(const bContext *C, ARegion *region) +{ + SpaceImage *sima = CTX_wm_space_image(C); + Scene *scene = CTX_data_scene(C); + Image *ima; + float zoomx, zoomy; + bool show_viewer, show_render, show_paint; + ima = ED_space_image(sima); + ED_space_image_get_zoom(sima, region, &zoomx, &zoomy); + + show_viewer = (ima && ima->source == IMA_SRC_VIEWER) != 0; + show_render = (show_viewer && ima->type == IMA_TYPE_R_RESULT) != 0; + show_paint = (ima && (sima->mode == SI_MODE_PAINT) && (show_viewer == false) && + (show_render == false)); + /* paint helpers */ + if (show_paint) { + draw_image_paint_helpers(C, region, scene, zoomx, zoomy); + } /* render info */ if (ima && show_render) { draw_render_info(C, sima->iuser.scene, ima, region, zoomx, zoomy); diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h index e6f5988aed8..100556ad29a 100644 --- a/source/blender/editors/space_image/image_intern.h +++ b/source/blender/editors/space_image/image_intern.h @@ -37,6 +37,7 @@ extern const char *image_context_dir[]; /* doc access */ /* image_draw.c */ void draw_image_main(const struct bContext *C, struct ARegion *region); +void draw_image_main_helpers(const struct bContext *C, struct ARegion *region); void draw_image_cache(const struct bContext *C, struct ARegion *region); void draw_image_grease_pencil(struct bContext *C, bool onlyv2d); void draw_image_sample_line(struct SpaceImage *sima); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index aa3f6446d51..f1becd5f027 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -76,6 +76,7 @@ #include "GPU_framebuffer.h" #include "GPU_viewport.h" +#include "DRW_engine.h" #include "DRW_engine_types.h" #include "image_intern.h" @@ -638,8 +639,6 @@ static void image_main_region_draw(const bContext *C, ARegion *region) Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); View2D *v2d = ®ion->v2d; - // View2DScrollers *scrollers; - float col[3]; GPUViewport *viewport = WM_draw_region_get_viewport(region); GPUFrameBuffer *framebuffer_default, *framebuffer_overlay; @@ -647,35 +646,14 @@ static void image_main_region_draw(const bContext *C, ARegion *region) framebuffer_default = GPU_viewport_framebuffer_default_get(viewport); framebuffer_overlay = GPU_viewport_framebuffer_overlay_get(viewport); - GPU_framebuffer_bind(framebuffer_default); - GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f); - - GPU_framebuffer_bind(framebuffer_overlay); - /* XXX not supported yet, disabling for now */ scene->r.scemode &= ~R_COMP_CROP; - /* clear and setup matrix */ - UI_GetThemeColor3fv(TH_BACK, col); - srgb_to_linearrgb_v3_v3(col, col); - GPU_clear_color(col[0], col[1], col[2], 1.0f); - GPU_depth_test(GPU_DEPTH_NONE); - image_user_refresh_scene(C, sima); /* we set view2d from own zoom and offset each time */ image_main_region_set_view2d(sima, region); - /* we draw image in pixelspace */ - draw_image_main(C, region); - - /* and uvs in 0.0-1.0 space */ - UI_view2d_view_ortho(v2d); - - ED_region_draw_cb_draw(C, region, REGION_DRAW_PRE_VIEW); - - ED_uvedit_draw_main(sima, scene, view_layer, obedit, obact, depsgraph); - /* check for mask (delay draw) */ if (ED_space_image_show_uvedit(sima, obedit)) { show_uvedit = true; @@ -687,21 +665,52 @@ static void image_main_region_draw(const bContext *C, ARegion *region) show_curve = true; } - ED_region_draw_cb_draw(C, region, REGION_DRAW_POST_VIEW); + /* we draw image in pixelspace */ + if (!U.experimental.use_image_editor_legacy_drawing) { + DRW_draw_view(C); + draw_image_main_helpers(C, region); - if (sima->flag & SI_SHOW_GPENCIL) { - /* Grease Pencil too (in addition to UV's) */ - draw_image_grease_pencil((bContext *)C, true); + /* sample line */ + UI_view2d_view_ortho(v2d); + draw_image_sample_line(sima); + UI_view2d_view_restore(C); } + else { + GPU_framebuffer_bind(framebuffer_default); + GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f); + + GPU_framebuffer_bind(framebuffer_overlay); + + float col[3]; + /* clear and setup matrix */ + UI_GetThemeColor3fv(TH_BACK, col); + srgb_to_linearrgb_v3_v3(col, col); + GPU_clear_color(col[0], col[1], col[2], 1.0f); + GPU_depth_test(GPU_DEPTH_NONE); + draw_image_main(C, region); + + /* and uvs in 0.0-1.0 space */ + UI_view2d_view_ortho(v2d); + + ED_region_draw_cb_draw(C, region, REGION_DRAW_PRE_VIEW); - /* sample line */ - draw_image_sample_line(sima); + ED_uvedit_draw_main(sima, scene, view_layer, obedit, obact, depsgraph); - UI_view2d_view_restore(C); + ED_region_draw_cb_draw(C, region, REGION_DRAW_POST_VIEW); - if (sima->flag & SI_SHOW_GPENCIL) { - /* draw Grease Pencil - screen space only */ - draw_image_grease_pencil((bContext *)C, false); + if (sima->flag & SI_SHOW_GPENCIL) { + /* Grease Pencil too (in addition to UV's) */ + draw_image_grease_pencil((bContext *)C, true); + } + /* sample line */ + draw_image_sample_line(sima); + + UI_view2d_view_restore(C); + + if (sima->flag & SI_SHOW_GPENCIL) { + /* draw Grease Pencil - screen space only */ + draw_image_grease_pencil((bContext *)C, false); + } } if (mask) { @@ -741,7 +750,7 @@ static void image_main_region_draw(const bContext *C, ARegion *region) C); } - if (show_uvedit || mask || show_curve) { + if ((show_uvedit || mask || show_curve) && U.experimental.use_image_editor_legacy_drawing) { UI_view2d_view_ortho(v2d); ED_image_draw_cursor(region, sima->cursor); UI_view2d_view_restore(C); diff --git a/source/blender/editors/space_info/CMakeLists.txt b/source/blender/editors/space_info/CMakeLists.txt index ad410e0aade..b6df07eec4e 100644 --- a/source/blender/editors/space_info/CMakeLists.txt +++ b/source/blender/editors/space_info/CMakeLists.txt @@ -33,10 +33,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) - set(SRC info_draw.c info_ops.c @@ -56,6 +52,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_info "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_nla/CMakeLists.txt b/source/blender/editors/space_nla/CMakeLists.txt index 60152bffaf4..9a94d28c604 100644 --- a/source/blender/editors/space_nla/CMakeLists.txt +++ b/source/blender/editors/space_nla/CMakeLists.txt @@ -29,9 +29,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC nla_buttons.c @@ -54,6 +51,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_nla "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_node/CMakeLists.txt b/source/blender/editors/space_node/CMakeLists.txt index f8c30f9a688..fc831bf8490 100644 --- a/source/blender/editors/space_node/CMakeLists.txt +++ b/source/blender/editors/space_node/CMakeLists.txt @@ -34,9 +34,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC drawnode.c @@ -75,6 +72,5 @@ if(WITH_OPENIMAGEDENOISE) add_definitions(-DWITH_OPENIMAGEDENOISE) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_node "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt index 616915dbc2c..db38839f959 100644 --- a/source/blender/editors/space_outliner/CMakeLists.txt +++ b/source/blender/editors/space_outliner/CMakeLists.txt @@ -30,9 +30,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC outliner_collections.c @@ -60,6 +57,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_outliner "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_script/CMakeLists.txt b/source/blender/editors/space_script/CMakeLists.txt index 0bd2a01a151..f2dd39ea13d 100644 --- a/source/blender/editors/space_script/CMakeLists.txt +++ b/source/blender/editors/space_script/CMakeLists.txt @@ -27,9 +27,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC script_edit.c @@ -49,6 +46,5 @@ if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_script "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt index 8105891e157..caf75349454 100644 --- a/source/blender/editors/space_sequencer/CMakeLists.txt +++ b/source/blender/editors/space_sequencer/CMakeLists.txt @@ -32,9 +32,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC sequencer_add.c @@ -73,6 +70,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_sequencer "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_statusbar/CMakeLists.txt b/source/blender/editors/space_statusbar/CMakeLists.txt index ad4c060a1f6..a0f3afecaf9 100644 --- a/source/blender/editors/space_statusbar/CMakeLists.txt +++ b/source/blender/editors/space_statusbar/CMakeLists.txt @@ -29,9 +29,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC space_statusbar.c @@ -42,6 +39,5 @@ set(LIB bf_blenlib ) -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_statusbar "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_text/CMakeLists.txt b/source/blender/editors/space_text/CMakeLists.txt index 740fc9948ef..abd7620ea2b 100644 --- a/source/blender/editors/space_text/CMakeLists.txt +++ b/source/blender/editors/space_text/CMakeLists.txt @@ -29,9 +29,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC space_text.c @@ -56,7 +53,6 @@ set(LIB bf_blenlib ) -add_definitions(${GL_DEFINITIONS}) if(WITH_PYTHON) list(APPEND INC diff --git a/source/blender/editors/space_topbar/CMakeLists.txt b/source/blender/editors/space_topbar/CMakeLists.txt index d56e1da334d..15e71e2296d 100644 --- a/source/blender/editors/space_topbar/CMakeLists.txt +++ b/source/blender/editors/space_topbar/CMakeLists.txt @@ -29,9 +29,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC space_topbar.c @@ -40,6 +37,5 @@ set(SRC set(LIB ) -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_space_topbar "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt index f2536cfac62..f4d6f7e322c 100644 --- a/source/blender/editors/space_view3d/CMakeLists.txt +++ b/source/blender/editors/space_view3d/CMakeLists.txt @@ -38,9 +38,6 @@ set(INC ${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC drawobject.c @@ -85,7 +82,6 @@ if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() -add_definitions(${GL_DEFINITIONS}) if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index f3300f21628..0b5daece556 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1065,7 +1065,7 @@ static void draw_rotation_guide(const RegionView3D *rv3d) float o[3]; /* center of rotation */ float end[3]; /* endpoints for drawing */ - GLubyte color[4] = {0, 108, 255, 255}; /* bright blue so it matches device LEDs */ + uchar color[4] = {0, 108, 255, 255}; /* bright blue so it matches device LEDs */ negate_v3_v3(o, rv3d->ofs); diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt index b284ba0af2d..f905e96dbdd 100644 --- a/source/blender/editors/transform/CMakeLists.txt +++ b/source/blender/editors/transform/CMakeLists.txt @@ -33,9 +33,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC transform.c @@ -125,6 +122,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_transform "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 84eac3bbf8f..0eaae7f17cd 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -163,41 +163,6 @@ void constraintNumInput(TransInfo *t, float vec[3]) } } -static void postConstraintChecks(TransInfo *t, float vec[3]) -{ - mul_m3_v3(t->spacemtx_inv, vec); - - transform_snap_increment(t, vec); - - if (t->flag & T_NULL_ONE) { - if (!(t->con.mode & CON_AXIS0)) { - vec[0] = 1.0f; - } - - if (!(t->con.mode & CON_AXIS1)) { - vec[1] = 1.0f; - } - - if (!(t->con.mode & CON_AXIS2)) { - vec[2] = 1.0f; - } - } - - if (applyNumInput(&t->num, vec)) { - constraintNumInput(t, vec); - removeAspectRatio(t, vec); - } - - /* If `t->values` is operator param, use that directly but not if snapping is forced */ - if (t->flag & T_INPUT_IS_VALUES_FINAL && (t->tsnap.status & SNAP_FORCED) == 0) { - copy_v3_v3(vec, t->values); - constraintValuesFinal(t, vec); - /* inverse transformation at the end */ - } - - mul_m3_v3(t->spacemtx, vec); -} - static void viewAxisCorrectCenter(const TransInfo *t, float t_con_center[3]) { if (t->spacetype == SPACE_VIEW3D) { @@ -432,15 +397,22 @@ static void applyAxisConstraintVec( { copy_v3_v3(out, in); if (!td && t->con.mode & CON_APPLY) { + bool is_snap_to_point = false, is_snap_to_edge = false, is_snap_to_face = false; mul_m3_v3(t->con.pmtx, out); - bool is_snap_to_edge = false, is_snap_to_face = false; + if (activeSnap(t)) { - is_snap_to_edge = (t->tsnap.snapElem & SCE_SNAP_MODE_EDGE) != 0; - is_snap_to_face = (t->tsnap.snapElem & SCE_SNAP_MODE_FACE) != 0; + if (validSnap(t)) { + is_snap_to_point = (t->tsnap.snapElem & SCE_SNAP_MODE_VERTEX) != 0; + is_snap_to_edge = (t->tsnap.snapElem & SCE_SNAP_MODE_EDGE) != 0; + is_snap_to_face = (t->tsnap.snapElem & SCE_SNAP_MODE_FACE) != 0; + } + else if (t->tsnap.snapElem & SCE_SNAP_MODE_GRID) { + is_snap_to_point = true; + } } /* With snap points, a projection is alright, no adjustments needed. */ - if (!validSnap(t) || is_snap_to_edge || is_snap_to_face) { + if (!is_snap_to_point || is_snap_to_edge || is_snap_to_face) { const int dims = getConstraintSpaceDimension(t); if (dims == 2) { if (!is_zero_v3(out)) { @@ -486,7 +458,6 @@ static void applyAxisConstraintVec( } } } - postConstraintChecks(t, out); } } diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c index 7ad54a56545..06ab60d992c 100644 --- a/source/blender/editors/transform/transform_convert_mesh.c +++ b/source/blender/editors/transform/transform_convert_mesh.c @@ -1296,6 +1296,9 @@ void mesh_customdatacorrect_init(TransInfo *t) use_merge_group = (t->settings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT_KEEP_CONNECTED) != 0; } } + else { + return; + } FOREACH_TRANS_DATA_CONTAINER (t, tc) { mesh_customdatacorrect_init_container(tc, use_merge_group); diff --git a/source/blender/editors/transform/transform_mode_edge_seq_slide.c b/source/blender/editors/transform/transform_mode_edge_seq_slide.c index 141f9acdeb4..d2474d78387 100644 --- a/source/blender/editors/transform/transform_mode_edge_seq_slide.c +++ b/source/blender/editors/transform/transform_mode_edge_seq_slide.c @@ -93,22 +93,29 @@ static void applySeqSlideValue(TransInfo *t, const float val[2]) static void applySeqSlide(TransInfo *t, const int mval[2]) { char str[UI_MAX_DRAW_STR]; + float values_final[3]; snapSequenceBounds(t, mval); - - if (t->con.mode & CON_APPLY) { - float tvec[3]; - t->con.applyVec(t, NULL, NULL, t->values, tvec); - copy_v3_v3(t->values_final, tvec); + if (applyNumInput(&t->num, values_final)) { + if (t->con.mode & CON_APPLY) { + if (t->con.mode & CON_AXIS0) { + /* Do nothing. */ + } + else { + mul_v2_v2fl(values_final, t->spacemtx[1], values_final[0]); + } + } + } + else if (t->con.mode & CON_APPLY) { + t->con.applyVec(t, NULL, NULL, t->values, values_final); } else { - // transform_snap_increment(t, t->values); - applyNumInput(&t->num, t->values); - copy_v3_v3(t->values_final, t->values); + copy_v2_v2(values_final, t->values); } - t->values_final[0] = floorf(t->values_final[0] + 0.5f); - t->values_final[1] = floorf(t->values_final[1] + 0.5f); + values_final[0] = floorf(values_final[0] + 0.5f); + values_final[1] = floorf(values_final[1] + 0.5f); + copy_v2_v2(t->values_final, values_final); headerSeqSlide(t, t->values_final, str); applySeqSlideValue(t, t->values_final); diff --git a/source/blender/editors/transform/transform_mode_translate.c b/source/blender/editors/transform/transform_mode_translate.c index 866b9d921c8..758a6d04f11 100644 --- a/source/blender/editors/transform/transform_mode_translate.c +++ b/source/blender/editors/transform/transform_mode_translate.c @@ -360,42 +360,49 @@ static void applyTranslation(TransInfo *t, const int UNUSED(mval[2])) if (t->flag & T_INPUT_IS_VALUES_FINAL) { mul_v3_m3v3(global_dir, t->spacemtx, t->values); } + else if (applyNumInput(&t->num, global_dir)) { + if (t->con.mode & CON_APPLY) { + if (t->con.mode & CON_AXIS0) { + /* Do nothing. */ + } + else if (t->con.mode & CON_AXIS1) { + mul_v3_v3fl(global_dir, t->spacemtx[1], global_dir[0]); + } + else if (t->con.mode & CON_AXIS2) { + mul_v3_v3fl(global_dir, t->spacemtx[2], global_dir[0]); + } + } + } else { copy_v3_v3(global_dir, t->values); - if (applyNumInput(&t->num, global_dir)) { - removeAspectRatio(t, global_dir); + + t->tsnap.snapElem = 0; + applySnapping(t, global_dir); + transform_snap_grid(t, global_dir); + + if (t->con.mode & CON_APPLY) { + float in[3]; + copy_v3_v3(in, global_dir); + t->con.applyVec(t, NULL, NULL, in, global_dir); } - else { - applySnapping(t, global_dir); - if (!validSnap(t) && !(t->con.mode & CON_APPLY)) { - float dist_sq = FLT_MAX; - if (transform_snap_grid(t, global_dir)) { - dist_sq = len_squared_v3v3(t->values, global_dir); - } + float incr_dir[3]; + mul_v3_m3v3(incr_dir, t->spacemtx_inv, global_dir); + if (transform_snap_increment(t, incr_dir)) { + mul_v3_m3v3(incr_dir, t->spacemtx, incr_dir); - /* Check the snap distance to the initial value to work with mixed snap. */ - float increment_loc[3]; - copy_v3_v3(increment_loc, t->values); - if (transform_snap_increment(t, increment_loc)) { - if ((dist_sq == FLT_MAX) || (len_squared_v3v3(t->values, increment_loc) < dist_sq)) { - copy_v3_v3(global_dir, increment_loc); - } - } + /* Test for mixed snap with grid. */ + float snap_dist_sq = FLT_MAX; + if (t->tsnap.snapElem != 0) { + snap_dist_sq = len_squared_v3v3(t->values, global_dir); + } + if ((snap_dist_sq == FLT_MAX) || (len_squared_v3v3(global_dir, incr_dir) < snap_dist_sq)) { + copy_v3_v3(global_dir, incr_dir); } } } - if (t->con.mode & CON_APPLY) { - float in[3]; - copy_v3_v3(in, global_dir); - t->con.applyVec(t, NULL, NULL, in, global_dir); - headerTranslation(t, global_dir, str); - } - else { - headerTranslation(t, global_dir, str); - } - + headerTranslation(t, global_dir, str); applyTranslationValue(t, global_dir); /* evil hack - redo translation if clipping needed */ diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 1813acadb9e..a546aabd095 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -464,6 +464,7 @@ void applySnapping(TransInfo *t, float *vec) void resetSnapping(TransInfo *t) { t->tsnap.status = 0; + t->tsnap.snapElem = 0; t->tsnap.align = false; t->tsnap.project = 0; t->tsnap.mode = 0; @@ -1412,12 +1413,12 @@ void snapSequenceBounds(TransInfo *t, const int mval[2]) t->values[0] = frame_near - frame_snap; } -static void snap_grid_apply_ex( +static void snap_grid_apply( TransInfo *t, const int max_index, const float grid_dist, const float loc[3], float r_out[3]) { + BLI_assert(max_index <= 2); const float *center_global = t->center_global; const float *asp = t->aspect; - bool use_local_axis = false; /* use a fallback for cursor selection, * this isn't useful as a global center for absolute grid snapping @@ -1427,74 +1428,27 @@ static void snap_grid_apply_ex( center_global = cd->global; } - if (t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2)) { - use_local_axis = true; + float in[3]; + if (t->con.mode & CON_APPLY) { + BLI_assert(t->tsnap.snapElem == 0); + t->con.applyVec(t, NULL, NULL, loc, in); + } + else { + copy_v3_v3(in, loc); } for (int i = 0; i <= max_index; i++) { - /* do not let unconstrained axis jump to absolute grid increments */ - if (!(t->con.mode & CON_APPLY) || t->con.mode & (CON_AXIS0 << i)) { - const float iter_fac = grid_dist * asp[i]; - - if (use_local_axis) { - float local_axis[3]; - float pos_on_axis[3]; - - copy_v3_v3(local_axis, t->spacemtx[i]); - copy_v3_v3(pos_on_axis, t->spacemtx[i]); - - /* amount of movement on axis from initial pos */ - mul_v3_fl(pos_on_axis, loc[i]); - - /* actual global position on axis */ - add_v3_v3(pos_on_axis, center_global); - - float min_dist = INFINITY; - for (int j = 0; j < 3; j++) { - if (fabs(local_axis[j]) < 0.01f) { - /* Ignore very small (normalized) axis changes */ - continue; - } - - /* closest point on grid */ - float grid_p = iter_fac * roundf(pos_on_axis[j] / iter_fac); - float dist_p = fabs((grid_p - pos_on_axis[j]) / local_axis[j]); - - /* The amount of distance needed to travel along the - * local axis to snap to the closest grid point */ - /* in the global j axis direction */ - float move_dist = (grid_p - center_global[j]) / local_axis[j]; - - if (dist_p < min_dist) { - min_dist = dist_p; - r_out[i] = move_dist; - } - } - } - else { - r_out[i] = iter_fac * roundf((loc[i] + center_global[i]) / iter_fac) - center_global[i]; - } - } + const float iter_fac = grid_dist * asp[i]; + r_out[i] = iter_fac * roundf((in[i] + center_global[i]) / iter_fac) - center_global[i]; } } -static void snap_grid_apply(TransInfo *t, int max_index, const float grid_dist, float *r_val) +bool transform_snap_grid(TransInfo *t, float *val) { - BLI_assert(t->tsnap.mode & SCE_SNAP_MODE_GRID); - BLI_assert(max_index <= 2); - - /* Early bailing out if no need to snap */ - if (grid_dist == 0.0f) { - return; + if (!activeSnap(t)) { + return false; } - /* absolute snapping on grid based on global center. - * for now only 3d view (others can be added if we want) */ - snap_grid_apply_ex(t, max_index, grid_dist, r_val, r_val); -} - -bool transform_snap_grid(TransInfo *t, float *val) -{ if ((!(t->tsnap.mode & SCE_SNAP_MODE_GRID)) || validSnap(t)) { /* Don't do grid snapping if there is a valid snap point. */ return false; @@ -1508,10 +1462,15 @@ bool transform_snap_grid(TransInfo *t, float *val) return false; } - float grid_dist = activeSnap(t) ? (t->modifiers & MOD_PRECISION) ? t->snap[2] : t->snap[1] : - t->snap[0]; + float grid_dist = (t->modifiers & MOD_PRECISION) ? t->snap[2] : t->snap[1]; + + /* Early bailing out if no need to snap */ + if (grid_dist == 0.0f) { + return false; + } - snap_grid_apply(t, t->idx_max, grid_dist, val); + snap_grid_apply(t, t->idx_max, grid_dist, val, val); + t->tsnap.snapElem = SCE_SNAP_MODE_GRID; return true; } diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt index 207606c2dcd..e05d1fedf6d 100644 --- a/source/blender/editors/util/CMakeLists.txt +++ b/source/blender/editors/util/CMakeLists.txt @@ -33,9 +33,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC ed_transverts.c @@ -106,7 +103,6 @@ set(SRC set(LIB ) -add_definitions(${GL_DEFINITIONS}) if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) diff --git a/source/blender/editors/uvedit/CMakeLists.txt b/source/blender/editors/uvedit/CMakeLists.txt index a39234561c2..f1751ef8d27 100644 --- a/source/blender/editors/uvedit/CMakeLists.txt +++ b/source/blender/editors/uvedit/CMakeLists.txt @@ -31,9 +31,6 @@ set(INC ../../../../intern/guardedalloc ) -set(INC_SYS - ${GLEW_INCLUDE_PATH} -) set(SRC uvedit_buttons.c @@ -58,6 +55,5 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() -add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_editor_uvedit "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") |