diff options
Diffstat (limited to 'source/blender/editors')
97 files changed, 1073 insertions, 584 deletions
diff --git a/source/blender/editors/animation/CMakeLists.txt b/source/blender/editors/animation/CMakeLists.txt index d6030a967d5..b9f50a6cdf1 100644 --- a/source/blender/editors/animation/CMakeLists.txt +++ b/source/blender/editors/animation/CMakeLists.txt @@ -23,10 +23,12 @@ set(INC ../../blenfont ../../blenkernel ../../blenlib + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -57,4 +59,6 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_animation "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/animation/SConscript b/source/blender/editors/animation/SConscript index 91d480978c4..ed4b794cbce 100644 --- a/source/blender/editors/animation/SConscript +++ b/source/blender/editors/animation/SConscript @@ -31,17 +31,19 @@ sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../../blenfont', '../../blenkernel', '../../blenlib', + '../../gpu', '../../makesdna', '../../makesrna', '../../windowmanager', ] -defs = [] +defs = env['BF_GL_DEFINITIONS'] if env['WITH_BF_INTERNATIONAL']: defs.append('WITH_INTERNATIONAL') diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 83593faff22..7f612de14b7 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -643,7 +643,7 @@ static short snap_bezier_nearestsec(KeyframeEditData *ked, BezTriple *bezt) const float secf = (float)FPS; if (bezt->f2 & SELECT) - bezt->vec[1][0] = ((float)floor(bezt->vec[1][0] / secf + 0.5f) * secf); + bezt->vec[1][0] = (floorf(bezt->vec[1][0] / secf + 0.5f) * secf); return 0; } diff --git a/source/blender/editors/armature/CMakeLists.txt b/source/blender/editors/armature/CMakeLists.txt index 9aa17f1e503..fc211f0e60b 100644 --- a/source/blender/editors/armature/CMakeLists.txt +++ b/source/blender/editors/armature/CMakeLists.txt @@ -23,11 +23,12 @@ set(INC ../../blenfont ../../blenkernel ../../blenlib + ../../gpu ../../makesdna ../../makesrna ../../windowmanager - ../../gpu ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -74,4 +75,6 @@ if(WITH_OPENNL) ) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_armature "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/armature/SConscript b/source/blender/editors/armature/SConscript index c68045c9398..97bc1a138b3 100644 --- a/source/blender/editors/armature/SConscript +++ b/source/blender/editors/armature/SConscript @@ -31,20 +31,21 @@ sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '#/intern/opennl/extern', '../include', '../../blenfont', '../../blenkernel', '../../blenlib', + '../../gpu', '../../makesdna', '../../makesrna', - '../../gpu', '../../windowmanager', ] incs = ' '.join(incs) -defs = [] +defs = env['BF_GL_DEFINITIONS'] if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): incs += ' ' + env['BF_PTHREADS_INC'] diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c index fbc18e977ce..5ff15b84284 100644 --- a/source/blender/editors/armature/armature_skinning.c +++ b/source/blender/editors/armature/armature_skinning.c @@ -238,7 +238,8 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], i } } -static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, Object *par, int heat, bool mirror) +static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, Object *par, + int heat, const bool mirror) { /* This functions implements the automatic computation of vertex group * weights, either through envelopes or using a heat equilibrium. @@ -418,7 +419,8 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, MEM_freeN(verts); } -void create_vgroups_from_armature(ReportList *reports, Scene *scene, Object *ob, Object *par, int mode, bool mirror) +void create_vgroups_from_armature(ReportList *reports, Scene *scene, Object *ob, Object *par, + const int mode, const bool mirror) { /* Lets try to create some vertex groups * based on the bones of the parent armature. @@ -439,7 +441,7 @@ void create_vgroups_from_armature(ReportList *reports, Scene *scene, Object *ob, ED_vgroup_data_clamp_range(ob->data, defbase_tot); } } - else if (mode == ARM_GROUPS_ENVELOPE || mode == ARM_GROUPS_AUTO) { + else if (ELEM(mode, ARM_GROUPS_ENVELOPE, ARM_GROUPS_AUTO)) { /* Traverse the bone list, trying to create vertex groups * that are populated with the vertices for which the * bone is closest. diff --git a/source/blender/editors/gpencil/CMakeLists.txt b/source/blender/editors/gpencil/CMakeLists.txt index 904ad4892ed..5dc9679777f 100644 --- a/source/blender/editors/gpencil/CMakeLists.txt +++ b/source/blender/editors/gpencil/CMakeLists.txt @@ -24,10 +24,12 @@ set(INC ../../blenkernel ../../blenlib ../../imbuf + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -50,4 +52,6 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_gpencil "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/gpencil/SConscript b/source/blender/editors/gpencil/SConscript index 8b891fcb8cf..ab42bad52dc 100644 --- a/source/blender/editors/gpencil/SConscript +++ b/source/blender/editors/gpencil/SConscript @@ -31,7 +31,8 @@ sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '#/intern/elbeem/extern', '../include', '../../blenfont', @@ -46,7 +47,7 @@ incs = [ '../../windowmanager', ] -defs = [] +defs = env['BF_GL_DEFINITIONS'] if env['WITH_BF_INTERNATIONAL']: defs.append('WITH_INTERNATIONAL') diff --git a/source/blender/editors/include/BIF_gl.h b/source/blender/editors/include/BIF_gl.h index 9fa603966b6..cd26bb22ada 100644 --- a/source/blender/editors/include/BIF_gl.h +++ b/source/blender/editors/include/BIF_gl.h @@ -33,7 +33,7 @@ #ifndef __BIF_GL_H__ #define __BIF_GL_H__ -#include "GL/glew.h" +#include "GPU_glew.h" #ifdef __APPLE__ diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h index b401f06f484..4272fd49f7f 100644 --- a/source/blender/editors/include/BIF_glutil.h +++ b/source/blender/editors/include/BIF_glutil.h @@ -41,10 +41,12 @@ struct ColorManagedDisplaySettings; void fdrawbezier(float vec[4][3]); void fdrawline(float x1, float y1, float x2, float y2); void fdrawbox(float x1, float y1, float x2, float y2); -void sdrawline(short x1, short y1, short x2, short y2); -void sdrawtri(short x1, short y1, short x2, short y2); -void sdrawtrifill(short x1, short y1, short x2, short y2); -void sdrawbox(short x1, short y1, short x2, short y2); +void sdrawline(int x1, int y1, int x2, int y2); +#if 0 +void sdrawtri(int x1, int y1, int x2, int y2); +void sdrawtrifill(int x1, int y1, int x2, int y2); +#endif +void sdrawbox(int x1, int y1, int x2, int y2); void sdrawXORline(int x0, int y0, int x1, int y1); void sdrawXORline4(int nr, int x0, int y0, int x1, int y1); diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 24c80cbf005..b08cc12dc3e 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -157,9 +157,11 @@ void ED_armature_transform(struct bArmature *arm, float mat[4][4]); #define ARM_GROUPS_ENVELOPE 2 #define ARM_GROUPS_AUTO 3 -void create_vgroups_from_armature(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct Object *par, int mode, bool mirror); +void create_vgroups_from_armature(struct ReportList *reports, struct Scene *scene, struct Object *ob, + struct Object *par, const int mode, const bool mirror); -void unique_editbone_name(struct ListBase *ebones, char *name, EditBone *bone); /* if bone is already in list, pass it as param to ignore it */ +/* if bone is already in list, pass it as param to ignore it */ +void unique_editbone_name(struct ListBase *ebones, char *name, EditBone *bone); void ED_armature_bone_rename(struct bArmature *arm, const char *oldnamep, const char *newnamep); void undo_push_armature(struct bContext *C, const char *name); diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 2328f7d5135..39586039e8f 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -101,9 +101,10 @@ extern struct EnumPropertyItem prop_clear_parent_types[]; extern struct EnumPropertyItem prop_make_parent_types[]; #endif -int ED_object_parent_set(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, - struct Object *par, int partype, bool xmirror, bool keep_transform, const int vert_par[3]); -void ED_object_parent_clear(struct Object *ob, int type); +bool ED_object_parent_set(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, + struct Object *par, int partype, const bool xmirror, const bool keep_transform, + const int vert_par[3]); +void ED_object_parent_clear(struct Object *ob, const int type); struct Base *ED_object_scene_link(struct Scene *scene, struct Object *ob); void ED_keymap_proportional_cycle(struct wmKeyConfig *keyconf, struct wmKeyMap *keymap); @@ -122,7 +123,7 @@ void ED_base_object_free_and_unlink(struct Main *bmain, struct Scene *scene, str /* single object duplicate, if (dupflag == 0), fully linked, else it uses the flags given */ struct Base *ED_object_add_duplicate(struct Main *bmain, struct Scene *scene, struct Base *base, int dupflag); -void ED_object_parent(struct Object *ob, struct Object *parent, int type, const char *substr); +void ED_object_parent(struct Object *ob, struct Object *parent, const int type, const char *substr); bool ED_object_mode_compat_set(struct bContext *C, struct Object *ob, int mode, struct ReportList *reports); void ED_object_toggle_modes(struct bContext *C, int mode); @@ -154,7 +155,7 @@ struct Object *ED_object_add_type( struct bContext *C, int type, const float loc[3], const float rot[3], bool enter_editmode, unsigned int layer) ATTR_RETURNS_NONNULL; -void ED_object_single_users(struct Main *bmain, struct Scene *scene, bool full, bool copy_groups); +void ED_object_single_users(struct Main *bmain, struct Scene *scene, const bool full, const bool copy_groups); void ED_object_single_user(struct Main *bmain, struct Scene *scene, struct Object *ob); /* object motion paths */ diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h index 6d9f1c4eda0..e26e03473e0 100644 --- a/source/blender/editors/include/ED_util.h +++ b/source/blender/editors/include/ED_util.h @@ -46,7 +46,7 @@ struct Mesh; void ED_editors_init(struct bContext *C); void ED_editors_exit(struct bContext *C); -void ED_editors_flush_edits(const struct bContext *C, bool for_render); +bool ED_editors_flush_edits(const struct bContext *C, bool for_render); /* ************** Undo ************************ */ diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt index e13517adbb3..b921d17104c 100644 --- a/source/blender/editors/interface/CMakeLists.txt +++ b/source/blender/editors/interface/CMakeLists.txt @@ -30,6 +30,7 @@ set(INC ../../python ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -70,4 +71,6 @@ if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_interface "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/interface/SConscript b/source/blender/editors/interface/SConscript index 1936e17a7bb..303ab7ff286 100644 --- a/source/blender/editors/interface/SConscript +++ b/source/blender/editors/interface/SConscript @@ -31,7 +31,8 @@ sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../../blenfont', '../../blenkernel', @@ -45,7 +46,7 @@ incs = [ '../../windowmanager', ] -defs = [] +defs = env['BF_GL_DEFINITIONS'] if env['WITH_BF_INTERNATIONAL']: defs.append('WITH_INTERNATIONAL') diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 9138ac92ab9..5bd85f855ba 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -6560,7 +6560,7 @@ static bool ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y) ui_window_to_block_fl(ar, block, &mx, &my); - if (but->dt == UI_EMBOSSR) { + if (but->pie_dir != UI_RADIAL_NONE) { if (!ui_but_isect_pie_seg(block, but)) { return false; } @@ -8521,14 +8521,6 @@ static int ui_handle_menu_return_submenu(bContext *C, const wmEvent *event, uiPo } if (menu->menuretval) { - /* pie menus should not close but wait for release instead */ - if ((block->flag & UI_BLOCK_RADIAL) && - !(block->pie_data.flags & UI_PIE_CLICK_STYLE)) - { - menu->menuretval = 0; - block->pie_data.flags |= UI_PIE_FINISHED; - } - return WM_UI_HANDLER_CONTINUE; } else { @@ -8538,10 +8530,10 @@ static int ui_handle_menu_return_submenu(bContext *C, const wmEvent *event, uiPo static bool ui_but_pie_menu_supported_apply(uiBut *but) { - return (but->type != NUMSLI); + return (!ELEM(but->type, NUMSLI, NUM)); } -static int ui_but_pie_menu_apply(bContext *C, uiPopupBlockHandle *menu, uiBut *but, bool force_close, bool click_style) +static int ui_but_pie_menu_apply(bContext *C, uiPopupBlockHandle *menu, uiBut *but, bool force_close) { int retval = WM_UI_HANDLER_BREAK; @@ -8566,24 +8558,11 @@ static int ui_but_pie_menu_apply(bContext *C, uiPopupBlockHandle *menu, uiBut *b ui_apply_button(C, but->block, but, but->active, false); button_activate_exit((bContext *)C, but, but->active, false, true); - if (!(click_style || force_close)) { - but->block->pie_data.flags |= UI_PIE_FINISHED; - menu->menuretval = 0; - } - else { - menu->menuretval = UI_RETURN_OK; - } + menu->menuretval = UI_RETURN_OK; } } else { - uiBlock *block = menu->region->uiblocks.first; - - if (!(click_style || force_close)) { - block->pie_data.flags |= UI_PIE_FINISHED; - } - else { - menu->menuretval = UI_RETURN_CANCEL; - } + menu->menuretval = UI_RETURN_CANCEL; ED_region_tag_redraw(menu->region); } @@ -8606,7 +8585,7 @@ static uiBut *ui_block_pie_dir_activate(uiBlock *block, const wmEvent *event, Ra return NULL; } -static int ui_but_pie_button_activate(bContext *C, uiBut *but, uiPopupBlockHandle *menu, bool is_click_style) +static int ui_but_pie_button_activate(bContext *C, uiBut *but, uiPopupBlockHandle *menu) { uiBut *active_but; @@ -8619,7 +8598,7 @@ static int ui_but_pie_button_activate(bContext *C, uiBut *but, uiPopupBlockHandl button_activate_exit(C, active_but, active_but->active, false, false); button_activate_init(C, menu->region, but, BUTTON_ACTIVATE_OVER); - return ui_but_pie_menu_apply(C, menu, but, false, is_click_style); + return ui_but_pie_menu_apply(C, menu, but, false); } static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle *menu) @@ -8687,7 +8666,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle mul_v2_fl(vec, pie_radius); add_v2_v2(vec, center); - mul_v2_fl(vec, fac); + mul_v2_fl(vec, fac); add_v2_v2(vec, block->pie_data.pie_center_spawned); BLI_rctf_recenter(&but->rect, vec[0], vec[1]); @@ -8718,7 +8697,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle return WM_UI_HANDLER_BREAK; } - if (event->type == block->pie_data.event) { + if (event->type == block->pie_data.event && !is_click_style) { if (event->val != KM_RELEASE) { ui_handle_menu_button(C, event, menu); @@ -8734,10 +8713,10 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle if (!(block->pie_data.flags & UI_PIE_DRAG_STYLE)) { block->pie_data.flags |= UI_PIE_CLICK_STYLE; } - else if (!is_click_style) { + else { uiBut *but = ui_but_find_activated(menu->region); - retval = ui_but_pie_menu_apply(C, menu, but, true, is_click_style); + retval = ui_but_pie_menu_apply(C, menu, but, true); } } } @@ -8747,7 +8726,9 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle switch (event->type) { case MOUSEMOVE: - if (len_squared_v2v2(event_xy, block->pie_data.pie_center_init) > PIE_CLICK_THRESHOLD_SQ) { + if (!is_click_style && + (len_squared_v2v2(event_xy, block->pie_data.pie_center_init) > PIE_CLICK_THRESHOLD_SQ)) + { block->pie_data.flags |= UI_PIE_DRAG_STYLE; } ui_handle_menu_button(C, event, menu); @@ -8757,9 +8738,13 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle break; case LEFTMOUSE: - if (event->val == KM_PRESS) { - uiBut *but = ui_but_find_activated(menu->region); - retval = ui_but_pie_menu_apply(C, menu, but, false, is_click_style); + if (is_click_style) { + if (block->pie_data.flags & UI_PIE_INVALID_DIR) { + menu->menuretval = UI_RETURN_CANCEL; + } + else { + retval = ui_handle_menu_button(C, event, menu); + } } break; @@ -8808,7 +8793,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle { for (but = block->buttons.first; but; but = but->next) { if (but->menu_key == event->type) { - ui_but_pie_button_activate(C, but, menu, is_click_style); + ui_but_pie_button_activate(C, but, menu); } } } @@ -8829,7 +8814,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle CASE_NUM_TO_DIR(9, UI_RADIAL_NE); { but = ui_block_pie_dir_activate(block, event, num_dir); - retval = ui_but_pie_button_activate(C, but, menu, is_click_style); + retval = ui_but_pie_button_activate(C, but, menu); break; } #undef CASE_NUM_TO_DIR diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 9b450b8fdf4..5739ebebe64 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -2720,6 +2720,11 @@ uiPieMenu *uiPieMenuBegin(struct bContext *C, const char *title, int icon, const pie->block_radial->flag |= UI_BLOCK_RADIAL; pie->block_radial->pie_data.event = event->type; + /* if pie is spawned by a left click, it is always assumed to be click style */ + if (event->type == LEFTMOUSE) { + pie->block_radial->flag |= UI_PIE_CLICK_STYLE; + } + pie->layout = uiBlockLayout(pie->block_radial, UI_LAYOUT_VERTICAL, UI_LAYOUT_PIEMENU, 0, 0, 200, 0, 0, style); pie->mx = event->x; pie->my = event->y; diff --git a/source/blender/editors/mask/CMakeLists.txt b/source/blender/editors/mask/CMakeLists.txt index b1cf6db3144..033d034cf4e 100644 --- a/source/blender/editors/mask/CMakeLists.txt +++ b/source/blender/editors/mask/CMakeLists.txt @@ -25,10 +25,12 @@ set(INC ../include ../../blenkernel ../../blenlib + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -48,4 +50,6 @@ set(SRC mask_intern.h ) +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_mask "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/mask/SConscript b/source/blender/editors/mask/SConscript index 9dd521e3a7c..bcbaaa34960 100644 --- a/source/blender/editors/mask/SConscript +++ b/source/blender/editors/mask/SConscript @@ -29,14 +29,16 @@ Import ('env') sources = env.Glob('*.c') -defs = [] +defs = env['BF_GL_DEFINITIONS'] incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../../blenkernel', '../../blenlib', + '../../gpu', '../../makesdna', '../../makesrna', '../../windowmanager', diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index c3959f90318..b27baaf22be 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -580,7 +580,7 @@ static bool spline_under_mouse_get(const bContext *C, } } } - /* TODO(sergey): Chech whether tesellated spline point is closer + /* TODO(sergey): Chech whether tessellated spline point is closer * to the mouse than the spline center. */ if (closest_dist_squared < 32.0f * 32.0f && closest_spline != NULL) { diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt index 0cb2dd1eb68..db20d42f39d 100644 --- a/source/blender/editors/mesh/CMakeLists.txt +++ b/source/blender/editors/mesh/CMakeLists.txt @@ -32,6 +32,7 @@ set(INC ../../render/extern/include ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -86,4 +87,6 @@ if(WITH_BULLET) add_definitions(-DWITH_BULLET) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_mesh "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/mesh/SConscript b/source/blender/editors/mesh/SConscript index 6fa48c12eca..122a7501e58 100644 --- a/source/blender/editors/mesh/SConscript +++ b/source/blender/editors/mesh/SConscript @@ -29,11 +29,12 @@ Import ('env') sources = env.Glob('*.c') -defs = [] +defs = env['BF_GL_DEFINITIONS'] incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../uvedit', '../../blenfont', diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index 48d5113a279..0e48cbcd589 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -75,7 +75,8 @@ typedef struct { static void edbm_bevel_update_header(bContext *C, wmOperator *op) { - const char *str = IFACE_("Confirm: (Enter/LMB), Cancel: (Esc/RMB), Mode: %s (M), Offset: %s, Segments: %d"); + const char *str = IFACE_("Confirm: (Enter/LMB), Cancel: (Esc/RMB), Mode: %s (M), Clamp Overlap: %s (C), " + "Offset: %s, Segments: %d"); char msg[HEADER_LENGTH]; ScrArea *sa = CTX_wm_area(C); @@ -96,7 +97,9 @@ static void edbm_bevel_update_header(bContext *C, wmOperator *op) RNA_property_enum_name_gettexted(C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &type_str); - BLI_snprintf(msg, HEADER_LENGTH, str, type_str, offset_str, RNA_int_get(op->ptr, "segments")); + BLI_snprintf(msg, HEADER_LENGTH, str, type_str, + WM_bool_as_string(RNA_boolean_get(op->ptr, "clamp_overlap")), + offset_str, RNA_int_get(op->ptr, "segments")); ED_area_headerprint(sa, msg); } @@ -150,6 +153,7 @@ static bool edbm_bevel_calc(wmOperator *op) const int segments = RNA_int_get(op->ptr, "segments"); const float profile = RNA_float_get(op->ptr, "profile"); const bool vertex_only = RNA_boolean_get(op->ptr, "vertex_only"); + const bool clamp_overlap = RNA_boolean_get(op->ptr, "clamp_overlap"); int material = RNA_int_get(op->ptr, "material"); /* revert to original mesh */ @@ -161,8 +165,9 @@ static bool edbm_bevel_calc(wmOperator *op) material = CLAMPIS(material, -1, em->ob->totcol - 1); EDBM_op_init(em, &bmop, op, - "bevel geom=%hev offset=%f segments=%i vertex_only=%b offset_type=%i profile=%f material=%i", - BM_ELEM_SELECT, offset, segments, vertex_only, offset_type, profile, material); + "bevel geom=%hev offset=%f segments=%i vertex_only=%b offset_type=%i profile=%f clamp_overlap=%b " + "material=%i", + BM_ELEM_SELECT, offset, segments, vertex_only, offset_type, profile, clamp_overlap, material); BMO_op_exec(em->bm, &bmop); @@ -408,6 +413,18 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) edbm_bevel_update_header(C, op); handled = true; break; + case CKEY: + if (event->val == KM_RELEASE) + break; + + { + PropertyRNA *prop = RNA_struct_find_property(op->ptr, "clamp_overlap"); + RNA_property_enum_set(op->ptr, prop, !RNA_property_boolean_get(op->ptr, prop)); + } + edbm_bevel_calc(op); + edbm_bevel_update_header(C, op); + handled = true; + break; } /* Modal numinput inactive, try to handle numeric inputs last... */ @@ -467,6 +484,8 @@ void MESH_OT_bevel(wmOperatorType *ot) RNA_def_property_float_array_funcs_runtime(prop, NULL, NULL, mesh_ot_bevel_offset_range_func); RNA_def_int(ot->srna, "segments", 1, 1, 50, "Segments", "Segments for curved edge", 1, 8); RNA_def_float(ot->srna, "profile", 0.5f, 0.15f, 1.0f, "Profile", "Controls profile shape (0.5 = round)", 0.15f, 1.0f); - RNA_def_boolean(ot->srna, "vertex_only", false, "Vertex only", "Bevel only vertices"); + RNA_def_boolean(ot->srna, "vertex_only", false, "Vertex Only", "Bevel only vertices"); + RNA_def_boolean(ot->srna, "clamp_overlap", false, "Clamp Overlap", + "Do not allow beveled edges/vertices to overlap each other"); RNA_def_int(ot->srna, "material", -1, -1, INT_MAX, "Material", "Material for bevel faces (-1 means use adjacent faces)", -1, 100); } diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index 1bb35b65918..9b380ff8d48 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -33,10 +33,11 @@ set(INC ../../render/extern/include ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS - + ${GLEW_INCLUDE_PATH} ) set(SRC @@ -62,6 +63,8 @@ set(SRC object_intern.h ) +add_definitions(${GL_DEFINITIONS}) + if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index abc0516cf2b..c8a009e4129 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -128,9 +128,9 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) BPoint *bp; Object *par; int a, v1 = 0, v2 = 0, v3 = 0, v4 = 0, nr = 1; - + /* we need 1 to 3 selected vertices */ - + if (obedit->type == OB_MESH) { Mesh *me = obedit->data; BMEditMesh *em; @@ -160,7 +160,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) } else if (ELEM(obedit->type, OB_SURF, OB_CURVE)) { ListBase *editnurb = object_editcurve_get(obedit); - + cu = obedit->data; nu = editnurb->first; @@ -200,7 +200,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) } else if (obedit->type == OB_LATTICE) { Lattice *lt = obedit->data; - + a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; bp = lt->editlatt->latt->def; while (a--) { @@ -215,28 +215,24 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) bp++; } } - + if (v4 || !((v1 && v2 == 0 && v3 == 0) || (v1 && v2 && v3))) { BKE_report(op->reports, RPT_ERROR, "Select either 1 or 3 vertices to parent to"); return OPERATOR_CANCELLED; } - + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { if (ob != obedit) { DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); par = obedit->parent; - - while (par) { - if (par == ob) break; - par = par->parent; - } - if (par) { + + if (BKE_object_parent_loop_check(par, ob)) { BKE_report(op->reports, RPT_ERROR, "Loop in parents"); } else { Object workob; - + ob->parent = BASACT->object; if (v3) { ob->partype = PARVERT3; @@ -260,7 +256,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT, NULL); @@ -274,12 +270,12 @@ void OBJECT_OT_vertex_parent_set(wmOperatorType *ot) ot->name = "Make Vertex Parent"; ot->description = "Parent selected objects to the selected vertices"; ot->idname = "OBJECT_OT_vertex_parent_set"; - + /* api callbacks */ ot->invoke = WM_operator_confirm; ot->poll = vertex_parent_set_poll; ot->exec = vertex_parent_set_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -291,26 +287,26 @@ static int make_proxy_invoke(bContext *C, wmOperator *op, const wmEvent *event) { Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); - + /* sanity checks */ if (!scene || scene->id.lib || !ob) return OPERATOR_CANCELLED; - + /* Get object to work on - use a menu if we need to... */ if (ob->dup_group && ob->dup_group->id.lib) { /* gives menu with list of objects in group */ - //proxy_group_objects_menu(C, op, ob, ob->dup_group); + /* proxy_group_objects_menu(C, op, ob, ob->dup_group); */ WM_enum_search_invoke(C, op, event); return OPERATOR_CANCELLED; - } else if (ob->id.lib) { uiPopupMenu *pup = uiPupMenuBegin(C, IFACE_("OK?"), ICON_QUESTION); uiLayout *layout = uiPupMenuLayout(pup); - + /* create operator menu item with relevant properties filled in */ - uiItemFullO_ptr(layout, op->type, op->type->name, ICON_NONE, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); - + uiItemFullO_ptr(layout, op->type, op->type->name, ICON_NONE, NULL, + WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); + /* present the menu and be done... */ uiPupMenuEnd(C, pup); } @@ -318,7 +314,7 @@ static int make_proxy_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* error.. cannot continue */ BKE_report(op->reports, RPT_ERROR, "Can only make proxy for a referenced object or group"); } - + /* this invoke just calls another instance of this operator... */ return OPERATOR_CANCELLED; } @@ -338,32 +334,32 @@ static int make_proxy_exec(bContext *C, wmOperator *op) ob = gob; gob = NULL; } - + if (ob) { Object *newob; Base *newbase, *oldbase = BASACT; char name[MAX_ID_NAME + 4]; - + /* Add new object for the proxy */ newob = BKE_object_add(bmain, scene, OB_EMPTY); BLI_snprintf(name, sizeof(name), "%s_proxy", ((ID *)(gob ? gob : ob))->name + 2); rename_id(&newob->id, name); - + /* set layers OK */ newbase = BASACT; /* BKE_object_add sets active... */ newbase->lay = oldbase->lay; newob->lay = newbase->lay; - + /* remove base, leave user count of object, it gets linked in BKE_object_make_proxy */ if (gob == NULL) { BKE_scene_base_unlink(scene, oldbase); MEM_freeN(oldbase); } - + BKE_object_make_proxy(newob, ob, gob); - + /* depsgraph flushes are needed for the new data */ DAG_relations_tag_update(bmain); DAG_id_tag_update(&newob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); @@ -373,12 +369,13 @@ static int make_proxy_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No object to make proxy for"); return OPERATOR_CANCELLED; } - + return OPERATOR_FINISHED; } /* Generic itemf's for operators that take library args */ -static EnumPropertyItem *proxy_group_object_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +static EnumPropertyItem *proxy_group_object_itemf(bContext *C, PointerRNA *UNUSED(ptr), + PropertyRNA *UNUSED(prop), bool *r_free) { EnumPropertyItem item_tmp = {0}, *item = NULL; int totitem = 0; @@ -410,17 +407,19 @@ void OBJECT_OT_proxy_make(wmOperatorType *ot) ot->name = "Make Proxy"; ot->idname = "OBJECT_OT_proxy_make"; ot->description = "Add empty object to become local replacement data of a library-linked object"; - + /* callbacks */ ot->invoke = make_proxy_invoke; ot->exec = make_proxy_exec; ot->poll = ED_operator_object_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ - prop = RNA_def_enum(ot->srna, "object", DummyRNA_DEFAULT_items, 0, "Proxy Object", "Name of lib-linked/grouped object to make a proxy for"); /* XXX, relies on hard coded ID at the moment */ + /* XXX, relies on hard coded ID at the moment */ + prop = RNA_def_enum(ot->srna, "object", DummyRNA_DEFAULT_items, 0, "Proxy Object", + "Name of lib-linked/grouped object to make a proxy for"); RNA_def_enum_funcs(prop, proxy_group_object_itemf); RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE); ot->prop = prop; @@ -435,9 +434,12 @@ typedef enum eObClearParentTypes { } eObClearParentTypes; EnumPropertyItem prop_clear_parent_types[] = { - {CLEAR_PARENT_ALL, "CLEAR", 0, "Clear Parent", ""}, - {CLEAR_PARENT_KEEP_TRANSFORM, "CLEAR_KEEP_TRANSFORM", 0, "Clear and Keep Transformation", ""}, - {CLEAR_PARENT_INVERSE, "CLEAR_INVERSE", 0, "Clear Parent Inverse", ""}, + {CLEAR_PARENT_ALL, "CLEAR", 0, "Clear Parent", + "Completely clear the parenting relationship, including involved modifiers is any"}, + {CLEAR_PARENT_KEEP_TRANSFORM, "CLEAR_KEEP_TRANSFORM", 0, "Clear and Keep Transformation", + "As 'Clear Parent', but keep the current visual transformations of the object"}, + {CLEAR_PARENT_INVERSE, "CLEAR_INVERSE", 0, "Clear Parent Inverse", + "Reset the transform corrections applied to the parenting relationship, does not remove parenting itself"}, {0, NULL, 0, NULL, NULL} }; @@ -446,13 +448,13 @@ static void object_remove_parent_deform_modifiers(Object *ob, const Object *par) { if (ELEM(par->type, OB_ARMATURE, OB_LATTICE, OB_CURVE)) { ModifierData *md, *mdn; - + /* assume that we only need to remove the first instance of matching deform modifier here */ for (md = ob->modifiers.first; md; md = mdn) { bool free = false; - + mdn = md->next; - + /* need to match types (modifier + parent) and references */ if ((md->type == eModifierType_Armature) && (par->type == OB_ARMATURE)) { ArmatureModifierData *amd = (ArmatureModifierData *)md; @@ -472,7 +474,7 @@ static void object_remove_parent_deform_modifiers(Object *ob, const Object *par) free = true; } } - + /* free modifier if match */ if (free) { BLI_remlink(&ob->modifiers, md); @@ -482,17 +484,17 @@ static void object_remove_parent_deform_modifiers(Object *ob, const Object *par) } } -void ED_object_parent_clear(Object *ob, int type) +void ED_object_parent_clear(Object *ob, const int type) { if (ob->parent == NULL) return; - + switch (type) { case CLEAR_PARENT_ALL: { /* for deformers, remove corresponding modifiers to prevent a large number of modifiers building up */ object_remove_parent_deform_modifiers(ob, ob->parent); - + /* clear parenting relationship completely */ ob->parent = NULL; break; @@ -506,12 +508,15 @@ void ED_object_parent_clear(Object *ob, int type) } case CLEAR_PARENT_INVERSE: { - /* object stays parented, but the parent inverse (i.e. offset from parent to retain binding state) is cleared */ - unit_m4(ob->parentinv); + /* object stays parented, but the parent inverse (i.e. offset from parent to retain binding state) + * is cleared. In other words: nothing to do here! */ break; } } - + + /* Always clear parentinv matrix for sake of consistency, see T41950. */ + unit_m4(ob->parentinv); + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); } @@ -519,7 +524,7 @@ void ED_object_parent_clear(Object *ob, int type) static int parent_clear_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - int type = RNA_enum_get(op->ptr, "type"); + const int type = RNA_enum_get(op->ptr, "type"); CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { @@ -539,23 +544,26 @@ void OBJECT_OT_parent_clear(wmOperatorType *ot) ot->name = "Clear Parent"; ot->description = "Clear the object's parenting"; ot->idname = "OBJECT_OT_parent_clear"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = parent_clear_exec; - + ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + ot->prop = RNA_def_enum(ot->srna, "type", prop_clear_parent_types, CLEAR_PARENT_ALL, "Type", ""); } /* ******************** Make Parent Operator *********************** */ -void ED_object_parent(Object *ob, Object *par, int type, const char *substr) +void ED_object_parent(Object *ob, Object *par, const int type, const char *substr) { + /* Always clear parentinv matrix for sake of consistency, see T41950. */ + unit_m4(ob->parentinv); + if (!par || BKE_object_parent_loop_check(par, ob)) { ob->parent = NULL; ob->partype = PAROBJECT; @@ -589,21 +597,21 @@ EnumPropertyItem prop_make_parent_types[] = { {0, NULL, 0, NULL, NULL} }; -int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object *ob, Object *par, - int partype, bool xmirror, bool keep_transform, const int vert_par[3]) +bool ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object *ob, Object *par, + int partype, const bool xmirror, const bool keep_transform, const int vert_par[3]) { bPoseChannel *pchan = NULL; - int pararm = ELEM(partype, PAR_ARMATURE, PAR_ARMATURE_NAME, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO); - + const bool pararm = ELEM(partype, PAR_ARMATURE, PAR_ARMATURE_NAME, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO); + DAG_id_tag_update(&par->id, OB_RECALC_OB); - + /* preconditions */ if (partype == PAR_FOLLOW || partype == PAR_PATH_CONST) { if (par->type != OB_CURVE) return 0; else { Curve *cu = par->data; - + if ((cu->flag & CU_PATH) == 0) { cu->flag |= CU_PATH | CU_FOLLOW; BKE_displist_make_curveTypes(scene, par, 0); /* force creation of path data */ @@ -617,12 +625,12 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object /* get or create F-Curve */ bAction *act = verify_adt_action(&cu->id, 1); FCurve *fcu = verify_fcurve(act, NULL, NULL, "eval_time", 0, 1); - + /* setup dummy 'generator' modifier here to get 1-1 correspondence still working */ if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first) add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR); } - + /* fall back on regular parenting now (for follow only) */ if (partype == PAR_FOLLOW) partype = PAR_OBJECT; @@ -630,17 +638,17 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object } else if (ELEM(partype, PAR_BONE, PAR_BONE_RELATIVE)) { pchan = BKE_pose_channel_active(par); - + if (pchan == NULL) { BKE_report(reports, RPT_ERROR, "No active bone"); - return 0; + return false; } } - + if (ob != par) { if (BKE_object_parent_loop_check(par, ob)) { BKE_report(reports, RPT_ERROR, "Loop in parents"); - return 0; + return false; } else { Object workob; @@ -655,14 +663,16 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object /* set the parent (except for follow-path constraint option) */ if (partype != PAR_PATH_CONST) { ob->parent = par; + /* Always clear parentinv matrix for sake of consistency, see T41950. */ + unit_m4(ob->parentinv); } - + /* handle types */ if (pchan) BLI_strncpy(ob->parsubstr, pchan->name, sizeof(ob->parsubstr)); else ob->parsubstr[0] = 0; - + if (partype == PAR_PATH_CONST) { /* don't do anything here, since this is not technically "parenting" */ } @@ -670,17 +680,18 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object /* partype is now set to PAROBJECT so that invisible 'virtual' modifiers don't need to be created * NOTE: the old (2.4x) method was to set ob->partype = PARSKEL, creating the virtual modifiers */ - ob->partype = PAROBJECT; /* note, dna define, not operator property */ - //ob->partype = PARSKEL; /* note, dna define, not operator property */ - - /* BUT, to keep the deforms, we need a modifier, and then we need to set the object that it uses + ob->partype = PAROBJECT; /* note, dna define, not operator property */ + /* ob->partype = PARSKEL; */ /* note, dna define, not operator property */ + + /* BUT, to keep the deforms, we need a modifier, and then we need to set the object that it uses * - We need to ensure that the modifier we're adding doesn't already exist, so we check this by * assuming that the parent is selected too... */ - // XXX currently this should only happen for meshes, curves, surfaces, and lattices - this stuff isn't available for metas yet + /* XXX currently this should only happen for meshes, curves, surfaces, + * and lattices - this stuff isn't available for metas yet */ if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) { ModifierData *md; - + switch (partype) { case PAR_CURVE: /* curve deform */ if (modifiers_isDeformedByCurve(ob) != par) { @@ -730,21 +741,21 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object else { ob->partype = PAROBJECT; /* note, dna define, not operator property */ } - + /* constraint */ if (partype == PAR_PATH_CONST) { bConstraint *con; bFollowPathConstraint *data; float cmat[4][4], vec[3]; - + con = BKE_constraint_add_for_object(ob, "AutoPath", CONSTRAINT_TYPE_FOLLOWPATH); - + data = con->data; data->tar = par; - + BKE_constraint_target_matrix_get(scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra); sub_v3_v3v3(vec, ob->obmat[3], cmat[3]); - + copy_v3_v3(ob->loc, vec); } else if (pararm && (ob->type == OB_MESH) && (par->type == OB_ARMATURE)) { @@ -760,7 +771,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object /* get corrected inverse */ ob->partype = PAROBJECT; BKE_object_workob_calc_parent(scene, ob, &workob); - + invert_m4_m4(ob->parentinv, workob.obmat); } else { @@ -768,12 +779,12 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); } - + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA); } } - return 1; + return true; } @@ -808,8 +819,8 @@ static int parent_set_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *par = ED_object_active_context(C); int partype = RNA_enum_get(op->ptr, "type"); - bool xmirror = RNA_boolean_get(op->ptr, "xmirror"); - bool keep_transform = RNA_boolean_get(op->ptr, "keep_transform"); + const bool xmirror = RNA_boolean_get(op->ptr, "xmirror"); + const bool keep_transform = RNA_boolean_get(op->ptr, "keep_transform"); bool ok = true; /* vertex parent (kdtree) */ @@ -828,27 +839,25 @@ static int parent_set_exec(bContext *C, wmOperator *op) if (tree_tot < (is_tri ? 3 : 1)) { BKE_report(op->reports, RPT_ERROR, "Not enough vertices for vertex-parent"); ok = false; - goto cleanup; } } + if (ok) { + /* Non vertex-parent */ + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) + { + if (is_vert_par) { + parent_set_vert_find(tree, ob, vert_par, is_tri); + } - /* Non vertex-parent */ - CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) - { - if (is_vert_par) { - parent_set_vert_find(tree, ob, vert_par, is_tri); - } - - if (!ED_object_parent_set(op->reports, bmain, scene, ob, par, partype, xmirror, keep_transform, vert_par_p)) { - ok = false; - break; + if (!ED_object_parent_set(op->reports, bmain, scene, ob, par, partype, xmirror, keep_transform, vert_par_p)) { + ok = false; + break; + } } + CTX_DATA_END; } - CTX_DATA_END; - -cleanup: if (is_vert_par) { BLI_kdtree_free(tree); } @@ -902,7 +911,7 @@ static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent else if (ob->type == OB_LATTICE) { uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_LATTICE); } - + /* vertex parenting */ if (OB_TYPE_SUPPORT_PARVERT(ob->type)) { uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_VERTEX); @@ -910,14 +919,14 @@ static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent } uiPupMenuEnd(C, pup); - + return OPERATOR_CANCELLED; } static bool parent_set_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) { const char *prop_id = RNA_property_identifier(prop); - int type = RNA_enum_get(ptr, "type"); + const int type = RNA_enum_get(ptr, "type"); /* Only show XMirror for PAR_ARMATURE_ENVELOPE and PAR_ARMATURE_AUTO! */ if (STREQ(prop_id, "xmirror")) { @@ -948,22 +957,21 @@ void OBJECT_OT_parent_set(wmOperatorType *ot) ot->name = "Make Parent"; ot->description = "Set the object's parenting"; ot->idname = "OBJECT_OT_parent_set"; - + /* api callbacks */ ot->invoke = parent_set_invoke; ot->exec = parent_set_exec; ot->poll = ED_operator_object_active; ot->ui = parent_set_ui; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_enum(ot->srna, "type", prop_make_parent_types, 0, "Type", ""); RNA_def_boolean(ot->srna, "xmirror", false, "X Mirror", "Apply weights symmetrically along X axis, for Envelope/Automatic vertex groups creation"); RNA_def_boolean(ot->srna, "keep_transform", false, "Keep Transform", "Apply transformation before parenting"); - } /* ************ Make Parent Without Inverse Operator ******************* */ @@ -972,9 +980,9 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Object *par = ED_object_active_context(C); - + DAG_id_tag_update(&par->id, OB_RECALC_OB); - + /* context iterator */ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { @@ -986,10 +994,10 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op) /* clear inverse matrix and also the object location */ unit_m4(ob->parentinv); memset(ob->loc, 0, 3 * sizeof(float)); - + /* set recalc flags */ DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA); - + /* set parenting type for object - object only... */ ob->parent = par; ob->partype = PAROBJECT; /* note, dna define, not operator property */ @@ -997,10 +1005,10 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); - + return OPERATOR_FINISHED; } @@ -1010,12 +1018,12 @@ void OBJECT_OT_parent_no_inverse_set(wmOperatorType *ot) ot->name = "Make Parent without Inverse"; ot->description = "Set the object's parenting without setting the inverse parent correction"; ot->idname = "OBJECT_OT_parent_no_inverse_set"; - + /* api callbacks */ ot->invoke = WM_operator_confirm; ot->exec = parent_noinv_set_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1040,23 +1048,22 @@ static int object_slow_parent_clear_exec(bContext *C, wmOperator *UNUSED(op)) CTX_DATA_END; WM_event_add_notifier(C, NC_SCENE, scene); - + return OPERATOR_FINISHED; } void OBJECT_OT_slow_parent_clear(wmOperatorType *ot) { - /* identifiers */ ot->name = "Clear Slow Parent"; ot->description = "Clear the object's slow parent"; ot->idname = "OBJECT_OT_slow_parent_clear"; - + /* api callbacks */ ot->invoke = WM_operator_confirm; ot->exec = object_slow_parent_clear_exec; ot->poll = ED_operator_view3d_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1073,37 +1080,40 @@ static int object_slow_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) ob->partype |= PARSLOW; DAG_id_tag_update(&ob->id, OB_RECALC_OB); - } CTX_DATA_END; WM_event_add_notifier(C, NC_SCENE, scene); - + return OPERATOR_FINISHED; } void OBJECT_OT_slow_parent_set(wmOperatorType *ot) { - /* identifiers */ ot->name = "Set Slow Parent"; ot->description = "Set the object's slow parent"; ot->idname = "OBJECT_OT_slow_parent_set"; - + /* api callbacks */ ot->invoke = WM_operator_confirm; ot->exec = object_slow_parent_set_exec; ot->poll = ED_operator_view3d_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Clear Track Operator ******************* */ +enum { + CLEAR_TRACK = 1, + CLEAR_TRACK_KEEP_TRANSFORM = 2, +}; + static EnumPropertyItem prop_clear_track_types[] = { - {0, "CLEAR", 0, "Clear Track", ""}, - {1, "CLEAR_KEEP_TRANSFORM", 0, "Clear and Keep Transformation (Clear Track)", ""}, + {CLEAR_TRACK, "CLEAR", 0, "Clear Track", ""}, + {CLEAR_TRACK_KEEP_TRANSFORM, "CLEAR_KEEP_TRANSFORM", 0, "Clear and Keep Transformation (Clear Track)", ""}, {0, NULL, 0, NULL, NULL} }; @@ -1111,7 +1121,7 @@ static EnumPropertyItem prop_clear_track_types[] = { static int object_track_clear_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - int type = RNA_enum_get(op->ptr, "type"); + const int type = RNA_enum_get(op->ptr, "type"); if (CTX_data_edit_object(C)) { BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in edit mode"); @@ -1120,19 +1130,19 @@ static int object_track_clear_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { bConstraint *con, *pcon; - + /* remove track-object for old track */ ob->track = NULL; DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); - + /* also remove all tracking constraints */ for (con = ob->constraints.last; con; con = pcon) { pcon = con->prev; if (ELEM(con->type, CONSTRAINT_TYPE_TRACKTO, CONSTRAINT_TYPE_LOCKTRACK, CONSTRAINT_TYPE_DAMPTRACK)) BKE_constraint_remove(&ob->constraints, con); } - - if (type == 1) + + if (type == CLEAR_TRACK_KEEP_TRANSFORM) BKE_object_apply_mat4(ob, ob->obmat, true, true); } CTX_DATA_END; @@ -1149,25 +1159,31 @@ void OBJECT_OT_track_clear(wmOperatorType *ot) ot->name = "Clear Track"; ot->description = "Clear tracking constraint or flag from object"; ot->idname = "OBJECT_OT_track_clear"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = object_track_clear_exec; - + ot->poll = ED_operator_objectmode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + ot->prop = RNA_def_enum(ot->srna, "type", prop_clear_track_types, 0, "Type", ""); } /************************** Make Track Operator *****************************/ +enum { + CREATE_TRACK_DAMPTRACK = 1, + CREATE_TRACK_TRACKTO = 2, + CREATE_TRACK_LOCKTRACK = 3, +}; + static EnumPropertyItem prop_make_track_types[] = { - {1, "DAMPTRACK", 0, "Damped Track Constraint", ""}, - {2, "TRACKTO", 0, "Track To Constraint", ""}, - {3, "LOCKTRACK", 0, "Lock Track Constraint", ""}, + {CREATE_TRACK_DAMPTRACK, "DAMPTRACK", 0, "Damped Track Constraint", ""}, + {CREATE_TRACK_TRACKTO, "TRACKTO", 0, "Track To Constraint", ""}, + {CREATE_TRACK_LOCKTRACK, "LOCKTRACK", 0, "Lock Track Constraint", ""}, {0, NULL, 0, NULL, NULL} }; @@ -1175,78 +1191,86 @@ static int track_set_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Object *obact = ED_object_active_context(C); - - int type = RNA_enum_get(op->ptr, "type"); - - if (type == 1) { - bConstraint *con; - bDampTrackConstraint *data; - CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) + const int type = RNA_enum_get(op->ptr, "type"); + + switch (type) { + case CREATE_TRACK_DAMPTRACK: { - if (ob != obact) { - con = BKE_constraint_add_for_object(ob, "AutoTrack", CONSTRAINT_TYPE_DAMPTRACK); + bConstraint *con; + bDampTrackConstraint *data; - data = con->data; - data->tar = obact; - DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); - - /* Lamp, Camera and Speaker track differently by default */ - if (ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_SPEAKER)) { - data->trackflag = TRACK_nZ; + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) + { + if (ob != obact) { + con = BKE_constraint_add_for_object(ob, "AutoTrack", CONSTRAINT_TYPE_DAMPTRACK); + + data = con->data; + data->tar = obact; + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); + + /* Lamp, Camera and Speaker track differently by default */ + if (ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_SPEAKER)) { + data->trackflag = TRACK_nZ; + } } } + CTX_DATA_END; + break; } - CTX_DATA_END; - } - else if (type == 2) { - bConstraint *con; - bTrackToConstraint *data; - - CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) + case CREATE_TRACK_TRACKTO: { - if (ob != obact) { - con = BKE_constraint_add_for_object(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO); + bConstraint *con; + bTrackToConstraint *data; - data = con->data; - data->tar = obact; - DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); - - /* Lamp, Camera and Speaker track differently by default */ - if (ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_SPEAKER)) { - data->reserved1 = TRACK_nZ; - data->reserved2 = UP_Y; + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) + { + if (ob != obact) { + con = BKE_constraint_add_for_object(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO); + + data = con->data; + data->tar = obact; + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); + + /* Lamp, Camera and Speaker track differently by default */ + if (ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_SPEAKER)) { + data->reserved1 = TRACK_nZ; + data->reserved2 = UP_Y; + } } } + CTX_DATA_END; + break; } - CTX_DATA_END; - } - else if (type == 3) { - bConstraint *con; - bLockTrackConstraint *data; - - CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) + case CREATE_TRACK_LOCKTRACK: { - if (ob != obact) { - con = BKE_constraint_add_for_object(ob, "AutoTrack", CONSTRAINT_TYPE_LOCKTRACK); + bConstraint *con; + bLockTrackConstraint *data; - data = con->data; - data->tar = obact; - DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); - - /* Lamp, Camera and Speaker track differently by default */ - if (ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_SPEAKER)) { - data->trackflag = TRACK_nZ; - data->lockflag = LOCK_Y; + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) + { + if (ob != obact) { + con = BKE_constraint_add_for_object(ob, "AutoTrack", CONSTRAINT_TYPE_LOCKTRACK); + + data = con->data; + data->tar = obact; + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); + + /* Lamp, Camera and Speaker track differently by default */ + if (ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_SPEAKER)) { + data->trackflag = TRACK_nZ; + data->lockflag = LOCK_Y; + } } } + CTX_DATA_END; + break; } - CTX_DATA_END; } - + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); - + return OPERATOR_FINISHED; } @@ -1254,18 +1278,18 @@ void OBJECT_OT_track_set(wmOperatorType *ot) { /* identifiers */ ot->name = "Make Track"; - ot->description = "Make the object track another object, either by constraint or old way or locked track"; + ot->description = "Make the object track another object, using various methods/constraints"; ot->idname = "OBJECT_OT_track_set"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = track_set_exec; - + ot->poll = ED_operator_objectmode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", prop_make_track_types, 0, "Type", ""); } @@ -1287,7 +1311,7 @@ static unsigned int move_to_layer_init(bContext *C, wmOperator *op) for (a = 0; a < 20; a++) values[a] = (lay & (1 << a)); - + RNA_boolean_set_array(op->ptr, "layers", values); } else { @@ -1320,12 +1344,12 @@ static int move_to_layer_exec(bContext *C, wmOperator *op) View3D *v3d = CTX_wm_view3d(C); unsigned int lay, local; /* bool is_lamp = false; */ /* UNUSED */ - + lay = move_to_layer_init(C, op); lay &= 0xFFFFFF; if (lay == 0) return OPERATOR_CANCELLED; - + if (v3d && v3d->localvd) { /* now we can move out of localview. */ /* note: layers are set in bases, library objects work for this */ @@ -1353,9 +1377,9 @@ static int move_to_layer_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } - + /* warning, active object may be hidden now */ - + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, scene); WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene); @@ -1370,15 +1394,15 @@ void OBJECT_OT_move_to_layer(wmOperatorType *ot) ot->name = "Move to Layer"; ot->description = "Move the object to different layers"; ot->idname = "OBJECT_OT_move_to_layer"; - + /* api callbacks */ ot->invoke = move_to_layer_invoke; ot->exec = move_to_layer_exec; ot->poll = ED_operator_objectmode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean_layer_member(ot->srna, "layers", 20, NULL, "Layer", ""); } @@ -1390,13 +1414,12 @@ static void link_to_scene(Main *UNUSED(bmain), unsigned short UNUSED(nr)) { Scene *sce = (Scene *) BLI_findlink(&bmain->scene, G.curscreen->scenenr - 1); Base *base, *nbase; - - if (sce == 0) return; + + if (sce == NULL) return; if (sce->id.lib) return; - + for (base = FIRSTBASE; base; base = base->next) { if (TESTBASE(v3d, base)) { - nbase = MEM_mallocN(sizeof(Base), "newbase"); *nbase = *base; BLI_addhead(&(sce->base), nbase); @@ -1453,48 +1476,45 @@ static int make_links_scene_exec(bContext *C, wmOperator *op) } enum { - MAKE_LINKS_OBDATA = 1, - MAKE_LINKS_MATERIALS, - MAKE_LINKS_ANIMDATA, - MAKE_LINKS_GROUP, - MAKE_LINKS_DUPLIGROUP, - MAKE_LINKS_MODIFIERS, - MAKE_LINKS_FONTS + MAKE_LINKS_OBDATA = 1, + MAKE_LINKS_MATERIALS = 2, + MAKE_LINKS_ANIMDATA = 3, + MAKE_LINKS_GROUP = 4, + MAKE_LINKS_DUPLIGROUP = 5, + MAKE_LINKS_MODIFIERS = 6, + MAKE_LINKS_FONTS = 7, }; -/* Return 1 if make link data is allow, zero otherwise */ -static int allow_make_links_data(const int type, Object *ob_src, Object *ob_dst) +/* Return true if make link data is allowed, false otherwise */ +static bool allow_make_links_data(const int type, Object *ob_src, Object *ob_dst) { switch (type) { case MAKE_LINKS_OBDATA: - if (ob_src->type == ob_dst->type && ob_src->type != OB_EMPTY) - return 1; + if (ob_src->type == ob_dst->type && ob_src->type != OB_EMPTY) { + return true; + } break; case MAKE_LINKS_MATERIALS: - if (OB_TYPE_SUPPORT_MATERIAL(ob_src->type) && - OB_TYPE_SUPPORT_MATERIAL(ob_dst->type)) - { - return 1; + if (OB_TYPE_SUPPORT_MATERIAL(ob_src->type) && OB_TYPE_SUPPORT_MATERIAL(ob_dst->type)) { + return true; } break; case MAKE_LINKS_ANIMDATA: case MAKE_LINKS_GROUP: case MAKE_LINKS_DUPLIGROUP: - return 1; + return true; case MAKE_LINKS_MODIFIERS: - if (ob_src->type != OB_EMPTY && ob_dst->type != OB_EMPTY) - return 1; + if (!ELEM(OB_EMPTY, ob_src->type, ob_dst->type)) { + return true; + } break; case MAKE_LINKS_FONTS: - if ((ob_src->data != ob_dst->data) && - (ob_src->type == OB_FONT) && - (ob_dst->type == OB_FONT)) - { - return 1; + if ((ob_src->data != ob_dst->data) && (ob_src->type == OB_FONT) && (ob_dst->type == OB_FONT)) { + return true; } break; } - return 0; + return false; } static int make_links_data_exec(bContext *C, wmOperator *op) @@ -1697,13 +1717,13 @@ void OBJECT_OT_make_links_data(wmOperatorType *ot) /**************************** Make Single User ********************************/ -static void single_object_users(Main *bmain, Scene *scene, View3D *v3d, int flag, bool copy_groups) +static void single_object_users(Main *bmain, Scene *scene, View3D *v3d, const int flag, const bool copy_groups) { Base *base; Object *ob, *obn; Group *group, *groupn; GroupObject *go; - + clear_sca_new_poins(); /* sensor/contr/act */ /* newid may still have some trash from Outliner tree building, @@ -1714,7 +1734,7 @@ static void single_object_users(Main *bmain, Scene *scene, View3D *v3d, int flag /* duplicate (must set newid) */ for (base = FIRSTBASE; base; base = base->next) { ob = base->object; - + if ((base->flag & flag) == flag) { if (ob->id.lib == NULL && ob->id.us > 1) { /* base gets copy of object */ @@ -1761,10 +1781,10 @@ static void single_object_users(Main *bmain, Scene *scene, View3D *v3d, int flag /* group pointers in scene */ BKE_scene_groups_relink(scene); - + ID_NEW(scene->camera); if (v3d) ID_NEW(v3d->camera); - + /* object and group pointers */ for (base = FIRSTBASE; base; base = base->next) { BKE_object_relink(base->object); @@ -1778,7 +1798,7 @@ static void single_object_users(Main *bmain, Scene *scene, View3D *v3d, int flag void ED_object_single_user(Main *bmain, Scene *scene, Object *ob) { Base *base; - bool copy_groups = false; + const bool copy_groups = false; for (base = FIRSTBASE; base; base = base->next) { if (base->object == ob) base->flag |= OB_DONE; @@ -1788,11 +1808,11 @@ void ED_object_single_user(Main *bmain, Scene *scene, Object *ob) single_object_users(bmain, scene, NULL, OB_DONE, copy_groups); } -static void new_id_matar(Material **matar, int totcol) +static void new_id_matar(Material **matar, const int totcol) { ID *id; int a; - + for (a = 0; a < totcol; a++) { id = (ID *)matar[a]; if (id && id->lib == NULL) { @@ -1810,12 +1830,12 @@ static void new_id_matar(Material **matar, int totcol) } } -static void single_obdata_users(Main *bmain, Scene *scene, int flag) +static void single_obdata_users(Main *bmain, Scene *scene, const int flag) { Object *ob; Lamp *la; Curve *cu; - //Camera *cam; + /* Camera *cam; */ Base *base; Mesh *me; Lattice *lat; @@ -1826,7 +1846,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) ob = base->object; if (ob->id.lib == NULL && (base->flag & flag) == flag) { id = ob->data; - + if (id && id->us > 1 && id->lib == NULL) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -1887,12 +1907,10 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) id->us--; id->newid = ob->data; - } - } } - + me = bmain->mesh.first; while (me) { ID_NEW(me->texcomesh); @@ -1900,11 +1918,11 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) } } -static void single_object_action_users(Scene *scene, int flag) +static void single_object_action_users(Scene *scene, const int flag) { Object *ob; Base *base; - + for (base = FIRSTBASE; base; base = base->next) { ob = base->object; if (ob->id.lib == NULL && (flag == 0 || (base->flag & SELECT)) ) { @@ -1914,27 +1932,26 @@ static void single_object_action_users(Scene *scene, int flag) } } -static void single_mat_users(Scene *scene, int flag, int do_textures) +static void single_mat_users(Scene *scene, const int flag, const bool do_textures) { Object *ob; Base *base; Material *ma, *man; Tex *tex; int a, b; - + for (base = FIRSTBASE; base; base = base->next) { ob = base->object; if (ob->id.lib == NULL && (flag == 0 || (base->flag & SELECT)) ) { - for (a = 1; a <= ob->totcol; a++) { ma = give_current_material(ob, a); if (ma) { /* do not test for LIB_NEW: this functions guaranteed delivers single_users! */ - + if (ma->id.us > 1) { man = BKE_material_copy(ma); BKE_copy_animdata_id_action(&man->id); - + man->id.us = 0; assign_material(ob, man, a, BKE_MAT_ASSIGN_USERPREF); @@ -1960,10 +1977,10 @@ static void single_mat_users(Scene *scene, int flag, int do_textures) static void do_single_tex_user(Tex **from) { Tex *tex, *texn; - + tex = *from; if (tex == NULL) return; - + if (tex->id.newid) { *from = (Tex *)tex->id.newid; id_us_plus(tex->id.newid); @@ -1985,7 +2002,7 @@ static void single_tex_users_expand(Main *bmain) Lamp *la; World *wo; int b; - + for (ma = bmain->mat.first; ma; ma = ma->id.next) { if (ma->id.flag & LIB_NEW) { for (b = 0; b < MAX_MTEX; b++) { @@ -2026,7 +2043,7 @@ static void single_mat_users_expand(Main *bmain) MetaBall *mb; Material *ma; int a; - + for (ob = bmain->object.first; ob; ob = ob->id.next) if (ob->id.flag & LIB_NEW) new_id_matar(ob->mat, ob->totcol); @@ -2052,7 +2069,7 @@ static void single_mat_users_expand(Main *bmain) } /* used for copying scenes */ -void ED_object_single_users(Main *bmain, Scene *scene, bool full, bool copy_groups) +void ED_object_single_users(Main *bmain, Scene *scene, const bool full, const bool copy_groups) { single_object_users(bmain, scene, NULL, 0, copy_groups); @@ -2073,13 +2090,13 @@ static void make_local_makelocalmaterial(Material *ma) { AnimData *adt; int b; - + id_make_local(&ma->id, false); - + for (b = 0; b < MAX_MTEX; b++) if (ma->mtex[b] && ma->mtex[b]->tex) id_make_local(&ma->mtex[b]->tex->id, false); - + adt = BKE_animdata_from_id(&ma->id); if (adt) BKE_animdata_make_local(adt); @@ -2087,13 +2104,13 @@ static void make_local_makelocalmaterial(Material *ma) } enum { - MAKE_LOCAL_SELECT_OB, - MAKE_LOCAL_SELECT_OBDATA, - MAKE_LOCAL_SELECT_OBDATA_MATERIAL, - MAKE_LOCAL_ALL + MAKE_LOCAL_SELECT_OB = 1, + MAKE_LOCAL_SELECT_OBDATA = 2, + MAKE_LOCAL_SELECT_OBDATA_MATERIAL = 3, + MAKE_LOCAL_ALL = 4, }; -static bool tag_localizable_looper(void *UNUSED(user_data), ID **id_pointer, int UNUSED(cd_flag)) +static bool tag_localizable_looper(void *UNUSED(user_data), ID **id_pointer, const int UNUSED(cd_flag)) { if (*id_pointer) { (*id_pointer)->flag &= ~LIB_DOIT; @@ -2101,7 +2118,7 @@ static bool tag_localizable_looper(void *UNUSED(user_data), ID **id_pointer, int return true; } -static void tag_localizable_objects(bContext *C, int mode) +static void tag_localizable_objects(bContext *C, const int mode) { Main *bmain = CTX_data_main(C); Object *object; @@ -2182,8 +2199,9 @@ static int make_local_exec(bContext *C, wmOperator *op) Material *ma, ***matarar; Lamp *la; ID *id; - int a, b, mode = RNA_enum_get(op->ptr, "type"); - + const int mode = RNA_enum_get(op->ptr, "type"); + int a, b; + if (mode == MAKE_LOCAL_ALL) { /* de-select so the user can differentiate newly instanced from existing objects */ BKE_scene_base_deselect_all(scene); @@ -2200,7 +2218,7 @@ static int make_local_exec(bContext *C, wmOperator *op) tag_localizable_objects(C, mode); BKE_main_id_clear_newpoins(bmain); - + CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { if ((ob->id.flag & LIB_DOIT) == 0) { @@ -2211,7 +2229,7 @@ static int make_local_exec(bContext *C, wmOperator *op) id_make_local(&ob->id, false); } CTX_DATA_END; - + /* maybe object pointers */ CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { @@ -2228,12 +2246,12 @@ static int make_local_exec(bContext *C, wmOperator *op) } id = ob->data; - + if (id && (ELEM(mode, MAKE_LOCAL_SELECT_OBDATA, MAKE_LOCAL_SELECT_OBDATA_MATERIAL))) { id_make_local(id, false); adt = BKE_animdata_from_id(id); if (adt) BKE_animdata_make_local(adt); - + /* tag indirect data direct */ matarar = give_matarar(ob); if (matarar) { @@ -2273,7 +2291,7 @@ static int make_local_exec(bContext *C, wmOperator *op) if (ma) make_local_makelocalmaterial(ma); } - + matarar = (Material ***)give_matarar(ob); if (matarar) { for (a = 0; a < ob->totcol; a++) { @@ -2306,26 +2324,33 @@ void OBJECT_OT_make_local(wmOperatorType *ot) ot->name = "Make Local"; ot->description = "Make library linked datablocks local to this file"; ot->idname = "OBJECT_OT_make_local"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = make_local_exec; ot->poll = ED_operator_objectmode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", ""); } +enum { + /* Be careful with those values, they are used as bitflags in some cases, in others as bool... + * See single_object_users, single_obdata_users, single_object_action_users, etc.< */ + MAKE_SINGLE_USER_ALL = 0, + MAKE_SINGLE_USER_SELECTED = SELECT, +}; + static int make_single_user_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); /* ok if this is NULL */ - int flag = RNA_enum_get(op->ptr, "type"); /* 0==ALL, SELECTED==selected objecs */ - bool copy_groups = false; + const int flag = RNA_enum_get(op->ptr, "type"); + const bool copy_groups = false; bool update_deps = false; BKE_main_id_clear_newpoins(bmain); @@ -2372,8 +2397,8 @@ static int make_single_user_exec(bContext *C, wmOperator *op) void OBJECT_OT_make_single_user(wmOperatorType *ot) { static EnumPropertyItem type_items[] = { - {SELECT, "SELECTED_OBJECTS", 0, "Selected Objects", ""}, - {0, "ALL", 0, "All", ""}, + {MAKE_SINGLE_USER_SELECTED, "SELECTED_OBJECTS", 0, "Selected Objects", ""}, + {MAKE_SINGLE_USER_ALL, "ALL", 0, "All", ""}, {0, NULL, 0, NULL, NULL}}; /* identifiers */ @@ -2395,7 +2420,8 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot) RNA_def_boolean(ot->srna, "object", 0, "Object", "Make single user objects"); RNA_def_boolean(ot->srna, "obdata", 0, "Object Data", "Make single user object data"); RNA_def_boolean(ot->srna, "material", 0, "Materials", "Make materials local to each datablock"); - RNA_def_boolean(ot->srna, "texture", 0, "Textures", "Make textures local to each material"); + RNA_def_boolean(ot->srna, "texture", 0, "Textures", + "Make textures local to each material (needs 'Materials' to be set too)"); RNA_def_boolean(ot->srna, "animation", 0, "Object Animation", "Make animation data local to each object"); } @@ -2404,12 +2430,12 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent Base *base = ED_view3d_give_base_under_cursor(C, event->mval); Material *ma; char name[MAX_ID_NAME - 2]; - + RNA_string_get(op->ptr, "name", name); ma = (Material *)BKE_libblock_find_name(ID_MA, name); if (base == NULL || ma == NULL) return OPERATOR_CANCELLED; - + assign_material(base->object, ma, 1, BKE_MAT_ASSIGN_USERPREF); DAG_id_tag_update(&base->object->id, OB_RECALC_OB); @@ -2425,19 +2451,18 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent /* assigns to object under cursor, only first material slot */ void OBJECT_OT_drop_named_material(wmOperatorType *ot) { - /* identifiers */ ot->name = "Drop Named Material on Object"; ot->description = ""; ot->idname = "OBJECT_OT_drop_named_material"; - + /* api callbacks */ ot->invoke = drop_named_material_invoke; ot->poll = ED_operator_objectmode; - + /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; - + /* properties */ RNA_def_string(ot->srna, "name", "Material", MAX_ID_NAME - 2, "Name", "Material name to assign"); } diff --git a/source/blender/editors/physics/CMakeLists.txt b/source/blender/editors/physics/CMakeLists.txt index 892d71befb4..40d555226f3 100644 --- a/source/blender/editors/physics/CMakeLists.txt +++ b/source/blender/editors/physics/CMakeLists.txt @@ -23,11 +23,13 @@ set(INC ../../blenfont ../../blenkernel ../../blenlib + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/elbeem/extern ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -64,4 +66,6 @@ if(WITH_BULLET) add_definitions(-DWITH_BULLET) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_physics "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/physics/SConscript b/source/blender/editors/physics/SConscript index 9436280de43..983d1c4b4ba 100644 --- a/source/blender/editors/physics/SConscript +++ b/source/blender/editors/physics/SConscript @@ -31,20 +31,22 @@ sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '#/intern/rigidbody', - '#/extern/glew/include', '#/intern/elbeem/extern', '../include', '../../blenfont', '../../blenkernel', '../../blenlib', + '../../gpu', '../../makesdna', '../../makesrna', '../../windowmanager', ] incs = ' '.join(incs) -defs = [] +defs = env['BF_GL_DEFINITIONS'] if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): incs += ' ' + env['BF_PTHREADS_INC'] diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 76344b77dd3..9a3433b0ccf 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -1588,6 +1588,87 @@ void PARTICLE_OT_select_tips(wmOperatorType *ot) WM_operator_properties_select_action(ot, SEL_SELECT); } +/*********************** select random operator ************************/ + +enum { RAN_HAIR, RAN_POINTS }; + +static EnumPropertyItem select_random_type_items[] = { + {RAN_HAIR, "HAIR", 0, "Hair", ""}, + {RAN_POINTS, "POINTS", 0, "Points", ""}, + {0, NULL, 0, NULL, NULL} +}; + +static int select_random_exec(bContext *C, wmOperator *op) +{ + PEData data; + int type; + Scene *scene; + Object *ob; + + /* used by LOOP_VISIBLE_POINTS, LOOP_VISIBLE_KEYS and LOOP_KEYS */ + PTCacheEdit *edit; + PTCacheEditPoint *point; + PTCacheEditKey *key; + int p; + int k; + + const float randf = RNA_float_get (op->ptr, "percent") / 100.0f; + + type = RNA_enum_get(op->ptr, "type"); + + PE_set_data(C, &data); + data.select_action = SEL_SELECT; + scene = CTX_data_scene(C); + ob = CTX_data_active_object(C); + edit = PE_get_current(scene, ob); + + switch (type) { + case RAN_HAIR: + LOOP_VISIBLE_POINTS { + int flag = (BLI_frand() < randf) ? SEL_SELECT : SEL_DESELECT; + LOOP_KEYS { + select_action_apply (point, key, flag); + } + } + break; + case RAN_POINTS: + LOOP_VISIBLE_POINTS { + LOOP_VISIBLE_KEYS { + int flag = (BLI_frand() < randf) ? SEL_SELECT : SEL_DESELECT; + select_action_apply (point, key, flag); + } + } + break; + } + + PE_update_selection(data.scene, data.ob, 1); + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_SELECTED, data.ob); + + return OPERATOR_FINISHED; +} + +void PARTICLE_OT_select_random(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Select Random"; + ot->idname = "PARTICLE_OT_select_random"; + ot->description = "Select a randomly distributed set of hair or points"; + + /* api callbacks */ + ot->exec = select_random_exec; + ot->poll = PE_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_float_percentage (ot->srna, "percent", 50.0f, 0.0f, 100.0f, "Percent", + "Percentage (mean) of elements in randomly selected set", + 0.0f, 100.0f); + ot->prop = RNA_def_enum (ot->srna, "type", select_random_type_items, RAN_HAIR, + "Type", "Select either hair or points"); +} + /************************ select linked operator ************************/ static int select_linked_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h index 77ce5a334e6..b8955c8c397 100644 --- a/source/blender/editors/physics/physics_intern.h +++ b/source/blender/editors/physics/physics_intern.h @@ -39,6 +39,7 @@ struct wmOperatorType; void PARTICLE_OT_select_all(struct wmOperatorType *ot); void PARTICLE_OT_select_roots(struct wmOperatorType *ot); void PARTICLE_OT_select_tips(struct wmOperatorType *ot); +void PARTICLE_OT_select_random(struct wmOperatorType *ot); void PARTICLE_OT_select_linked(struct wmOperatorType *ot); void PARTICLE_OT_select_less(struct wmOperatorType *ot); void PARTICLE_OT_select_more(struct wmOperatorType *ot); diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c index 48cc51ffb55..ff89909b124 100644 --- a/source/blender/editors/physics/physics_ops.c +++ b/source/blender/editors/physics/physics_ops.c @@ -51,6 +51,7 @@ static void operatortypes_particle(void) WM_operatortype_append(PARTICLE_OT_select_all); WM_operatortype_append(PARTICLE_OT_select_roots); WM_operatortype_append(PARTICLE_OT_select_tips); + WM_operatortype_append(PARTICLE_OT_select_random); WM_operatortype_append(PARTICLE_OT_select_linked); WM_operatortype_append(PARTICLE_OT_select_less); WM_operatortype_append(PARTICLE_OT_select_more); diff --git a/source/blender/editors/render/CMakeLists.txt b/source/blender/editors/render/CMakeLists.txt index 24015bd4ea3..42dafc076ed 100644 --- a/source/blender/editors/render/CMakeLists.txt +++ b/source/blender/editors/render/CMakeLists.txt @@ -32,6 +32,7 @@ set(INC ../../render/extern/include ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -64,6 +65,8 @@ if(WITH_HEADLESS) add_definitions(-DWITH_HEADLESS) endif() +add_definitions(${GL_DEFINITIONS}) + if(WITH_FREESTYLE) list(APPEND INC ../../freestyle diff --git a/source/blender/editors/render/SConscript b/source/blender/editors/render/SConscript index 41576f9b485..cbb7988695b 100644 --- a/source/blender/editors/render/SConscript +++ b/source/blender/editors/render/SConscript @@ -31,7 +31,8 @@ sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '#/intern/elbeem/extern', '../include', '../../blenfont', @@ -48,7 +49,7 @@ incs = [ ] incs = ' '.join(incs) -defs = [] +defs = env['BF_GL_DEFINITIONS'] if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): incs += ' ' + env['BF_PTHREADS_INC'] diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index ecf5e962c80..559c86bf48c 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -31,8 +31,6 @@ #include <string.h> #include <stddef.h> -#include <GL/glew.h> - #include "MEM_guardedalloc.h" #include "BLI_math.h" @@ -69,6 +67,7 @@ #include "RNA_define.h" #include "GPU_extensions.h" +#include "GPU_glew.h" #include "wm_window.h" diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 70c9e3c4306..450a3b19889 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -88,6 +88,7 @@ #include "PIL_time.h" #include "RE_pipeline.h" +#include "RE_engine.h" #include "WM_api.h" #include "WM_types.h" @@ -213,6 +214,12 @@ void ED_preview_init_dbase(void) #endif } +static bool check_engine_supports_textures(Scene *scene) +{ + RenderEngineType *type = RE_engines_find(scene->r.engine); + return type->flag & RE_USE_TEXTURE_PREVIEW; +} + void ED_preview_free_dbase(void) { if (G_pr_main) @@ -299,7 +306,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre sce->r.cfra = scene->r.cfra; - if (id_type == ID_TE) { + if (id_type == ID_TE && !check_engine_supports_textures(scene)) { /* Force blender internal for texture icons and nodes render, * seems commonly used render engines does not support * such kind of rendering. diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt index 4ff1767f582..413d40b9f9c 100644 --- a/source/blender/editors/screen/CMakeLists.txt +++ b/source/blender/editors/screen/CMakeLists.txt @@ -30,6 +30,7 @@ set(INC ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -51,4 +52,6 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_screen "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/screen/SConscript b/source/blender/editors/screen/SConscript index 28a6cbb02e6..f5442c7ea63 100644 --- a/source/blender/editors/screen/SConscript +++ b/source/blender/editors/screen/SConscript @@ -31,7 +31,8 @@ sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../../blenfont', '../../blenkernel', @@ -45,7 +46,7 @@ incs = [ ] incs = ' '.join(incs) -defs = [] +defs = env['BF_GL_DEFINITIONS'] if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): incs += ' ' + env['BF_PTHREADS_INC'] diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 0edde66ffff..c095dfe7792 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -224,15 +224,15 @@ void fdrawcheckerboard(float x1, float y1, float x2, float y2) glDisable(GL_POLYGON_STIPPLE); } -void sdrawline(short x1, short y1, short x2, short y2) +void sdrawline(int x1, int y1, int x2, int y2) { - short v[2]; + int v[2]; glBegin(GL_LINE_STRIP); v[0] = x1; v[1] = y1; - glVertex2sv(v); + glVertex2iv(v); v[0] = x2; v[1] = y2; - glVertex2sv(v); + glVertex2iv(v); glEnd(); } @@ -246,25 +246,25 @@ void sdrawline(short x1, short y1, short x2, short y2) * x1,y1-- x2,y1 */ -static void sdrawtripoints(short x1, short y1, short x2, short y2) +static void sdrawtripoints(int x1, int y1, int x2, int y2) { - short v[2]; + int v[2]; v[0] = x1; v[1] = y1; - glVertex2sv(v); + glVertex2iv(v); v[0] = x1; v[1] = y2; - glVertex2sv(v); + glVertex2iv(v); v[0] = x2; v[1] = y1; - glVertex2sv(v); + glVertex2iv(v); } -void sdrawtri(short x1, short y1, short x2, short y2) +void sdrawtri(int x1, int y1, int x2, int y2) { glBegin(GL_LINE_STRIP); sdrawtripoints(x1, y1, x2, y2); glEnd(); } -void sdrawtrifill(short x1, short y1, short x2, short y2) +void sdrawtrifill(int x1, int y1, int x2, int y2) { glBegin(GL_TRIANGLES); sdrawtripoints(x1, y1, x2, y2); @@ -272,22 +272,22 @@ void sdrawtrifill(short x1, short y1, short x2, short y2) } #endif -void sdrawbox(short x1, short y1, short x2, short y2) +void sdrawbox(int x1, int y1, int x2, int y2) { - short v[2]; + int v[2]; glBegin(GL_LINE_STRIP); v[0] = x1; v[1] = y1; - glVertex2sv(v); + glVertex2iv(v); v[0] = x1; v[1] = y2; - glVertex2sv(v); + glVertex2iv(v); v[0] = x2; v[1] = y2; - glVertex2sv(v); + glVertex2iv(v); v[0] = x2; v[1] = y1; - glVertex2sv(v); + glVertex2iv(v); v[0] = x1; v[1] = y1; - glVertex2sv(v); + glVertex2iv(v); glEnd(); } @@ -339,7 +339,7 @@ void sdrawXORline(int x0, int y0, int x1, int y1) void sdrawXORline4(int nr, int x0, int y0, int x1, int y1) { - static short old[4][2][2]; + static int old[4][2][2]; static char flags[4] = {0, 0, 0, 0}; /* with builtin memory, max 4 lines */ @@ -350,8 +350,8 @@ void sdrawXORline4(int nr, int x0, int y0, int x1, int y1) if (nr == -1) { /* flush */ for (nr = 0; nr < 4; nr++) { if (flags[nr]) { - glVertex2sv(old[nr][0]); - glVertex2sv(old[nr][1]); + glVertex2iv(old[nr][0]); + glVertex2iv(old[nr][1]); flags[nr] = 0; } } @@ -359,8 +359,8 @@ void sdrawXORline4(int nr, int x0, int y0, int x1, int y1) else { if (nr >= 0 && nr < 4) { if (flags[nr]) { - glVertex2sv(old[nr][0]); - glVertex2sv(old[nr][1]); + glVertex2iv(old[nr][0]); + glVertex2iv(old[nr][1]); } old[nr][0][0] = x0; diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 5beab9fcc14..12236e3779d 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1009,7 +1009,7 @@ static void scrarea_draw_shape_light(ScrArea *sa, char UNUSED(dir)) glDisable(GL_BLEND); } -static void drawscredge_area_draw(int sizex, int sizey, short x1, short y1, short x2, short y2, short a) +static void drawscredge_area_draw(int sizex, int sizey, int x1, int y1, int x2, int y2, int a) { /* right border area */ if (x2 < sizex - 1) diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index 18db57c9f21..0fa5f2d9837 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -32,6 +32,7 @@ set(INC ../../render/extern/include ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -64,4 +65,6 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_sculpt_paint "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/sculpt_paint/SConscript b/source/blender/editors/sculpt_paint/SConscript index b0118fbbf53..233f562fcc7 100644 --- a/source/blender/editors/sculpt_paint/SConscript +++ b/source/blender/editors/sculpt_paint/SConscript @@ -29,11 +29,12 @@ Import ('env') sources = env.Glob('*.c') -defs = [] +defs = env['BF_GL_DEFINITIONS'] incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../uvedit', '../../blenfont', diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 7b9ede38b39..e27ef705fad 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -521,14 +521,15 @@ static int project_brush_radius(ViewContext *vc, } } -static int sculpt_get_brush_geometry(bContext *C, ViewContext *vc, - int x, int y, int *pixel_radius, - float location[3]) +static bool sculpt_get_brush_geometry( + bContext *C, ViewContext *vc, + int x, int y, int *pixel_radius, + float location[3]) { Scene *scene = CTX_data_scene(C); Paint *paint = BKE_paint_get_active_from_context(C); float mouse[2]; - int hit; + bool hit; mouse[0] = x; mouse[1] = y; @@ -1011,7 +1012,8 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) * special mode of drawing will go away */ if ((mode == PAINT_SCULPT) && vc.obact->sculpt) { float location[3]; - int pixel_radius, hit; + int pixel_radius; + bool hit; /* test if brush is over the mesh */ hit = sculpt_get_brush_geometry(C, &vc, x, y, &pixel_radius, location); diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index 8faa4cfaf33..25f22996050 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -277,7 +277,7 @@ int ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *r typedef struct LassoMaskData { struct ViewContext *vc; float projviewobjmat[4][4]; - bool *px; + BLI_bitmap *px; int width; rcti rect; /* bounding box for scanfilling */ int symmpass; @@ -307,19 +307,19 @@ static bool is_effected_lasso(LassoMaskData *data, float co[3]) scr_co_s[0] -= data->rect.xmin; scr_co_s[1] -= data->rect.ymin; - return data->px[scr_co_s[1] * data->width + scr_co_s[0]]; + return BLI_BITMAP_TEST_BOOL(data->px, scr_co_s[1] * data->width + scr_co_s[0]); } static void mask_lasso_px_cb(int x, int y, void *user_data) { struct LassoMaskData *data = user_data; - data->px[(y * data->width) + x] = true; + BLI_BITMAP_ENABLE(data->px, (y * data->width) + x); } static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) { int mcords_tot; - int (*mcords)[2] = (int (*)[2])WM_gesture_lasso_path_to_array(C, op, &mcords_tot); + const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); if (mcords) { float clip_planes[4][4], clip_planes_final[4][4]; @@ -349,13 +349,13 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) ob = vc.obact; ED_view3d_ob_project_mat_get(vc.rv3d, ob, data.projviewobjmat); - BLI_lasso_boundbox(&data.rect, (const int (*)[2])mcords, mcords_tot); + BLI_lasso_boundbox(&data.rect, mcords, mcords_tot); data.width = data.rect.xmax - data.rect.xmin; - data.px = MEM_callocN(sizeof(*data.px) * data.width * (data.rect.ymax - data.rect.ymin), "lasso_mask_pixel_buffer"); + data.px = BLI_BITMAP_NEW(data.width * (data.rect.ymax - data.rect.ymin), __func__); fill_poly_v2i_n( data.rect.xmin, data.rect.ymin, data.rect.xmax, data.rect.ymax, - (const int (*)[2])mcords, mcords_tot, + mcords, mcords_tot, mask_lasso_px_cb, &data); ED_view3d_clipping_calc(&bb, clip_planes, &mats, &data.rect); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 101d176b00f..9c4701d0a01 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -68,6 +68,12 @@ #include <float.h> #include <math.h> +// #define DEBUG_TIME + +#ifdef DEBUG_TIME +# include "PIL_time_utildefines.h" +#endif + typedef struct PaintSample { float mouse[2]; float pressure; @@ -910,6 +916,7 @@ static void paint_stroke_line_end(bContext *C, wmOperator *op, PaintStroke *stro static bool paint_stroke_curve_end(bContext *C, wmOperator *op, PaintStroke *stroke) { Brush *br = stroke->brush; + if (br->flag & BRUSH_CURVE) { const Scene *scene = CTX_data_scene(C); const float spacing = paint_space_stroke_spacing(scene, stroke, 1.0f, 1.0f); @@ -921,6 +928,10 @@ static bool paint_stroke_curve_end(bContext *C, wmOperator *op, PaintStroke *str if (!pc) return true; +#ifdef DEBUG_TIME + TIMEIT_START(stroke); +#endif + pcp = pc->points; stroke->ups->overlap_factor = paint_stroke_integrate_overlap(br, 1.0); @@ -956,6 +967,11 @@ static bool paint_stroke_curve_end(bContext *C, wmOperator *op, PaintStroke *str } stroke_done(C, op); + +#ifdef DEBUG_TIME + TIMEIT_END(stroke); +#endif + return true; } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index c1f52c58793..abdc184aa1a 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -268,8 +268,8 @@ typedef struct { /* Original coordinate, normal, and mask */ const float *co; - float mask; const short *no; + float mask; } SculptOrigVertData; @@ -4066,14 +4066,14 @@ static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob) typedef struct { SculptSession *ss; const float *ray_start, *ray_normal; - int hit; + bool hit; float dist; - int original; + bool original; } SculptRaycastData; typedef struct { const float *ray_start, *ray_normal; - int hit; + bool hit; float dist; float detail; } SculptDetailRaycastData; @@ -4205,7 +4205,7 @@ static void sculpt_brush_init_tex(const Scene *scene, Sculpt *sd, SculptSession sculpt_update_tex(scene, sd, ss); } -static int sculpt_brush_stroke_init(bContext *C, wmOperator *op) +static bool sculpt_brush_stroke_init(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); diff --git a/source/blender/editors/space_action/CMakeLists.txt b/source/blender/editors/space_action/CMakeLists.txt index e0dc2709cf3..96a1e74c882 100644 --- a/source/blender/editors/space_action/CMakeLists.txt +++ b/source/blender/editors/space_action/CMakeLists.txt @@ -22,10 +22,12 @@ set(INC ../include ../../blenkernel ../../blenlib + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -42,4 +44,6 @@ set(SRC action_intern.h ) +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_space_action "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_action/SConscript b/source/blender/editors/space_action/SConscript index 2776bd2989a..2e2081b3c6e 100644 --- a/source/blender/editors/space_action/SConscript +++ b/source/blender/editors/space_action/SConscript @@ -29,16 +29,20 @@ Import ('env') sources = env.Glob('*.c') +defs = env['BF_GL_DEFINITIONS'] + incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../../blenkernel', '../../blenlib', + '../../gpu', '../../makesdna', '../../makesrna', '../../windowmanager', ] incs = ' '.join(incs) -env.BlenderLib ( 'bf_editors_space_action', sources, Split(incs), [], libtype=['core'], priority=[40] ) +env.BlenderLib ( 'bf_editors_space_action', sources, Split(incs), defs, libtype=['core'], priority=[40] ) diff --git a/source/blender/editors/space_buttons/CMakeLists.txt b/source/blender/editors/space_buttons/CMakeLists.txt index 9e045a39a0c..01a099e3701 100644 --- a/source/blender/editors/space_buttons/CMakeLists.txt +++ b/source/blender/editors/space_buttons/CMakeLists.txt @@ -23,10 +23,12 @@ set(INC ../../blenfont ../../blenkernel ../../blenlib + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -46,6 +48,8 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() +add_definitions(${GL_DEFINITIONS}) + if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) endif() diff --git a/source/blender/editors/space_buttons/SConscript b/source/blender/editors/space_buttons/SConscript index 61f9b6f496e..07fe17e302b 100644 --- a/source/blender/editors/space_buttons/SConscript +++ b/source/blender/editors/space_buttons/SConscript @@ -31,12 +31,14 @@ sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../../blenfont', '../../blenkernel', '../../blenlib', '../../bmesh', + '../../gpu', '../../imbuf', '../../makesdna', '../../makesrna', @@ -44,7 +46,8 @@ incs = [ '../../windowmanager', ] incs = ' '.join(incs) -defs = [] + +defs = env['BF_GL_DEFINITIONS'] if env['WITH_BF_INTERNATIONAL']: defs.append('WITH_INTERNATIONAL') diff --git a/source/blender/editors/space_clip/CMakeLists.txt b/source/blender/editors/space_clip/CMakeLists.txt index 7689aa28169..4659e612b41 100644 --- a/source/blender/editors/space_clip/CMakeLists.txt +++ b/source/blender/editors/space_clip/CMakeLists.txt @@ -27,11 +27,12 @@ set(INC ../../blenfont ../../blenlib ../../imbuf + ../../gpu ../../makesdna ../../makesrna ../../windowmanager - ../../gpu ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -56,6 +57,8 @@ set(SRC clip_intern.h ) +add_definitions(${GL_DEFINITIONS}) + if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() diff --git a/source/blender/editors/space_clip/SConscript b/source/blender/editors/space_clip/SConscript index d4483eda6e3..8fec4ebf0fa 100644 --- a/source/blender/editors/space_clip/SConscript +++ b/source/blender/editors/space_clip/SConscript @@ -28,10 +28,13 @@ Import ('env') sources = env.Glob('*.c') -defs = [] + +defs = env['BF_GL_DEFINITIONS'] + incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../../blenfont', '../../blenkernel', diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index b7860643e1a..f25f035db32 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -48,7 +48,7 @@ #include "BLI_fileops.h" #include "BLI_math.h" #include "BLI_rect.h" -#include "BLI_threads.h" +#include "BLI_task.h" #include "BKE_global.h" #include "BKE_main.h" @@ -620,11 +620,6 @@ typedef struct PrefetchQueue { float *progress; } PrefetchQueue; -typedef struct PrefetchThread { - MovieClip *clip; - PrefetchQueue *queue; -} PrefetchThread; - /* check whether pre-fetching is allowed */ static bool check_prefetch_break(void) { @@ -757,15 +752,15 @@ static unsigned char *prefetch_thread_next_frame(PrefetchQueue *queue, MovieClip return mem; } -static void *do_prefetch_thread(void *data_v) +static void prefetch_task_func(TaskPool *pool, void *task_data, int UNUSED(threadid)) { - PrefetchThread *data = (PrefetchThread *) data_v; - MovieClip *clip = data->clip; + PrefetchQueue *queue = (PrefetchQueue *)BLI_task_pool_userdata(pool); + MovieClip *clip = (MovieClip *)task_data; unsigned char *mem; size_t size; int current_frame; - while ((mem = prefetch_thread_next_frame(data->queue, data->clip, &size, ¤t_frame))) { + while ((mem = prefetch_thread_next_frame(queue, clip, &size, ¤t_frame))) { ImBuf *ibuf; MovieClipUser user = {0}; int flag = IB_rect | IB_alphamode_detect; @@ -773,17 +768,17 @@ static void *do_prefetch_thread(void *data_v) char *colorspace_name = NULL; user.framenr = current_frame; - user.render_size = data->queue->render_size; - user.render_flag = data->queue->render_flag; + user.render_size = queue->render_size; + user.render_flag = queue->render_flag; /* Proxies are stored in the display space. */ - if (data->queue->render_flag & MCLIP_USE_PROXY) { + if (queue->render_flag & MCLIP_USE_PROXY) { colorspace_name = clip->colorspace_settings.name; } ibuf = IMB_ibImageFromMemory(mem, size, flag, colorspace_name, "prefetch frame"); - result = BKE_movieclip_put_frame_if_possible(data->clip, &user, ibuf); + result = BKE_movieclip_put_frame_if_possible(clip, &user, ibuf); IMB_freeImBuf(ibuf); @@ -791,27 +786,20 @@ static void *do_prefetch_thread(void *data_v) if (!result) { /* no more space in the cache, stop reading frames */ - *data->queue->stop = 1; + *queue->stop = 1; break; } } - - return NULL; } static void start_prefetch_threads(MovieClip *clip, int start_frame, int current_frame, int end_frame, short render_size, short render_flag, short *stop, short *do_update, float *progress) { - ListBase threads; PrefetchQueue queue; - PrefetchThread *handles; - int tot_thread = BLI_system_thread_count(); - int i; - - /* reserve one thread for the interface */ - if (tot_thread > 1) - tot_thread--; + TaskScheduler *task_scheduler = BLI_task_scheduler_get(); + TaskPool *task_pool; + int i, tot_thread = BLI_task_scheduler_num_threads(task_scheduler); /* initialize queue */ BLI_spin_init(&queue.spin); @@ -828,29 +816,18 @@ static void start_prefetch_threads(MovieClip *clip, int start_frame, int current queue.do_update = do_update; queue.progress = progress; - /* fill in thread handles */ - handles = MEM_callocN(sizeof(PrefetchThread) * tot_thread, "prefetch threaded handles"); - - if (tot_thread > 1) - BLI_init_threads(&threads, do_prefetch_thread, tot_thread); - + task_pool = BLI_task_pool_create(task_scheduler, &queue); for (i = 0; i < tot_thread; i++) { - PrefetchThread *handle = &handles[i]; - - handle->clip = clip; - handle->queue = &queue; - - if (tot_thread > 1) - BLI_insert_thread(&threads, handle); + BLI_task_pool_push(task_pool, + prefetch_task_func, + clip, + false, + TASK_PRIORITY_LOW); } + BLI_task_pool_work_and_wait(task_pool); + BLI_task_pool_free(task_pool); - /* run the threads */ - if (tot_thread > 1) - BLI_end_threads(&threads); - else - do_prefetch_thread(handles); - - MEM_freeN(handles); + BLI_spin_end(&queue.spin); } static bool prefetch_movie_frame(MovieClip *clip, int frame, short render_size, diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 87efaa615ee..9f7bcae800a 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -49,7 +49,7 @@ #include "BLI_path_util.h" #include "BLI_math.h" #include "BLI_rect.h" -#include "BLI_threads.h" +#include "BLI_task.h" #include "BLI_string.h" #include "BLF_translation.h" @@ -79,6 +79,8 @@ #include "UI_view2d.h" +#include "PIL_time.h" + #include "clip_intern.h" // own include /******************** view navigation utilities *********************/ @@ -486,18 +488,25 @@ typedef struct ViewZoomData { float zoom; int event_type; float location[2]; + wmTimer *timer; + double timer_lastdraw; } ViewZoomData; static void view_zoom_init(bContext *C, wmOperator *op, const wmEvent *event) { SpaceClip *sc = CTX_wm_space_clip(C); ARegion *ar = CTX_wm_region(C); - ViewZoomData *vpd; op->customdata = vpd = MEM_callocN(sizeof(ViewZoomData), "ClipViewZoomData"); WM_cursor_modal_set(CTX_wm_window(C), BC_NSEW_SCROLLCURSOR); + if (U.viewzoom == USER_ZOOM_CONT) { + /* needs a timer to continue redrawing */ + vpd->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f); + vpd->timer_lastdraw = PIL_check_seconds_timer(); + } + vpd->x = event->x; vpd->y = event->y; vpd->zoom = sc->zoom; @@ -518,6 +527,10 @@ static void view_zoom_exit(bContext *C, wmOperator *op, bool cancel) ED_region_tag_redraw(CTX_wm_region(C)); } + if (vpd->timer) { + WM_event_remove_timer(CTX_wm_manager(C), vpd->timer->win, vpd->timer); + } + WM_cursor_modal_restore(CTX_wm_window(C)); MEM_freeN(op->customdata); } @@ -555,22 +568,61 @@ static int view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *event) } } +static void view_zoom_apply(bContext *C, + ViewZoomData *vpd, + wmOperator *op, + const wmEvent *event) +{ + float factor; + + if (U.viewzoom == USER_ZOOM_CONT) { + SpaceClip *sclip = CTX_wm_space_clip(C); + double time = PIL_check_seconds_timer(); + float time_step = (float)(time - vpd->timer_lastdraw); + float fac; + float zfac; + + if (U.uiflag & USER_ZOOM_HORIZ) { + fac = (float)(event->x - vpd->x); + } + else { + fac = (float)(event->y - vpd->y); + } + + if (U.uiflag & USER_ZOOM_INVERT) { + fac = -fac; + } + + zfac = 1.0f + ((fac / 20.0f) * time_step); + vpd->timer_lastdraw = time; + factor = (sclip->zoom * zfac) / vpd->zoom; + } + else { + float delta = event->x - vpd->x + event->y - vpd->y; + + if (U.uiflag & USER_ZOOM_INVERT) { + delta *= -1; + } + + factor = 1.0f + delta / 300.0f; + } + + RNA_float_set(op->ptr, "factor", factor); + sclip_zoom_set(C, vpd->zoom * factor, vpd->location); + ED_region_tag_redraw(CTX_wm_region(C)); +} + static int view_zoom_modal(bContext *C, wmOperator *op, const wmEvent *event) { ViewZoomData *vpd = op->customdata; - float delta, factor; - switch (event->type) { + case TIMER: + if (event->customdata == vpd->timer) { + view_zoom_apply(C, vpd, op, event); + } + break; case MOUSEMOVE: - delta = event->x - vpd->x + event->y - vpd->y; - - if (U.uiflag & USER_ZOOM_INVERT) - delta *= -1; - - factor = 1.0f + delta / 300.0f; - RNA_float_set(op->ptr, "factor", factor); - sclip_zoom_set(C, vpd->zoom * factor, vpd->location); - ED_region_tag_redraw(CTX_wm_region(C)); + view_zoom_apply(C, vpd, op, event); break; default: if (event->type == vpd->event_type && event->val == KM_RELEASE) { @@ -1071,10 +1123,7 @@ typedef struct ProxyQueue { typedef struct ProxyThread { MovieClip *clip; - ProxyQueue *queue; - struct MovieDistortion *distortion; - int *build_sizes, build_count; int *build_undistort_sizes, build_undistort_count; } ProxyThread; @@ -1130,14 +1179,15 @@ static unsigned char *proxy_thread_next_frame(ProxyQueue *queue, MovieClip *clip return mem; } -static void *do_proxy_thread(void *data_v) +static void proxy_task_func(TaskPool *pool, void *task_data, int UNUSED(threadid)) { - ProxyThread *data = (ProxyThread *) data_v; + ProxyThread *data = (ProxyThread *)task_data; + ProxyQueue *queue = (ProxyQueue *)BLI_task_pool_userdata(pool); unsigned char *mem; size_t size; int cfra; - while ((mem = proxy_thread_next_frame(data->queue, data->clip, &size, &cfra))) { + while ((mem = proxy_thread_next_frame(queue, data->clip, &size, &cfra))) { ImBuf *ibuf; ibuf = IMB_ibImageFromMemory(mem, size, IB_rect | IB_multilayer | IB_alphamode_detect, @@ -1153,8 +1203,6 @@ static void *do_proxy_thread(void *data_v) MEM_freeN(mem); } - - return NULL; } static void do_sequence_proxy(void *pjv, int *build_sizes, int build_count, @@ -1164,12 +1212,18 @@ static void do_sequence_proxy(void *pjv, int *build_sizes, int build_count, ProxyJob *pj = pjv; MovieClip *clip = pj->clip; Scene *scene = pj->scene; + TaskScheduler *task_scheduler = BLI_task_scheduler_get(); + TaskPool *task_pool; int sfra = SFRA, efra = EFRA; ProxyThread *handles; - ListBase threads; - int i, tot_thread = BLI_system_thread_count(); + int i, tot_thread = BLI_task_scheduler_num_threads(task_scheduler); + int width, height; ProxyQueue queue; + if (build_undistort_count) { + BKE_movieclip_get_size(clip, NULL, &width, &height); + } + BLI_spin_init(&queue.spin); queue.cfra = sfra; @@ -1179,16 +1233,13 @@ static void do_sequence_proxy(void *pjv, int *build_sizes, int build_count, queue.do_update = do_update; queue.progress = progress; - handles = MEM_callocN(sizeof(ProxyThread) * tot_thread, "proxy threaded handles"); - - if (tot_thread > 1) - BLI_init_threads(&threads, do_proxy_thread, tot_thread); - + task_pool = BLI_task_pool_create(task_scheduler, &queue); + handles = MEM_callocN(sizeof(ProxyThread) * tot_thread, + "proxy threaded handles"); for (i = 0; i < tot_thread; i++) { ProxyThread *handle = &handles[i]; handle->clip = clip; - handle->queue = &queue; handle->build_count = build_count; handle->build_sizes = build_sizes; @@ -1197,29 +1248,29 @@ static void do_sequence_proxy(void *pjv, int *build_sizes, int build_count, handle->build_undistort_sizes = build_undistort_sizes; if (build_undistort_count) { - int width, height; - BKE_movieclip_get_size(clip, NULL, &width, &height); - handle->distortion = BKE_tracking_distortion_new(&clip->tracking, width, height); + handle->distortion = BKE_tracking_distortion_new(&clip->tracking, + width, height); } - if (tot_thread > 1) - BLI_insert_thread(&threads, handle); + BLI_task_pool_push(task_pool, + proxy_task_func, + handle, + false, + TASK_PRIORITY_LOW); } - if (tot_thread > 1) - BLI_end_threads(&threads); - else - do_proxy_thread(handles); - - MEM_freeN(handles); + BLI_task_pool_work_and_wait(task_pool); + BLI_task_pool_free(task_pool); if (build_undistort_count) { for (i = 0; i < tot_thread; i++) { ProxyThread *handle = &handles[i]; - BKE_tracking_distortion_free(handle->distortion); } } + + BLI_spin_end(&queue.spin); + MEM_freeN(handles); } static void proxy_startjob(void *pjv, short *stop, short *do_update, float *progress) diff --git a/source/blender/editors/space_console/CMakeLists.txt b/source/blender/editors/space_console/CMakeLists.txt index 241a48c1e2d..ecfb1f0e0df 100644 --- a/source/blender/editors/space_console/CMakeLists.txt +++ b/source/blender/editors/space_console/CMakeLists.txt @@ -23,10 +23,12 @@ set(INC ../../blenfont ../../blenkernel ../../blenlib + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -45,4 +47,6 @@ if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_space_console "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_console/SConscript b/source/blender/editors/space_console/SConscript index 0395a33cd97..87d12fe34bd 100644 --- a/source/blender/editors/space_console/SConscript +++ b/source/blender/editors/space_console/SConscript @@ -28,16 +28,19 @@ Import ('env') sources = env.Glob('*.c') -defs = [] + +defs = env['BF_GL_DEFINITIONS'] incs = [ '../include', - '#/extern/glew/include', '#/intern/guardedalloc', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../../makesdna', '../../makesrna', '../../blenkernel', '../../blenlib', + '../../gpu', '../../windowmanager', '../../blenfont', ] diff --git a/source/blender/editors/space_file/CMakeLists.txt b/source/blender/editors/space_file/CMakeLists.txt index 3b2db3ee7bc..fc007a659b4 100644 --- a/source/blender/editors/space_file/CMakeLists.txt +++ b/source/blender/editors/space_file/CMakeLists.txt @@ -25,11 +25,13 @@ set(INC ../../blenlib ../../blenloader ../../imbuf + ../../gpu ../../makesdna ../../makesrna ../../render/extern/include ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -86,6 +88,8 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() +add_definitions(${GL_DEFINITIONS}) + if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) endif() diff --git a/source/blender/editors/space_file/SConscript b/source/blender/editors/space_file/SConscript index d42394454eb..85c3e073922 100644 --- a/source/blender/editors/space_file/SConscript +++ b/source/blender/editors/space_file/SConscript @@ -30,12 +30,14 @@ Import ('env') sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../../blenfont', '../../blenkernel', '../../blenlib', '../../blenloader', + '../../gpu', '../../imbuf', '../../makesdna', '../../makesrna', @@ -44,7 +46,7 @@ incs = [ ] incs = ' '.join(incs) -defs = [] +defs = env['BF_GL_DEFINITIONS'] if env['WITH_BF_OPENJPEG']: defs.append('WITH_OPENJPEG') diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 1915f45fc87..00d9680f0aa 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -443,7 +443,12 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) if (pathString == NULL || !CFStringGetCString(pathString, line, sizeof(line), kCFStringEncodingASCII)) continue; - fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, NULL); + + /* Exclude "all my files" as it makes no sense in blender fileselector */ + /* Exclude "airdrop" if wlan not active as it would show "" ) */ + if (!strstr((char *)line, "myDocuments.cannedSearch") && (strcmp((char *)line, ""))) { + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, NULL); + } CFRelease(pathString); CFRelease(cfURL); diff --git a/source/blender/editors/space_graph/CMakeLists.txt b/source/blender/editors/space_graph/CMakeLists.txt index d3fb87204fb..0a29810ff3d 100644 --- a/source/blender/editors/space_graph/CMakeLists.txt +++ b/source/blender/editors/space_graph/CMakeLists.txt @@ -23,10 +23,12 @@ set(INC ../../blenfont ../../blenkernel ../../blenlib + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -56,4 +58,6 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_space_graph "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_graph/SConscript b/source/blender/editors/space_graph/SConscript index 8ddeb0ccfe8..35e09749743 100644 --- a/source/blender/editors/space_graph/SConscript +++ b/source/blender/editors/space_graph/SConscript @@ -31,19 +31,21 @@ sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '#/intern/audaspace/intern', '../include', '../../blenfont', '../../blenkernel', '../../blenlib', + '../../gpu', '../../imbuf', '../../makesdna', '../../makesrna', '../../windowmanager', ] -defs = [] +defs = env['BF_GL_DEFINITIONS'] if env['WITH_BF_INTERNATIONAL']: defs.append('WITH_INTERNATIONAL') diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt index 62ac3c2d985..30bfc2fbdfd 100644 --- a/source/blender/editors/space_image/CMakeLists.txt +++ b/source/blender/editors/space_image/CMakeLists.txt @@ -23,14 +23,15 @@ set(INC ../../blenfont ../../blenkernel ../../blenlib - ../../imbuf ../../bmesh + ../../imbuf + ../../gpu ../../makesdna ../../makesrna ../../render/extern/include ../../windowmanager ../../../../intern/guardedalloc - ../../gpu + ../../../../intern/glew-mx ) set(INC_SYS @@ -71,4 +72,6 @@ if(WITH_IMAGE_CINEON) add_definitions(-DWITH_CINEON) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_space_image "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_image/SConscript b/source/blender/editors/space_image/SConscript index d878a726b55..e983db431b4 100644 --- a/source/blender/editors/space_image/SConscript +++ b/source/blender/editors/space_image/SConscript @@ -31,12 +31,14 @@ sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../../blenfont', '../../blenkernel', '../../blenlib', '../../bmesh', + '../../gpu', '../../imbuf', '../../makesdna', '../../makesrna', @@ -46,7 +48,7 @@ incs = [ ] incs = ' '.join(incs) -defs = [] +defs = env['BF_GL_DEFINITIONS'] if env['WITH_BF_INTERNATIONAL']: defs.append('WITH_INTERNATIONAL') diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index ed6e6ba1e1b..ffdb8ecfce6 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -284,10 +284,10 @@ static void image_panel_preview(ScrArea *sa, short cntrl) // IMAGE_HANDLER_PRE /* ********************* callbacks for standard image buttons *************** */ -static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *render_slot_p) +static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *image_p) { uiBlock *block = uiLayoutGetBlock(layout); - short *render_slot = render_slot_p; + Image *image = image_p; int slot; uiDefBut(block, LABEL, 0, IFACE_("Slot"), @@ -296,10 +296,15 @@ static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void * slot = IMA_MAX_RENDER_SLOT; while (slot--) { - char str[32]; - BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), slot + 1); + char str[64]; + if (image->render_slots[slot].name[0] != '\0') { + BLI_strncpy(str, image->render_slots[slot].name, sizeof(str)); + } + else { + BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), slot + 1); + } uiDefButS(block, BUTM, B_NOP, str, 0, 0, - UI_UNIT_X * 5, UI_UNIT_X, render_slot, (float) slot, 0.0, 0, -1, ""); + UI_UNIT_X * 5, UI_UNIT_X, &image->render_slot, (float) slot, 0.0, 0, -1, ""); } } @@ -492,7 +497,7 @@ static void image_user_change(bContext *C, void *iuser_v, void *unused) } #endif -static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, int w, short *render_slot) +static void uiblock_layer_pass_buttons(uiLayout *layout, Image *image, RenderResult *rr, ImageUser *iuser, int w, short *render_slot) { static void *rnd_pt[3]; /* XXX, workaround */ uiBlock *block = uiLayoutGetBlock(layout); @@ -516,8 +521,13 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, Image /* menu buts */ if (render_slot) { char str[64]; - BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), *render_slot + 1); - but = uiDefMenuBut(block, ui_imageuser_slot_menu, render_slot, str, 0, 0, wmenu1, UI_UNIT_Y, TIP_("Select Slot")); + if (image->render_slots[*render_slot].name[0] != '\0') { + BLI_strncpy(str, image->render_slots[*render_slot].name, sizeof(str)); + } + else { + BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), *render_slot + 1); + } + but = uiDefMenuBut(block, ui_imageuser_slot_menu, image, str, 0, 0, wmenu1, UI_UNIT_Y, TIP_("Select Slot")); uiButSetFunc(but, image_multi_cb, rr, iuser); uiButSetMenuFromPulldown(but); } @@ -547,7 +557,7 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, Image } } -static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, short *render_slot) +static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, Image *image, RenderResult *rr, ImageUser *iuser, short *render_slot) { uiBlock *block = uiLayoutGetBlock(layout); uiLayout *row; @@ -569,7 +579,7 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, but = uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0, 0, 0.90f * UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Next Layer")); uiButSetFunc(but, image_multi_inclay_cb, rr, iuser); - uiblock_layer_pass_buttons(row, rr, iuser, 230 * dpi_fac, render_slot); + uiblock_layer_pass_buttons(row, image, rr, iuser, 230 * dpi_fac, render_slot); /* decrease, increase arrows */ but = uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0, 0, 0.85f * UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Previous Pass")); @@ -691,7 +701,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char /* use BKE_image_acquire_renderresult so we get the correct slot in the menu */ rr = BKE_image_acquire_renderresult(scene, ima); - uiblock_layer_pass_arrow_buttons(layout, rr, iuser, &ima->render_slot); + uiblock_layer_pass_arrow_buttons(layout, ima, rr, iuser, &ima->render_slot); BKE_image_release_renderresult(scene, ima); } } @@ -724,7 +734,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char /* multilayer? */ if (ima->type == IMA_TYPE_MULTILAYER && ima->rr) { - uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser, NULL); + uiblock_layer_pass_arrow_buttons(layout, ima, ima->rr, iuser, NULL); } else if (ima->source != IMA_SRC_GENERATED) { if (compact == 0) { @@ -937,7 +947,7 @@ void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser /* use BKE_image_acquire_renderresult so we get the correct slot in the menu */ rr = BKE_image_acquire_renderresult(scene, ima); - uiblock_layer_pass_buttons(layout, rr, iuser, 160 * dpi_fac, (ima->type == IMA_TYPE_R_RESULT) ? &ima->render_slot : NULL); + uiblock_layer_pass_buttons(layout, ima, rr, iuser, 160 * dpi_fac, (ima->type == IMA_TYPE_R_RESULT) ? &ima->render_slot : NULL); BKE_image_release_renderresult(scene, ima); } } diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 79c21bab01c..f41e237beb4 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -83,6 +83,7 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar, float zoomx, { RenderResult *rr; Render *re = RE_GetRender(scene->id.name); + RenderData *rd = RE_engine_get_render_data(re); rr = BKE_image_acquire_renderresult(scene, ima); @@ -110,9 +111,9 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar, float zoomx, glTranslatef(x, y, 0.0f); glScalef(zoomx, zoomy, 1.0f); - if (scene->r.mode & R_BORDER) { - glTranslatef((int)(-scene->r.border.xmin * scene->r.xsch * scene->r.size / 100.0f), - (int)(-scene->r.border.ymin * scene->r.ysch * scene->r.size / 100.0f), + if (rd->mode & R_BORDER) { + glTranslatef((int)(-rd->border.xmin * rd->xsch * rd->size / 100.0f), + (int)(-rd->border.ymin * rd->ysch * rd->size / 100.0f), 0.0f); } diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h index 74a0a18b0c8..aecc43f4fdf 100644 --- a/source/blender/editors/space_image/image_intern.h +++ b/source/blender/editors/space_image/image_intern.h @@ -92,6 +92,8 @@ void IMAGE_OT_curves_point_set(struct wmOperatorType *ot); void IMAGE_OT_change_frame(struct wmOperatorType *ot); void IMAGE_OT_read_renderlayers(struct wmOperatorType *ot); +void IMAGE_OT_render_border(struct wmOperatorType *ot); +void IMAGE_OT_clear_render_border(struct wmOperatorType *ot); /* image_panels.c */ struct ImageUser *ntree_get_active_iuser(struct bNodeTree *ntree); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 58b56e99119..df556f94f28 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -3101,3 +3101,88 @@ void IMAGE_OT_read_renderlayers(wmOperatorType *ot) /* flags */ ot->flag = 0; } + +/* ********************* Render border operator ****************** */ + +static int render_border_exec(bContext *C, wmOperator *op) +{ + ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); + rctf border; + + /* get rectangle from operator */ + WM_operator_properties_border_to_rctf(op, &border); + UI_view2d_region_to_view_rctf(&ar->v2d, &border, &border); + + /* actually set border */ + CLAMP(border.xmin, 0.0f, 1.0f); + CLAMP(border.ymin, 0.0f, 1.0f); + CLAMP(border.xmax, 0.0f, 1.0f); + CLAMP(border.ymax, 0.0f, 1.0f); + scene->r.border = border; + + /* drawing a border surrounding the entire camera view switches off border rendering + * or the border covers no pixels */ + if ((border.xmin <= 0.0f && border.xmax >= 1.0f && + border.ymin <= 0.0f && border.ymax >= 1.0f) || + (border.xmin == border.xmax || border.ymin == border.ymax)) + { + scene->r.mode &= ~R_BORDER; + } + else { + scene->r.mode |= R_BORDER; + } + + WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, NULL); + + return OPERATOR_FINISHED; + +} + +void IMAGE_OT_render_border(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Render Border"; + ot->description = "Set the boundaries of the border render and enable border render"; + ot->idname = "IMAGE_OT_render_border"; + + /* api callbacks */ + ot->invoke = WM_border_select_invoke; + ot->exec = render_border_exec; + ot->modal = WM_border_select_modal; + ot->cancel = WM_border_select_cancel; + ot->poll = image_cycle_render_slot_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* rna */ + WM_operator_properties_border(ot); +} + +/* ********************* Clear render border operator ****************** */ + +static int clear_render_border_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + scene->r.mode &= ~R_BORDER; + WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, NULL); + BLI_rctf_init(&scene->r.border, 0.0f, 1.0f, 0.0f, 1.0f); + return OPERATOR_FINISHED; + +} + +void IMAGE_OT_clear_render_border(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Render Border"; + ot->description = "Clear the boundaries of the border render and disable border render"; + ot->idname = "IMAGE_OT_clear_render_border"; + + /* api callbacks */ + ot->exec = clear_render_border_exec; + ot->poll = image_cycle_render_slot_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index ab616bf592f..9cfd2e645f9 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -257,6 +257,8 @@ static void image_operatortypes(void) WM_operatortype_append(IMAGE_OT_change_frame); WM_operatortype_append(IMAGE_OT_read_renderlayers); + WM_operatortype_append(IMAGE_OT_render_border); + WM_operatortype_append(IMAGE_OT_clear_render_border); } static void image_keymap(struct wmKeyConfig *keyconf) @@ -325,9 +327,9 @@ static void image_keymap(struct wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "toggle", true); /* fast switch to render slots */ - for (i = 0; i < MAX2(IMA_MAX_RENDER_SLOT, 9); i++) { + for (i = 0; i < MIN2(IMA_MAX_RENDER_SLOT, 9); i++) { kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_int", ONEKEY + i, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "data_path", "space_data.image.render_slot"); + RNA_string_set(kmi->ptr, "data_path", "space_data.image.render_slots.active_index"); RNA_int_set(kmi->ptr, "value", i); } @@ -343,6 +345,10 @@ static void image_keymap(struct wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point"); RNA_string_set(kmi->ptr, "value", "CURSOR"); + + /* render border */ + WM_keymap_add_item(keymap, "IMAGE_OT_render_border", BKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "IMAGE_OT_clear_render_border", BKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); } /* dropboxes */ diff --git a/source/blender/editors/space_info/CMakeLists.txt b/source/blender/editors/space_info/CMakeLists.txt index 94b40a9f40a..46ea251de03 100644 --- a/source/blender/editors/space_info/CMakeLists.txt +++ b/source/blender/editors/space_info/CMakeLists.txt @@ -26,10 +26,12 @@ set(INC ../../blenloader ../../imbuf ../../bmesh + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -52,4 +54,6 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_space_info "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_info/SConscript b/source/blender/editors/space_info/SConscript index 2a1419984c6..378940805da 100644 --- a/source/blender/editors/space_info/SConscript +++ b/source/blender/editors/space_info/SConscript @@ -31,13 +31,15 @@ sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../../blenfont', '../../blenkernel', '../../blenlib', '../../blenloader', '../../bmesh', + '../../gpu', '../../imbuf', '../../makesdna', '../../makesrna', @@ -45,7 +47,7 @@ incs = [ ] incs = ' '.join(incs) -defs = [] +defs = env['BF_GL_DEFINITIONS'] if env['WITH_BF_INTERNATIONAL']: defs.append('WITH_INTERNATIONAL') diff --git a/source/blender/editors/space_logic/CMakeLists.txt b/source/blender/editors/space_logic/CMakeLists.txt index af2e8476511..19525c87923 100644 --- a/source/blender/editors/space_logic/CMakeLists.txt +++ b/source/blender/editors/space_logic/CMakeLists.txt @@ -24,10 +24,12 @@ set(INC ../../blenfont ../../blenkernel ../../blenlib + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -47,6 +49,8 @@ if(WITH_GAMEENGINE) add_definitions(-DWITH_GAMEENGINE) endif() +add_definitions(${GL_DEFINITIONS}) + if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() diff --git a/source/blender/editors/space_logic/SConscript b/source/blender/editors/space_logic/SConscript index ae8e929a684..067073fab22 100644 --- a/source/blender/editors/space_logic/SConscript +++ b/source/blender/editors/space_logic/SConscript @@ -31,12 +31,14 @@ sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../interface', '../../blenfont', '../../blenkernel', '../../blenlib', + '../../gpu', '../../imbuf', '../../makesdna', '../../makesrna', @@ -44,7 +46,7 @@ incs = [ ] incs = ' '.join(incs) -defs = [] +defs = env['BF_GL_DEFINITIONS'] if env['WITH_BF_GAMEENGINE']: defs.append('WITH_GAMEENGINE') diff --git a/source/blender/editors/space_nla/CMakeLists.txt b/source/blender/editors/space_nla/CMakeLists.txt index a74fc3191b7..ab0dfa30121 100644 --- a/source/blender/editors/space_nla/CMakeLists.txt +++ b/source/blender/editors/space_nla/CMakeLists.txt @@ -23,10 +23,12 @@ set(INC ../../blenfont ../../blenkernel ../../blenlib + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -49,4 +51,6 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_space_nla "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_nla/SConscript b/source/blender/editors/space_nla/SConscript index a00337e0b58..9e743d918b9 100644 --- a/source/blender/editors/space_nla/SConscript +++ b/source/blender/editors/space_nla/SConscript @@ -31,18 +31,20 @@ sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../../blenfont', '../../blenkernel', '../../blenlib', + '../../gpu', '../../makesdna', '../../makesrna', '../../windowmanager', ] incs = ' '.join(incs) -defs = [] +defs = env['BF_GL_DEFINITIONS'] if env['WITH_BF_INTERNATIONAL']: defs.append('WITH_INTERNATIONAL') diff --git a/source/blender/editors/space_node/CMakeLists.txt b/source/blender/editors/space_node/CMakeLists.txt index 6b0460ce5cd..34887f8388d 100644 --- a/source/blender/editors/space_node/CMakeLists.txt +++ b/source/blender/editors/space_node/CMakeLists.txt @@ -32,6 +32,7 @@ set(INC ../../windowmanager ../../compositor ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -64,4 +65,6 @@ if(WITH_COMPOSITOR) add_definitions(-DWITH_COMPOSITOR) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_space_node "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_node/SConscript b/source/blender/editors/space_node/SConscript index 94756b96035..435a78f1b7e 100644 --- a/source/blender/editors/space_node/SConscript +++ b/source/blender/editors/space_node/SConscript @@ -31,7 +31,8 @@ sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../../blenfont', '../../blenkernel', @@ -47,7 +48,8 @@ incs = [ ] incs = ' '.join(incs) -defs = [] +defs = env['BF_GL_DEFINITIONS'] + cf = [] if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): #cf.append('/WX') diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt index 4db47b75502..b716f0671bd 100644 --- a/source/blender/editors/space_outliner/CMakeLists.txt +++ b/source/blender/editors/space_outliner/CMakeLists.txt @@ -24,10 +24,12 @@ set(INC ../../blenlib ../../blenfont ../../imbuf + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -50,4 +52,6 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_space_outliner "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_outliner/SConscript b/source/blender/editors/space_outliner/SConscript index db8041f0235..cc02c9555a9 100644 --- a/source/blender/editors/space_outliner/SConscript +++ b/source/blender/editors/space_outliner/SConscript @@ -28,15 +28,18 @@ Import ('env') sources = env.Glob('*.c') -defs = [] + +defs = env['BF_GL_DEFINITIONS'] incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../../blenfont', '../../blenkernel', '../../blenlib', + '../../gpu', '../../imbuf', '../../makesdna', '../../makesrna', diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 7eb90953df4..e033f781f62 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -29,6 +29,7 @@ * \ingroup spoutliner */ +#include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_group_types.h" #include "DNA_lamp_types.h" @@ -46,6 +47,7 @@ #include "BKE_context.h" #include "BKE_deform.h" #include "BKE_depsgraph.h" +#include "BKE_fcurve.h" #include "BKE_global.h" #include "BKE_library.h" #include "BKE_main.h" @@ -55,6 +57,7 @@ #include "BKE_object.h" #include "ED_armature.h" +#include "ED_keyframing.h" #include "ED_object.h" #include "ED_screen.h" @@ -168,7 +171,7 @@ static void restrictbutton_recursive_bone(bContext *C, bArmature *arm, Bone *bon } static void restrictbutton_recursive_child(bContext *C, Scene *scene, Object *ob_parent, char flag, - bool state, bool deselect) + bool state, bool deselect, const char *rnapropname) { Main *bmain = CTX_data_main(C); Object *ob; @@ -183,6 +186,33 @@ static void restrictbutton_recursive_child(bContext *C, Scene *scene, Object *ob else { ob->restrictflag &= ~flag; } + + if (rnapropname) { + PointerRNA ptr; + PropertyRNA *prop; + ID *id; + bAction *action; + FCurve *fcu; + bool driven; + + RNA_id_pointer_create(&ob->id, &ptr); + prop = RNA_struct_find_property(&ptr, rnapropname); + fcu = rna_get_fcurve_context_ui(C, &ptr, prop, 0, &action, &driven); + + if (fcu && !driven) { + id = ptr.id.data; + if (autokeyframe_cfra_can_key(scene, id)) { + ReportList *reports = CTX_wm_reports(C); + short flag = ANIM_get_keyframing_flags(scene, 1); + + fcu->flag &= ~FCURVE_SELECTED; + insert_keyframe(reports, id, action, ((fcu->grp) ? (fcu->grp->name) : (NULL)), + fcu->rna_path, fcu->array_index, CFRA, flag); + /* Assuming this is not necessary here, since 'ancestor' object button will do it anyway. */ + /* WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); */ + } + } + } } } } @@ -203,7 +233,7 @@ static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2) if (CTX_wm_window(C)->eventstate->ctrl) { restrictbutton_recursive_child(C, scene, ob, OB_RESTRICT_VIEW, - (ob->restrictflag & OB_RESTRICT_VIEW) != 0, true); + (ob->restrictflag & OB_RESTRICT_VIEW) != 0, true, "hide"); } WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); @@ -226,7 +256,7 @@ static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2) if (CTX_wm_window(C)->eventstate->ctrl) { restrictbutton_recursive_child(C, scene, ob, OB_RESTRICT_SELECT, - (ob->restrictflag & OB_RESTRICT_SELECT) != 0, true); + (ob->restrictflag & OB_RESTRICT_SELECT) != 0, true, NULL); } WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); @@ -239,7 +269,7 @@ static void restrictbutton_rend_cb(bContext *C, void *poin, void *poin2) if (CTX_wm_window(C)->eventstate->ctrl) { restrictbutton_recursive_child(C, (Scene *)poin, ob, OB_RESTRICT_RENDER, - (ob->restrictflag & OB_RESTRICT_RENDER) != 0, false); + (ob->restrictflag & OB_RESTRICT_RENDER) != 0, false, "hide_render"); } WM_event_add_notifier(C, NC_SCENE | ND_OB_RENDER, poin); diff --git a/source/blender/editors/space_script/CMakeLists.txt b/source/blender/editors/space_script/CMakeLists.txt index 26c4183f7df..2eb31576c57 100644 --- a/source/blender/editors/space_script/CMakeLists.txt +++ b/source/blender/editors/space_script/CMakeLists.txt @@ -22,10 +22,12 @@ set(INC ../include ../../blenkernel ../../blenlib + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -47,4 +49,6 @@ if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_space_script "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_script/SConscript b/source/blender/editors/space_script/SConscript index acb0bf9f20b..e749780a4aa 100644 --- a/source/blender/editors/space_script/SConscript +++ b/source/blender/editors/space_script/SConscript @@ -31,10 +31,12 @@ sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../../blenkernel', '../../blenlib', + '../../gpu', '../../imbuf', '../../makesdna', '../../makesrna', @@ -42,7 +44,7 @@ incs = [ '../../windowmanager', ] -defs = [] +defs = env['BF_GL_DEFINITIONS'] if env['WITH_BF_PYTHON']: defs.append('WITH_PYTHON') diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt index db5729a5762..4cf9c0c95c2 100644 --- a/source/blender/editors/space_sequencer/CMakeLists.txt +++ b/source/blender/editors/space_sequencer/CMakeLists.txt @@ -24,10 +24,12 @@ set(INC ../../blenkernel ../../blenlib ../../imbuf + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -60,4 +62,6 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_space_sequencer "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_sequencer/SConscript b/source/blender/editors/space_sequencer/SConscript index 5aae30244a7..954f8abff69 100644 --- a/source/blender/editors/space_sequencer/SConscript +++ b/source/blender/editors/space_sequencer/SConscript @@ -31,19 +31,21 @@ sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '#/intern/audaspace/intern', '../include', '../../blenfont', '../../blenkernel', '../../blenlib', + '../../gpu', '../../imbuf', '../../makesdna', '../../makesrna', '../../windowmanager', ] -defs = [] +defs = env['BF_GL_DEFINITIONS'] if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): incs.append(env['BF_PTHREADS_INC']) diff --git a/source/blender/editors/space_text/CMakeLists.txt b/source/blender/editors/space_text/CMakeLists.txt index bfeeb93372a..5367efbf84b 100644 --- a/source/blender/editors/space_text/CMakeLists.txt +++ b/source/blender/editors/space_text/CMakeLists.txt @@ -23,10 +23,12 @@ set(INC ../../blenfont ../../blenkernel ../../blenlib + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -48,6 +50,8 @@ set(SRC text_intern.h ) +add_definitions(${GL_DEFINITIONS}) + if(WITH_PYTHON) list(APPEND INC ../../python diff --git a/source/blender/editors/space_text/SConscript b/source/blender/editors/space_text/SConscript index 3f617f95c58..8ee9bd745dd 100644 --- a/source/blender/editors/space_text/SConscript +++ b/source/blender/editors/space_text/SConscript @@ -28,14 +28,18 @@ Import ('env') sources = env.Glob('*.c') -defs = [] + +defs = env['BF_GL_DEFINITIONS'] + incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../../blenfont', '../../blenkernel', '../../blenlib', + '../../gpu', '../../imbuf', '../../makesdna', '../../makesrna', diff --git a/source/blender/editors/space_time/CMakeLists.txt b/source/blender/editors/space_time/CMakeLists.txt index b42ae3ab725..90af405eaa8 100644 --- a/source/blender/editors/space_time/CMakeLists.txt +++ b/source/blender/editors/space_time/CMakeLists.txt @@ -22,10 +22,12 @@ set(INC ../include ../../blenkernel ../../blenlib + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -39,4 +41,6 @@ set(SRC time_intern.h ) +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_space_time "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_time/SConscript b/source/blender/editors/space_time/SConscript index bf1b918f4f1..5a9e9a4cb42 100644 --- a/source/blender/editors/space_time/SConscript +++ b/source/blender/editors/space_time/SConscript @@ -31,15 +31,17 @@ sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../../blenkernel', '../../blenlib', + '../../gpu', '../../makesdna', '../../makesrna', '../../windowmanager', ] -defs = [] +defs = env['BF_GL_DEFINITIONS'] env.BlenderLib('bf_editors_space_time', sources, incs, defs, libtype=['core'], priority=[65]) diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt index 97c328dbac2..320267a4a7c 100644 --- a/source/blender/editors/space_view3d/CMakeLists.txt +++ b/source/blender/editors/space_view3d/CMakeLists.txt @@ -31,6 +31,7 @@ set(INC ../../render/extern/include ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ../../../../intern/smoke/extern ) @@ -76,7 +77,7 @@ if(WITH_GAMEENGINE) add_definitions(-DWITH_GAMEENGINE) endif() -add_definitions(-DGLEW_STATIC) +add_definitions(${GL_DEFINITIONS}) if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) diff --git a/source/blender/editors/space_view3d/SConscript b/source/blender/editors/space_view3d/SConscript index e6658ab3c49..a21da940906 100644 --- a/source/blender/editors/space_view3d/SConscript +++ b/source/blender/editors/space_view3d/SConscript @@ -28,11 +28,13 @@ Import ('env') sources = env.Glob('*.c') -defs = [ 'GLEW_STATIC' ] + +defs = env['BF_GL_DEFINITIONS'] incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '#/intern/smoke/extern', '#/source/gameengine/BlenderRoutines', '../include', diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 0e3621aa91f..b3accb431ee 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -434,9 +434,7 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl) BGpic *bgpic; /* clear or remove stuff from old */ - -// XXX BIF_view3d_previewrender_free(v3do); - + if (v3dn->localvd) { v3dn->localvd = NULL; v3dn->properties_storage = NULL; diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt index 3ad5d94efd6..0c360474b78 100644 --- a/source/blender/editors/transform/CMakeLists.txt +++ b/source/blender/editors/transform/CMakeLists.txt @@ -30,6 +30,7 @@ set(INC ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -54,4 +55,6 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_transform "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/transform/SConscript b/source/blender/editors/transform/SConscript index 4f47062e3a3..e249856b747 100644 --- a/source/blender/editors/transform/SConscript +++ b/source/blender/editors/transform/SConscript @@ -31,20 +31,21 @@ sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../../blenfont', '../../blenkernel', '../../blenlib', '../../bmesh', + '../../gpu', '../../ikplugin', '../../makesdna', '../../makesrna', - '../../gpu', '../../windowmanager', ] -defs = [] +defs = env['BF_GL_DEFINITIONS'] if env['WITH_BF_INTERNATIONAL']: defs.append('WITH_INTERNATIONAL') diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 47adbb6d16d..86e6e611cf3 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2773,8 +2773,8 @@ void flushTransUVs(TransInfo *t) td->loc2d[1] = td->loc[1] * invy; if ((sima->flag & SI_PIXELSNAP) && (t->state != TRANS_CANCEL)) { - td->loc2d[0] = (float)floor(width * td->loc2d[0] + 0.5f) / width; - td->loc2d[1] = (float)floor(height * td->loc2d[1] + 0.5f) / height; + td->loc2d[0] = floorf(width * td->loc2d[0] + 0.5f) / width; + td->loc2d[1] = floorf(height * td->loc2d[1] + 0.5f) / height; } } } diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index af563f71376..8a3e8f19db4 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -2396,7 +2396,7 @@ bool snapNodesContext(bContext *C, const int mval[2], float *r_dist_px, float r_ /*================================================================*/ -static void applyGridIncrement(TransInfo *t, float *val, int max_index, float fac[3], GearsType action); +static void applyGridIncrement(TransInfo *t, float *val, int max_index, const float fac[3], GearsType action); void snapGridIncrementAction(TransInfo *t, float *val, GearsType action) @@ -2429,7 +2429,7 @@ void snapGridIncrement(TransInfo *t, float *val) } -static void applyGridIncrement(TransInfo *t, float *val, int max_index, float fac[3], GearsType action) +static void applyGridIncrement(TransInfo *t, float *val, int max_index, const float fac[3], GearsType action) { int i; float asp[3] = {1.0f, 1.0f, 1.0f}; // TODO: Remove hard coded limit here (3) @@ -2457,6 +2457,6 @@ static void applyGridIncrement(TransInfo *t, float *val, int max_index, float fa } for (i = 0; i <= max_index; i++) { - val[i] = fac[action] * asp[i] * (float)floor(val[i] / (fac[action] * asp[i]) + 0.5f); + val[i] = fac[action] * asp[i] * floorf(val[i] / (fac[action] * asp[i]) + 0.5f); } } diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt index 4400870f1b8..f4189a18da4 100644 --- a/source/blender/editors/util/CMakeLists.txt +++ b/source/blender/editors/util/CMakeLists.txt @@ -24,10 +24,12 @@ set(INC ../../blenkernel ../../blenlib ../../bmesh + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -91,7 +93,7 @@ set(SRC ../include/UI_view2d.h ) -add_definitions(-DGLEW_STATIC) +add_definitions(${GL_DEFINITIONS}) if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) diff --git a/source/blender/editors/util/SConscript b/source/blender/editors/util/SConscript index 0876fe48c91..d695a848f4e 100644 --- a/source/blender/editors/util/SConscript +++ b/source/blender/editors/util/SConscript @@ -28,16 +28,19 @@ Import ('env') sources = env.Glob('*.c') -defs = [ 'GLEW_STATIC' ] + +defs = env['BF_GL_DEFINITIONS'] incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../include', '../../blenfont', '../../blenkernel', '../../blenlib', '../../bmesh', + '../../gpu', '../../makesdna', '../../makesrna', '../../windowmanager', diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 56b12fcdcda..ec0471da8d3 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -153,19 +153,20 @@ void ED_editors_exit(bContext *C) /* flush any temp data from object editing to DNA before writing files, * rendering, copying, etc. */ -void ED_editors_flush_edits(const bContext *C, bool for_render) +bool ED_editors_flush_edits(const bContext *C, bool for_render) { + bool has_edited = false; Object *ob; - Object *obedit = CTX_data_edit_object(C); Main *bmain = CTX_data_main(C); - /* get editmode results */ - if (obedit) - ED_object_editmode_load(obedit); + /* loop through all data to find edit mode or object mode, because during + * exiting we might not have a context for edit object and multiple sculpt + * objects can exist at the same time */ for (ob = bmain->object.first; ob; ob = ob->id.next) { - if (ob && (ob->mode & OB_MODE_SCULPT)) { + if (ob->mode & OB_MODE_SCULPT) { /* flush multires changes (for sculpt) */ multires_force_update(ob); + has_edited = true; if (for_render) { /* flush changes from dynamic topology sculpt */ @@ -177,7 +178,14 @@ void ED_editors_flush_edits(const bContext *C, bool for_render) BKE_sculptsession_bm_to_me(ob, false); } } + else if (ob->mode & OB_MODE_EDIT) { + /* get editmode results */ + has_edited = true; + ED_object_editmode_load(ob); + } } + + return has_edited; } /* ***** XXX: functions are using old blender names, cleanup later ***** */ diff --git a/source/blender/editors/uvedit/CMakeLists.txt b/source/blender/editors/uvedit/CMakeLists.txt index 45edbde7482..74ba1672485 100644 --- a/source/blender/editors/uvedit/CMakeLists.txt +++ b/source/blender/editors/uvedit/CMakeLists.txt @@ -24,10 +24,12 @@ set(INC ../../blenlib ../../blenfont ../../bmesh + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -57,4 +59,6 @@ if(WITH_OPENNL) ) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_uvedit "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/uvedit/SConscript b/source/blender/editors/uvedit/SConscript index 413503191cd..7153d25188b 100644 --- a/source/blender/editors/uvedit/SConscript +++ b/source/blender/editors/uvedit/SConscript @@ -27,13 +27,14 @@ Import ('env') -defs = [] +defs = env['BF_GL_DEFINITIONS'] sources = env.Glob('*.c') incs = [ '#/intern/guardedalloc', - '#/extern/glew/include', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '#/intern/opennl/extern', '../include', '../../blenfont', |