diff options
Diffstat (limited to 'source/blender/editors')
51 files changed, 277 insertions, 365 deletions
diff --git a/source/blender/editors/animation/CMakeLists.txt b/source/blender/editors/animation/CMakeLists.txt index 6fa4d94df3a..0baac40660d 100644 --- a/source/blender/editors/animation/CMakeLists.txt +++ b/source/blender/editors/animation/CMakeLists.txt @@ -60,10 +60,6 @@ set(LIB bf_blenlib ) -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() diff --git a/source/blender/editors/armature/CMakeLists.txt b/source/blender/editors/armature/CMakeLists.txt index aff5803f037..c8ca27c64a3 100644 --- a/source/blender/editors/armature/CMakeLists.txt +++ b/source/blender/editors/armature/CMakeLists.txt @@ -63,9 +63,5 @@ set(LIB bf_blenlib ) -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - blender_add_lib(bf_editor_armature "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 252cf806e34..aaeac29b7d0 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -27,6 +27,7 @@ struct wmOperatorType; struct Base; +struct GPUSelectResult; struct Object; struct Scene; struct bContext; @@ -323,21 +324,21 @@ struct Bone *ED_armature_pick_bone(struct bContext *C, struct EditBone *ED_armature_pick_ebone_from_selectbuffer(struct Base **bases, uint bases_len, - const uint *buffer, + const struct GPUSelectResult *buffer, short hits, bool findunsel, bool do_nearest, struct Base **r_base); struct bPoseChannel *ED_armature_pick_pchan_from_selectbuffer(struct Base **bases, uint bases_len, - const uint *buffer, + const struct GPUSelectResult *buffer, short hits, bool findunsel, bool do_nearest, struct Base **r_base); struct Bone *ED_armature_pick_bone_from_selectbuffer(struct Base **bases, uint bases_len, - const uint *buffer, + const struct GPUSelectResult *buffer, short hits, bool findunsel, bool do_nearest, diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index 5e4cb813064..f9b52eb53ed 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -55,6 +55,8 @@ #include "DEG_depsgraph.h" +#include "GPU_select.h" + #include "armature_intern.h" /* utility macros for storing a temp int in the bone (selection flag) */ @@ -67,10 +69,10 @@ Base *ED_armature_base_and_ebone_from_select_buffer(Base **bases, uint bases_len, - int hit, + const uint select_id, EditBone **r_ebone) { - const uint hit_object = hit & 0xFFFF; + const uint hit_object = select_id & 0xFFFF; Base *base = NULL; EditBone *ebone = NULL; /* TODO(campbell): optimize, eg: sort & binary search. */ @@ -81,7 +83,7 @@ Base *ED_armature_base_and_ebone_from_select_buffer(Base **bases, } } if (base != NULL) { - const uint hit_bone = (hit & ~BONESEL_ANY) >> 16; + const uint hit_bone = (select_id & ~BONESEL_ANY) >> 16; bArmature *arm = base->object->data; ebone = BLI_findlink(arm->edbo, hit_bone); } @@ -91,10 +93,10 @@ Base *ED_armature_base_and_ebone_from_select_buffer(Base **bases, Object *ED_armature_object_and_ebone_from_select_buffer(Object **objects, uint objects_len, - int hit, + const uint select_id, EditBone **r_ebone) { - const uint hit_object = hit & 0xFFFF; + const uint hit_object = select_id & 0xFFFF; Object *ob = NULL; EditBone *ebone = NULL; /* TODO(campbell): optimize, eg: sort & binary search. */ @@ -105,7 +107,7 @@ Object *ED_armature_object_and_ebone_from_select_buffer(Object **objects, } } if (ob != NULL) { - const uint hit_bone = (hit & ~BONESEL_ANY) >> 16; + const uint hit_bone = (select_id & ~BONESEL_ANY) >> 16; bArmature *arm = ob->data; ebone = BLI_findlink(arm->edbo, hit_bone); } @@ -115,10 +117,10 @@ Object *ED_armature_object_and_ebone_from_select_buffer(Object **objects, Base *ED_armature_base_and_pchan_from_select_buffer(Base **bases, uint bases_len, - int hit, + const uint select_id, bPoseChannel **r_pchan) { - const uint hit_object = hit & 0xFFFF; + const uint hit_object = select_id & 0xFFFF; Base *base = NULL; bPoseChannel *pchan = NULL; /* TODO(campbell): optimize, eg: sort & binary search. */ @@ -130,7 +132,7 @@ Base *ED_armature_base_and_pchan_from_select_buffer(Base **bases, } if (base != NULL) { if (base->object->pose != NULL) { - const uint hit_bone = (hit & ~BONESEL_ANY) >> 16; + const uint hit_bone = (select_id & ~BONESEL_ANY) >> 16; /* pchan may be NULL. */ pchan = BLI_findlink(&base->object->pose->chanbase, hit_bone); } @@ -141,11 +143,11 @@ Base *ED_armature_base_and_pchan_from_select_buffer(Base **bases, Base *ED_armature_base_and_bone_from_select_buffer(Base **bases, uint bases_len, - int hit, + const uint select_id, Bone **r_bone) { bPoseChannel *pchan = NULL; - Base *base = ED_armature_base_and_pchan_from_select_buffer(bases, bases_len, hit, &pchan); + Base *base = ED_armature_base_and_pchan_from_select_buffer(bases, bases_len, select_id, &pchan); *r_bone = pchan ? pchan->bone : NULL; return base; } @@ -166,8 +168,8 @@ Base *ED_armature_base_and_bone_from_select_buffer(Base **bases, static void *ed_armature_pick_bone_from_selectbuffer_impl(const bool is_editmode, Base **bases, uint bases_len, - const uint *buffer, - short hits, + const GPUSelectResult *buffer, + const short hits, bool findunsel, bool do_nearest, Base **r_base) @@ -181,7 +183,7 @@ static void *ed_armature_pick_bone_from_selectbuffer_impl(const bool is_editmode int minsel = 0xffffffff, minunsel = 0xffffffff; for (short i = 0; i < hits; i++) { - hitresult = buffer[3 + (i * 4)]; + hitresult = buffer[i].id; if (hitresult & BONESEL_ANY) { /* to avoid including objects in selection */ Base *base = NULL; @@ -221,10 +223,10 @@ static void *ed_armature_pick_bone_from_selectbuffer_impl(const bool is_editmode if (data) { if (sel) { if (do_nearest) { - if (minsel > buffer[4 * i + 1]) { + if (minsel > buffer[i].depth) { firstSel = data; firstSel_base = base; - minsel = buffer[4 * i + 1]; + minsel = buffer[i].depth; } } else { @@ -237,10 +239,10 @@ static void *ed_armature_pick_bone_from_selectbuffer_impl(const bool is_editmode } else { if (do_nearest) { - if (minunsel > buffer[4 * i + 1]) { + if (minunsel > buffer[i].depth) { firstunSel = data; firstunSel_base = base; - minunsel = buffer[4 * i + 1]; + minunsel = buffer[i].depth; } } else { @@ -268,8 +270,8 @@ static void *ed_armature_pick_bone_from_selectbuffer_impl(const bool is_editmode EditBone *ED_armature_pick_ebone_from_selectbuffer(Base **bases, uint bases_len, - const uint *buffer, - short hits, + const GPUSelectResult *buffer, + const short hits, bool findunsel, bool do_nearest, Base **r_base) @@ -281,8 +283,8 @@ EditBone *ED_armature_pick_ebone_from_selectbuffer(Base **bases, bPoseChannel *ED_armature_pick_pchan_from_selectbuffer(Base **bases, uint bases_len, - const uint *buffer, - short hits, + const GPUSelectResult *buffer, + const short hits, bool findunsel, bool do_nearest, Base **r_base) @@ -294,8 +296,8 @@ bPoseChannel *ED_armature_pick_pchan_from_selectbuffer(Base **bases, Bone *ED_armature_pick_bone_from_selectbuffer(Base **bases, uint bases_len, - const uint *buffer, - short hits, + const GPUSelectResult *buffer, + const short hits, bool findunsel, bool do_nearest, Base **r_base) @@ -327,7 +329,7 @@ static void *ed_armature_pick_bone_impl( Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewContext vc; rcti rect; - uint buffer[MAXPICKBUF]; + GPUSelectResult buffer[MAXPICKELEMS]; short hits; ED_view3d_viewcontext_init(C, &vc, depsgraph); @@ -340,7 +342,7 @@ static void *ed_armature_pick_bone_impl( hits = view3d_opengl_select_with_id_filter(&vc, buffer, - MAXPICKBUF, + ARRAY_SIZE(buffer), &rect, VIEW3D_SELECT_PICK_NEAREST, VIEW3D_SELECT_FILTER_NOP, @@ -636,15 +638,15 @@ void ARMATURE_OT_select_linked_pick(wmOperatorType *ot) * \{ */ /* utility function for get_nearest_editbonepoint */ -static int selectbuffer_ret_hits_12(uint *UNUSED(buffer), const int hits12) +static int selectbuffer_ret_hits_12(GPUSelectResult *UNUSED(buffer), const int hits12) { return hits12; } -static int selectbuffer_ret_hits_5(uint *buffer, const int hits12, const int hits5) +static int selectbuffer_ret_hits_5(GPUSelectResult *buffer, const int hits12, const int hits5) { - const int ofs = 4 * hits12; - memcpy(buffer, buffer + ofs, 4 * hits5 * sizeof(uint)); + const int ofs = hits12; + memcpy(buffer, buffer + ofs, hits5 * sizeof(*buffer)); return hits5; } @@ -653,7 +655,7 @@ static int selectbuffer_ret_hits_5(uint *buffer, const int hits12, const int hit static EditBone *get_nearest_editbonepoint( ViewContext *vc, bool findunsel, bool use_cycle, Base **r_base, int *r_selmask) { - uint buffer[MAXPICKBUF]; + GPUSelectResult buffer[MAXPICKELEMS]; struct { uint hitresult; Base *base; @@ -692,7 +694,7 @@ static EditBone *get_nearest_editbonepoint( rcti rect; BLI_rcti_init_pt_radius(&rect, vc->mval, 12); const int hits12 = view3d_opengl_select_with_id_filter( - vc, buffer, MAXPICKBUF, &rect, select_mode, select_filter, select_id_ignore); + vc, buffer, ARRAY_SIZE(buffer), &rect, select_mode, select_filter, select_id_ignore); if (hits12 == 1) { hits = selectbuffer_ret_hits_12(buffer, hits12); @@ -701,10 +703,15 @@ static EditBone *get_nearest_editbonepoint( else if (hits12 > 0) { int ofs; - ofs = 4 * hits12; + ofs = hits12; BLI_rcti_init_pt_radius(&rect, vc->mval, 5); - const int hits5 = view3d_opengl_select_with_id_filter( - vc, buffer + ofs, MAXPICKBUF - ofs, &rect, select_mode, select_filter, select_id_ignore); + const int hits5 = view3d_opengl_select_with_id_filter(vc, + buffer + ofs, + ARRAY_SIZE(buffer) - ofs, + &rect, + select_mode, + select_filter, + select_id_ignore); if (hits5 == 1) { hits = selectbuffer_ret_hits_5(buffer, hits12, hits5); @@ -732,7 +739,7 @@ cache_end: /* See if there are any selected bones in this group */ if (hits > 0) { if (hits == 1) { - result_bias.hitresult = buffer[3]; + result_bias.hitresult = buffer->id; result_bias.base = ED_armature_base_and_ebone_from_select_buffer( bases, bases_len, result_bias.hitresult, &result_bias.ebone); } @@ -771,7 +778,7 @@ cache_end: } for (int i = 0; i < hits; i++) { - const uint hitresult = buffer[3 + (i * 4)]; + const uint hitresult = buffer[i].id; Base *base = NULL; EditBone *ebone; diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index 0b889149f9d..f41c3657431 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -240,8 +240,8 @@ void ED_armature_pose_select_pick_bone(ViewLayer *view_layer, bool ED_armature_pose_select_pick_with_buffer(ViewLayer *view_layer, View3D *v3d, Base *base, - const uint *buffer, - short hits, + const struct GPUSelectResult *buffer, + const short hits, bool extend, bool deselect, bool toggle, diff --git a/source/blender/editors/curve/CMakeLists.txt b/source/blender/editors/curve/CMakeLists.txt index 877c2d99102..0ac572c0422 100644 --- a/source/blender/editors/curve/CMakeLists.txt +++ b/source/blender/editors/curve/CMakeLists.txt @@ -51,9 +51,5 @@ set(LIB extern_curve_fit_nd ) -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - blender_add_lib(bf_editor_curve "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/gpencil/CMakeLists.txt b/source/blender/editors/gpencil/CMakeLists.txt index bff7310e9f7..93d17598181 100644 --- a/source/blender/editors/gpencil/CMakeLists.txt +++ b/source/blender/editors/gpencil/CMakeLists.txt @@ -86,9 +86,5 @@ if(WITH_POTRACE) add_definitions(-DWITH_POTRACE) endif() -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - blender_add_lib(bf_editor_gpencil "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 7631bd35e79..afba3c7b96a 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -35,6 +35,7 @@ struct Base; struct Bone; struct Depsgraph; struct EditBone; +struct GPUSelectResult; struct ListBase; struct Main; struct Mesh; @@ -157,22 +158,22 @@ int ED_armature_join_objects_exec(struct bContext *C, struct wmOperator *op); struct Base *ED_armature_base_and_ebone_from_select_buffer(struct Base **bases, uint bases_len, - int hit, + unsigned int select_id, struct EditBone **r_ebone); struct Object *ED_armature_object_and_ebone_from_select_buffer(struct Object **objects, uint objects_len, - int hit, + unsigned int select_id, struct EditBone **r_ebone); struct Base *ED_armature_base_and_pchan_from_select_buffer(struct Base **bases, uint bases_len, - int hit, + unsigned int select_id, struct bPoseChannel **r_pchan); /** * For callers that don't need the pose channel. */ struct Base *ED_armature_base_and_bone_from_select_buffer(struct Base **bases, uint bases_len, - int hit, + unsigned int select_id, struct Bone **r_bone); bool ED_armature_edit_deselect_all(struct Object *obedit); bool ED_armature_edit_deselect_all_visible(struct Object *obedit); @@ -334,7 +335,7 @@ void ED_armature_pose_select_pick_bone(struct ViewLayer *view_layer, bool ED_armature_pose_select_pick_with_buffer(struct ViewLayer *view_layer, struct View3D *v3d, struct Base *base, - const unsigned int *buffer, + const struct GPUSelectResult *buffer, short hits, bool extend, bool deselect, diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h index 4e794838b2f..6d9691d96f4 100644 --- a/source/blender/editors/include/ED_util.h +++ b/source/blender/editors/include/ED_util.h @@ -62,9 +62,9 @@ bool ED_editors_flush_edits(struct Main *bmain); * \param new_id: may be NULL to unlink \a old_id. */ void ED_spacedata_id_remap_single(struct ScrArea *area, - struct SpaceLink *sl, - struct ID *old_id, - struct ID *new_id); + struct SpaceLink *sl, + struct ID *old_id, + struct ID *new_id); void ED_spacedata_id_remap(struct ScrArea *area, struct SpaceLink *sl, const struct IDRemapper *mappings); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 0398c209c68..3bbffc3b7c9 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -41,6 +41,7 @@ struct Camera; struct CustomData_MeshMasks; struct Depsgraph; struct EditBone; +struct GPUSelectResult; struct ID; struct MVert; struct Main; @@ -871,9 +872,14 @@ bool ED_view3d_autodist_simple(struct ARegion *region, bool ED_view3d_depth_read_cached_seg( const ViewDepths *vd, const int mval_sta[2], const int mval_end[2], int margin, float *depth); -/* select */ +/** + * The default value for the maximum number of elements that can be selected at once + * using view-port selection. + * + * \note in many cases this defines the size of fixed-size stack buffers, + * so take care increasing this value. + */ #define MAXPICKELEMS 2500 -#define MAXPICKBUF (4 * MAXPICKELEMS) typedef enum { /* all elements in the region, ignore depth */ @@ -912,21 +918,21 @@ void view3d_opengl_select_cache_end(void); * \note (vc->obedit == NULL) can be set to explicitly skip edit-object selection. */ int view3d_opengl_select_ex(struct ViewContext *vc, - unsigned int *buffer, - unsigned int bufsize, + struct GPUSelectResult *buffer, + unsigned int buffer_len, const struct rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter, bool do_material_slot_selection); int view3d_opengl_select(struct ViewContext *vc, - unsigned int *buffer, - unsigned int bufsize, + struct GPUSelectResult *buffer, + unsigned int buffer_len, const struct rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter); int view3d_opengl_select_with_id_filter(struct ViewContext *vc, - unsigned int *buffer, - unsigned int bufsize, + struct GPUSelectResult *buffer, + unsigned int buffer_len, const struct rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter, diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h index 1009ae5cd3f..ec80338b4c0 100644 --- a/source/blender/editors/include/UI_interface_icons.h +++ b/source/blender/editors/include/UI_interface_icons.h @@ -102,7 +102,6 @@ void UI_icon_render_id_ex(const struct bContext *C, const bool use_job, struct PreviewImage *r_preview_image); - /** * Render size for preview images and icons */ diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c index fd03cc5e12c..6fa94730365 100644 --- a/source/blender/editors/interface/interface_eyedropper.c +++ b/source/blender/editors/interface/interface_eyedropper.c @@ -25,6 +25,7 @@ #include "DNA_space_types.h" #include "BLI_math_color.h" +#include "BLI_math_vector.h" #include "BKE_context.h" #include "BKE_screen.h" @@ -107,7 +108,7 @@ wmKeyMap *eyedropper_colorband_modal_keymap(wmKeyConfig *keyconf) /** \name Generic Shared Functions * \{ */ -static void eyedropper_draw_cursor_text_ex(const int x, const int y, const char *name) +static void eyedropper_draw_cursor_text_ex(const int xy[2], const char *name) { const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; @@ -119,7 +120,7 @@ static void eyedropper_draw_cursor_text_ex(const int x, const int y, const char rgba_uchar_to_float(col_fg, wcol->text); rgba_uchar_to_float(col_bg, wcol->inner); - UI_fontstyle_draw_simple_backdrop(fstyle, x, y + U.widget_unit, name, col_fg, col_bg); + UI_fontstyle_draw_simple_backdrop(fstyle, xy[0], xy[1] + U.widget_unit, name, col_fg, col_bg); } void eyedropper_draw_cursor_text_window(const struct wmWindow *window, const char *name) @@ -128,19 +129,16 @@ void eyedropper_draw_cursor_text_window(const struct wmWindow *window, const cha return; } - const int x = window->eventstate->xy[0]; - const int y = window->eventstate->xy[1]; - - eyedropper_draw_cursor_text_ex(x, y, name); + eyedropper_draw_cursor_text_ex(window->eventstate->xy, name); } -void eyedropper_draw_cursor_text_region(const int x, const int y, const char *name) +void eyedropper_draw_cursor_text_region(const int xy[2], const char *name) { if (name[0] == '\0') { return; } - eyedropper_draw_cursor_text_ex(x, y, name); + eyedropper_draw_cursor_text_ex(xy, name); } uiBut *eyedropper_get_property_button_under_mouse(bContext *C, const wmEvent *event) @@ -173,8 +171,7 @@ void datadropper_win_area_find( } } else if (mval != r_mval) { - r_mval[0] = mval[0]; - r_mval[1] = mval[1]; + copy_v2_v2_int(r_mval, mval); } } diff --git a/source/blender/editors/interface/interface_eyedropper_color.c b/source/blender/editors/interface/interface_eyedropper_color.c index 05840175fab..b5eed2534a3 100644 --- a/source/blender/editors/interface/interface_eyedropper_color.c +++ b/source/blender/editors/interface/interface_eyedropper_color.c @@ -254,8 +254,10 @@ static bool eyedropper_cryptomatte_sample_image_fl(const bNode *node, return success; } -static bool eyedropper_cryptomatte_sample_fl( - bContext *C, Eyedropper *eye, int mx, int my, float r_col[3]) +static bool eyedropper_cryptomatte_sample_fl(bContext *C, + Eyedropper *eye, + const int m_xy[2], + float r_col[3]) { bNode *node = eye->crypto_node; NodeCryptomatte *crypto = node ? ((NodeCryptomatte *)node->storage) : NULL; @@ -265,17 +267,17 @@ static bool eyedropper_cryptomatte_sample_fl( } bScreen *screen = CTX_wm_screen(C); - ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, (const int[2]){mx, my}); + ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, m_xy); if (!area || !ELEM(area->spacetype, SPACE_IMAGE, SPACE_NODE, SPACE_CLIP)) { return false; } - ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, (const int[2]){mx, my}); + ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, m_xy); if (!region) { return false; } - int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin}; + int mval[2] = {m_xy[0] - region->winrct.xmin, m_xy[1] - region->winrct.ymin}; float fpos[2] = {-1.0f, -1.0}; switch (area->spacetype) { case SPACE_IMAGE: { @@ -324,7 +326,7 @@ static bool eyedropper_cryptomatte_sample_fl( return false; } -void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3]) +void eyedropper_color_sample_fl(bContext *C, const int m_xy[2], float r_col[3]) { /* we could use some clever */ Main *bmain = CTX_data_main(C); @@ -332,10 +334,10 @@ void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3]) const char *display_device = CTX_data_scene(C)->display_settings.display_device; struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device); + int mval[2]; wmWindow *win; ScrArea *area; - int mval[2] = {mx, my}; - datadropper_win_area_find(C, mval, mval, &win, &area); + datadropper_win_area_find(C, m_xy, mval, &win, &area); if (area) { if (area->spacetype == SPACE_IMAGE) { @@ -406,17 +408,17 @@ static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3 RNA_property_update(C, &eye->ptr, eye->prop); } -static void eyedropper_color_sample(bContext *C, Eyedropper *eye, int mx, int my) +static void eyedropper_color_sample(bContext *C, Eyedropper *eye, const int m_xy[2]) { /* Accumulate color. */ float col[3]; if (eye->crypto_node) { - if (!eyedropper_cryptomatte_sample_fl(C, eye, mx, my, col)) { + if (!eyedropper_cryptomatte_sample_fl(C, eye, m_xy, col)) { return; } } else { - eyedropper_color_sample_fl(C, mx, my, col); + eyedropper_color_sample_fl(C, m_xy, col); } if (!eye->crypto_node) { @@ -439,13 +441,13 @@ static void eyedropper_color_sample(bContext *C, Eyedropper *eye, int mx, int my eyedropper_color_set(C, eye, accum_col); } -static void eyedropper_color_sample_text_update(bContext *C, Eyedropper *eye, int mx, int my) +static void eyedropper_color_sample_text_update(bContext *C, Eyedropper *eye, const int m_xy[2]) { float col[3]; eye->sample_text[0] = '\0'; if (eye->cryptomatte_session) { - if (eyedropper_cryptomatte_sample_fl(C, eye, mx, my, col)) { + if (eyedropper_cryptomatte_sample_fl(C, eye, m_xy, col)) { BKE_cryptomatte_find_name( eye->cryptomatte_session, col[0], eye->sample_text, sizeof(eye->sample_text)); eye->sample_text[sizeof(eye->sample_text) - 1] = '\0'; @@ -476,7 +478,7 @@ static int eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event) case EYE_MODAL_SAMPLE_CONFIRM: { const bool is_undo = eye->is_undo; if (eye->accum_tot == 0) { - eyedropper_color_sample(C, eye, event->xy[0], event->xy[1]); + eyedropper_color_sample(C, eye, event->xy); } eyedropper_exit(C, op); /* Could support finished & undo-skip. */ @@ -485,23 +487,23 @@ static int eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event) case EYE_MODAL_SAMPLE_BEGIN: /* enable accum and make first sample */ eye->accum_start = true; - eyedropper_color_sample(C, eye, event->xy[0], event->xy[1]); + eyedropper_color_sample(C, eye, event->xy); break; case EYE_MODAL_SAMPLE_RESET: eye->accum_tot = 0; zero_v3(eye->accum_col); - eyedropper_color_sample(C, eye, event->xy[0], event->xy[1]); + eyedropper_color_sample(C, eye, event->xy); break; } } else if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { if (eye->accum_start) { /* button is pressed so keep sampling */ - eyedropper_color_sample(C, eye, event->xy[0], event->xy[1]); + eyedropper_color_sample(C, eye, event->xy); } if (eye->draw_handle_sample_text) { - eyedropper_color_sample_text_update(C, eye, event->xy[0], event->xy[1]); + eyedropper_color_sample_text_update(C, eye, event->xy); ED_region_tag_redraw(CTX_wm_region(C)); } } diff --git a/source/blender/editors/interface/interface_eyedropper_colorband.c b/source/blender/editors/interface/interface_eyedropper_colorband.c index 22320282766..05ed4ecf601 100644 --- a/source/blender/editors/interface/interface_eyedropper_colorband.c +++ b/source/blender/editors/interface/interface_eyedropper_colorband.c @@ -58,7 +58,7 @@ typedef struct Colorband_RNAUpdateCb { } Colorband_RNAUpdateCb; typedef struct EyedropperColorband { - int last_x, last_y; + int event_xy_last[2]; /* Alpha is currently fixed at 1.0, may support in future. */ float (*color_buffer)[4]; int color_buffer_alloc; @@ -142,13 +142,12 @@ static bool eyedropper_colorband_init(bContext *C, wmOperator *op) static void eyedropper_colorband_sample_point(bContext *C, EyedropperColorband *eye, - int mx, - int my) + const int m_xy[2]) { - if (eye->last_x != mx || eye->last_y != my) { + if (eye->event_xy_last[0] != m_xy[0] || eye->event_xy_last[1] != m_xy[1]) { float col[4]; col[3] = 1.0f; /* TODO: sample alpha */ - eyedropper_color_sample_fl(C, mx, my, col); + eyedropper_color_sample_fl(C, m_xy, col); if (eye->color_buffer_len + 1 == eye->color_buffer_alloc) { eye->color_buffer_alloc *= 2; eye->color_buffer = MEM_reallocN(eye->color_buffer, @@ -156,8 +155,7 @@ static void eyedropper_colorband_sample_point(bContext *C, } copy_v4_v4(eye->color_buffer[eye->color_buffer_len], col); eye->color_buffer_len += 1; - eye->last_x = mx; - eye->last_y = my; + copy_v2_v2_int(eye->event_xy_last, m_xy); eye->is_set = true; } } @@ -167,21 +165,20 @@ static bool eyedropper_colorband_sample_callback(int mx, int my, void *userdata) struct EyedropperColorband_Context *data = userdata; bContext *C = data->context; EyedropperColorband *eye = data->eye; - eyedropper_colorband_sample_point(C, eye, mx, my); + const int cursor[2] = {mx, my}; + eyedropper_colorband_sample_point(C, eye, cursor); return true; } static void eyedropper_colorband_sample_segment(bContext *C, EyedropperColorband *eye, - int mx, - int my) + const int m_xy[2]) { /* Since the mouse tends to move rather rapidly we use #BLI_bitmap_draw_2d_line_v2v2i * to interpolate between the reported coordinates */ struct EyedropperColorband_Context userdata = {C, eye}; - const int p1[2] = {eye->last_x, eye->last_y}; - const int p2[2] = {mx, my}; - BLI_bitmap_draw_2d_line_v2v2i(p1, p2, eyedropper_colorband_sample_callback, &userdata); + BLI_bitmap_draw_2d_line_v2v2i( + eye->event_xy_last, m_xy, eyedropper_colorband_sample_callback, &userdata); } static void eyedropper_colorband_exit(bContext *C, wmOperator *op) @@ -233,7 +230,7 @@ static int eyedropper_colorband_modal(bContext *C, wmOperator *op, const wmEvent return OPERATOR_CANCELLED; case EYE_MODAL_SAMPLE_CONFIRM: { const bool is_undo = eye->is_undo; - eyedropper_colorband_sample_segment(C, eye, event->xy[0], event->xy[1]); + eyedropper_colorband_sample_segment(C, eye, event->xy); eyedropper_colorband_apply(C, op); eyedropper_colorband_exit(C, op); /* Could support finished & undo-skip. */ @@ -242,10 +239,9 @@ static int eyedropper_colorband_modal(bContext *C, wmOperator *op, const wmEvent case EYE_MODAL_SAMPLE_BEGIN: /* enable accum and make first sample */ eye->sample_start = true; - eyedropper_colorband_sample_point(C, eye, event->xy[0], event->xy[1]); + eyedropper_colorband_sample_point(C, eye, event->xy); eyedropper_colorband_apply(C, op); - eye->last_x = event->xy[0]; - eye->last_y = event->xy[1]; + copy_v2_v2_int(eye->event_xy_last, event->xy); break; case EYE_MODAL_SAMPLE_RESET: break; @@ -253,7 +249,7 @@ static int eyedropper_colorband_modal(bContext *C, wmOperator *op, const wmEvent } else if (event->type == MOUSEMOVE) { if (eye->sample_start) { - eyedropper_colorband_sample_segment(C, eye, event->xy[0], event->xy[1]); + eyedropper_colorband_sample_segment(C, eye, event->xy); eyedropper_colorband_apply(C, op); } } @@ -280,7 +276,7 @@ static int eyedropper_colorband_point_modal(bContext *C, wmOperator *op, const w } break; case EYE_MODAL_POINT_SAMPLE: - eyedropper_colorband_sample_point(C, eye, event->xy[0], event->xy[1]); + eyedropper_colorband_sample_point(C, eye, event->xy); eyedropper_colorband_apply(C, op); if (eye->color_buffer_len == MAXCOLORBAND) { eyedropper_colorband_exit(C, op); diff --git a/source/blender/editors/interface/interface_eyedropper_datablock.c b/source/blender/editors/interface/interface_eyedropper_datablock.c index cf53ef0ec75..812011101e8 100644 --- a/source/blender/editors/interface/interface_eyedropper_datablock.c +++ b/source/blender/editors/interface/interface_eyedropper_datablock.c @@ -32,6 +32,7 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" +#include "BLI_math_vector.h" #include "BLI_string.h" #include "BLT_translation.h" @@ -80,7 +81,7 @@ static void datadropper_draw_cb(const struct bContext *UNUSED(C), void *arg) { DataDropper *ddr = arg; - eyedropper_draw_cursor_text_region(UNPACK2(ddr->name_pos), ddr->name); + eyedropper_draw_cursor_text_region(ddr->name_pos, ddr->name); } static int datadropper_init(bContext *C, wmOperator *op) @@ -152,7 +153,7 @@ static void datadropper_exit(bContext *C, wmOperator *op) * \brief get the ID from the 3D view or outliner. */ static void datadropper_id_sample_pt( - bContext *C, wmWindow *win, ScrArea *area, DataDropper *ddr, int mx, int my, ID **r_id) + bContext *C, wmWindow *win, ScrArea *area, DataDropper *ddr, const int m_xy[2], ID **r_id) { wmWindow *win_prev = CTX_wm_window(C); ScrArea *area_prev = CTX_wm_area(C); @@ -162,9 +163,9 @@ static void datadropper_id_sample_pt( if (area) { if (ELEM(area->spacetype, SPACE_VIEW3D, SPACE_OUTLINER)) { - ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, (const int[2]){mx, my}); + ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, m_xy); if (region) { - const int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin}; + const int mval[2] = {m_xy[0] - region->winrct.xmin, m_xy[1] - region->winrct.ymin}; Base *base; CTX_wm_window_set(C, win); @@ -205,8 +206,7 @@ static void datadropper_id_sample_pt( *r_id = id; } - ddr->name_pos[0] = mval[0]; - ddr->name_pos[1] = mval[1]; + copy_v2_v2_int(ddr->name_pos, mval); } } } @@ -234,17 +234,16 @@ static bool datadropper_id_set(bContext *C, DataDropper *ddr, ID *id) } /* single point sample & set */ -static bool datadropper_id_sample(bContext *C, DataDropper *ddr, int mx, int my) +static bool datadropper_id_sample(bContext *C, DataDropper *ddr, const int m_xy[2]) { ID *id = NULL; + int mval[2]; wmWindow *win; ScrArea *area; + datadropper_win_area_find(C, m_xy, mval, &win, &area); - int mval[] = {mx, my}; - datadropper_win_area_find(C, mval, mval, &win, &area); - - datadropper_id_sample_pt(C, win, area, ddr, mval[0], mval[1], &id); + datadropper_id_sample_pt(C, win, area, ddr, mval, &id); return datadropper_id_set(C, ddr, id); } @@ -292,7 +291,7 @@ static int datadropper_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_CANCELLED; case EYE_MODAL_SAMPLE_CONFIRM: { const bool is_undo = ddr->is_undo; - const bool success = datadropper_id_sample(C, ddr, event->xy[0], event->xy[1]); + const bool success = datadropper_id_sample(C, ddr, event->xy); datadropper_exit(C, op); if (success) { /* Could support finished & undo-skip. */ @@ -306,16 +305,15 @@ static int datadropper_modal(bContext *C, wmOperator *op, const wmEvent *event) else if (event->type == MOUSEMOVE) { ID *id = NULL; + int mval[2]; wmWindow *win; ScrArea *area; - - int mval[] = {event->xy[0], event->xy[1]}; - datadropper_win_area_find(C, mval, mval, &win, &area); + datadropper_win_area_find(C, event->xy, mval, &win, &area); /* Set the region for eyedropper cursor text drawing */ datadropper_set_draw_callback_region(area, ddr); - datadropper_id_sample_pt(C, win, area, ddr, mval[0], mval[1], &id); + datadropper_id_sample_pt(C, win, area, ddr, mval, &id); } return OPERATOR_RUNNING_MODAL; diff --git a/source/blender/editors/interface/interface_eyedropper_depth.c b/source/blender/editors/interface/interface_eyedropper_depth.c index 8c6b0ac9cfe..b11001c4bf2 100644 --- a/source/blender/editors/interface/interface_eyedropper_depth.c +++ b/source/blender/editors/interface/interface_eyedropper_depth.c @@ -81,7 +81,7 @@ static void depthdropper_draw_cb(const struct bContext *UNUSED(C), void *arg) { DepthDropper *ddr = arg; - eyedropper_draw_cursor_text_region(UNPACK2(ddr->name_pos), ddr->name); + eyedropper_draw_cursor_text_region(ddr->name_pos, ddr->name); } static int depthdropper_init(bContext *C, wmOperator *op) @@ -152,12 +152,14 @@ static void depthdropper_exit(bContext *C, wmOperator *op) /** * \brief get the ID from the screen. */ -static void depthdropper_depth_sample_pt( - bContext *C, DepthDropper *ddr, int mx, int my, float *r_depth) +static void depthdropper_depth_sample_pt(bContext *C, + DepthDropper *ddr, + const int m_xy[2], + float *r_depth) { /* we could use some clever */ bScreen *screen = CTX_wm_screen(C); - ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, (const int[2]){mx, my}); + ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, m_xy); Scene *scene = CTX_data_scene(C); ScrArea *area_prev = CTX_wm_area(C); @@ -167,14 +169,14 @@ static void depthdropper_depth_sample_pt( if (area) { if (area->spacetype == SPACE_VIEW3D) { - ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, (const int[2]){mx, my}); + ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, m_xy); if (region) { struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); View3D *v3d = area->spacedata.first; RegionView3D *rv3d = region->regiondata; /* weak, we could pass in some reference point */ const float *view_co = v3d->camera ? v3d->camera->obmat[3] : rv3d->viewinv[3]; - const int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin}; + const int mval[2] = {m_xy[0] - region->winrct.xmin, m_xy[1] - region->winrct.ymin}; copy_v2_v2_int(ddr->name_pos, mval); float co[3]; @@ -234,19 +236,19 @@ static void depthdropper_depth_set_accum(bContext *C, DepthDropper *ddr) } /* single point sample & set */ -static void depthdropper_depth_sample(bContext *C, DepthDropper *ddr, int mx, int my) +static void depthdropper_depth_sample(bContext *C, DepthDropper *ddr, const int m_xy[2]) { float depth = -1.0f; if (depth != -1.0f) { - depthdropper_depth_sample_pt(C, ddr, mx, my, &depth); + depthdropper_depth_sample_pt(C, ddr, m_xy, &depth); depthdropper_depth_set(C, ddr, depth); } } -static void depthdropper_depth_sample_accum(bContext *C, DepthDropper *ddr, int mx, int my) +static void depthdropper_depth_sample_accum(bContext *C, DepthDropper *ddr, const int m_xy[2]) { float depth = -1.0f; - depthdropper_depth_sample_pt(C, ddr, mx, my, &depth); + depthdropper_depth_sample_pt(C, ddr, m_xy, &depth); if (depth != -1.0f) { ddr->accum_depth += depth; ddr->accum_tot++; @@ -276,7 +278,7 @@ static int depthdropper_modal(bContext *C, wmOperator *op, const wmEvent *event) case EYE_MODAL_SAMPLE_CONFIRM: { const bool is_undo = ddr->is_undo; if (ddr->accum_tot == 0) { - depthdropper_depth_sample(C, ddr, event->xy[0], event->xy[1]); + depthdropper_depth_sample(C, ddr, event->xy); } else { depthdropper_depth_set_accum(C, ddr); @@ -288,12 +290,12 @@ static int depthdropper_modal(bContext *C, wmOperator *op, const wmEvent *event) case EYE_MODAL_SAMPLE_BEGIN: /* enable accum and make first sample */ ddr->accum_start = true; - depthdropper_depth_sample_accum(C, ddr, event->xy[0], event->xy[1]); + depthdropper_depth_sample_accum(C, ddr, event->xy); break; case EYE_MODAL_SAMPLE_RESET: ddr->accum_tot = 0; ddr->accum_depth = 0.0f; - depthdropper_depth_sample_accum(C, ddr, event->xy[0], event->xy[1]); + depthdropper_depth_sample_accum(C, ddr, event->xy); depthdropper_depth_set_accum(C, ddr); break; } @@ -301,7 +303,7 @@ static int depthdropper_modal(bContext *C, wmOperator *op, const wmEvent *event) else if (event->type == MOUSEMOVE) { if (ddr->accum_start) { /* button is pressed so keep sampling */ - depthdropper_depth_sample_accum(C, ddr, event->xy[0], event->xy[1]); + depthdropper_depth_sample_accum(C, ddr, event->xy); depthdropper_depth_set_accum(C, ddr); } } diff --git a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c index d76ff84bcad..c1d49406818 100644 --- a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c +++ b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c @@ -265,9 +265,9 @@ static void eyedropper_gpencil_color_set(bContext *C, const wmEvent *event, Eyed } /* Sample the color below cursor. */ -static void eyedropper_gpencil_color_sample(bContext *C, EyedropperGPencil *eye, int mx, int my) +static void eyedropper_gpencil_color_sample(bContext *C, EyedropperGPencil *eye, const int m_xy[2]) { - eyedropper_color_sample_fl(C, mx, my, eye->color); + eyedropper_color_sample_fl(C, m_xy, eye->color); } /* Cancel operator. */ @@ -292,7 +292,7 @@ static int eyedropper_gpencil_modal(bContext *C, wmOperator *op, const wmEvent * return OPERATOR_CANCELLED; } case EYE_MODAL_SAMPLE_CONFIRM: { - eyedropper_gpencil_color_sample(C, eye, event->xy[0], event->xy[1]); + eyedropper_gpencil_color_sample(C, eye, event->xy); /* Create material. */ eyedropper_gpencil_color_set(C, event, eye); @@ -309,7 +309,7 @@ static int eyedropper_gpencil_modal(bContext *C, wmOperator *op, const wmEvent * } case MOUSEMOVE: case INBETWEEN_MOUSEMOVE: { - eyedropper_gpencil_color_sample(C, eye, event->xy[0], event->xy[1]); + eyedropper_gpencil_color_sample(C, eye, event->xy); break; } default: { diff --git a/source/blender/editors/interface/interface_eyedropper_intern.h b/source/blender/editors/interface/interface_eyedropper_intern.h index ec448ef9b9f..335ee520791 100644 --- a/source/blender/editors/interface/interface_eyedropper_intern.h +++ b/source/blender/editors/interface/interface_eyedropper_intern.h @@ -25,7 +25,7 @@ /* interface_eyedropper.c */ void eyedropper_draw_cursor_text_window(const struct wmWindow *window, const char *name); -void eyedropper_draw_cursor_text_region(int x, int y, const char *name); +void eyedropper_draw_cursor_text_region(const int xy[2], const char *name); /** * Utility to retrieve a button representing a RNA property that is currently under the cursor. * @@ -51,7 +51,7 @@ void datadropper_win_area_find(const struct bContext *C, * * \note Exposed by 'interface_eyedropper_intern.h' for use with color band picking. */ -void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3]); +void eyedropper_color_sample_fl(bContext *C, const int m_xy[2], float r_col[3]); /* Used for most eye-dropper operators. */ enum { diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 44942d508ca..1fe538eca5d 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -39,9 +39,8 @@ #include "BKE_global.h" #include "BLF_api.h" -#ifdef WITH_INTERNATIONAL -# include "BLT_translation.h" -#endif + +#include "BLT_translation.h" #include "UI_interface.h" diff --git a/source/blender/editors/io/CMakeLists.txt b/source/blender/editors/io/CMakeLists.txt index cb1c3cedf8e..5db16354124 100644 --- a/source/blender/editors/io/CMakeLists.txt +++ b/source/blender/editors/io/CMakeLists.txt @@ -84,10 +84,6 @@ if(WITH_USD) add_definitions(-DWITH_USD) endif() -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - if(WITH_PUGIXML) add_definitions(-DWITH_PUGIXML) endif() diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt index 4ad2e57d266..0fb64c8a46b 100644 --- a/source/blender/editors/mesh/CMakeLists.txt +++ b/source/blender/editors/mesh/CMakeLists.txt @@ -78,10 +78,6 @@ set(LIB bf_windowmanager ) -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) endif() diff --git a/source/blender/editors/metaball/CMakeLists.txt b/source/blender/editors/metaball/CMakeLists.txt index 4e600dc0277..a247920c305 100644 --- a/source/blender/editors/metaball/CMakeLists.txt +++ b/source/blender/editors/metaball/CMakeLists.txt @@ -20,6 +20,7 @@ set(INC ../../blenkernel ../../blenlib ../../depsgraph + ../../gpu ../../makesdna ../../makesrna ../../render diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index bedb9d4f4f4..51cfc920d1d 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -47,6 +47,8 @@ #include "DEG_depsgraph.h" +#include "GPU_select.h" + #include "ED_mball.h" #include "ED_object.h" #include "ED_screen.h" @@ -756,15 +758,19 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese static MetaElem *startelem = NULL; ViewContext vc; int a, hits; - uint buffer[MAXPICKBUF]; + GPUSelectResult buffer[MAXPICKELEMS]; rcti rect; ED_view3d_viewcontext_init(C, &vc, depsgraph); BLI_rcti_init_pt_radius(&rect, mval, 12); - hits = view3d_opengl_select( - &vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST, VIEW3D_SELECT_FILTER_NOP); + hits = view3d_opengl_select(&vc, + buffer, + ARRAY_SIZE(buffer), + &rect, + VIEW3D_SELECT_PICK_NEAREST, + VIEW3D_SELECT_FILTER_NOP); FOREACH_BASE_IN_EDIT_MODE_BEGIN (vc.view_layer, vc.v3d, base) { ED_view3d_viewcontext_init_object(&vc, base->object); @@ -789,7 +795,7 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese ml = startelem; while (ml) { for (a = 0; a < hits; a++) { - int hitresult = buffer[(4 * a) + 3]; + const int hitresult = buffer[a].id; if (hitresult == -1) { continue; } diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index 040b5cd5066..a953c7d7f89 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -85,10 +85,6 @@ if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - if(WITH_EXPERIMENTAL_FEATURES) add_definitions(-DWITH_SIMULATION_DATABLOCK) add_definitions(-DWITH_POINT_CLOUD) diff --git a/source/blender/editors/physics/CMakeLists.txt b/source/blender/editors/physics/CMakeLists.txt index a607663763e..7c32a2dcf1d 100644 --- a/source/blender/editors/physics/CMakeLists.txt +++ b/source/blender/editors/physics/CMakeLists.txt @@ -60,10 +60,6 @@ if(WITH_MOD_FLUID) add_definitions(-DWITH_FLUID) endif() -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - if(WITH_BULLET) list(APPEND INC ../../../../intern/rigidbody diff --git a/source/blender/editors/render/CMakeLists.txt b/source/blender/editors/render/CMakeLists.txt index 1f867c6f1f7..934badd3b6f 100644 --- a/source/blender/editors/render/CMakeLists.txt +++ b/source/blender/editors/render/CMakeLists.txt @@ -67,8 +67,4 @@ if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) endif() -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - blender_add_lib(bf_editor_render "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/scene/CMakeLists.txt b/source/blender/editors/scene/CMakeLists.txt index cd59f06c6e3..ce0c2062766 100644 --- a/source/blender/editors/scene/CMakeLists.txt +++ b/source/blender/editors/scene/CMakeLists.txt @@ -39,8 +39,5 @@ set(LIB bf_blenlib ) -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() blender_add_lib(bf_editor_scene "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt index d194d0cdbb6..7c5ae4dcd5e 100644 --- a/source/blender/editors/screen/CMakeLists.txt +++ b/source/blender/editors/screen/CMakeLists.txt @@ -57,9 +57,5 @@ set(LIB bf_editor_space_sequencer ) -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - blender_add_lib(bf_editor_screen "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index b15b6784d34..907080626e0 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -90,9 +90,5 @@ set(LIB bf_blenlib ) -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - blender_add_lib(bf_editor_sculpt_paint "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index ca012f20f01..133424bae79 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -1730,17 +1730,10 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps, normalize_v3(no); } else { -#if 1 - /* In case the normalizing per pixel isn't optimal, - * we could cache or access from evaluated mesh. */ normal_tri_v3(no, ps->mvert_eval[lt_vtri[0]].co, ps->mvert_eval[lt_vtri[1]].co, ps->mvert_eval[lt_vtri[2]].co); -#else - /* Don't use because some modifiers don't have normal data (subsurf for eg). */ - copy_v3_v3(no, (float *)ps->dm->getTessFaceData(ps->dm, tri_index, CD_NORMAL)); -#endif } if (UNLIKELY(ps->is_flip_object)) { diff --git a/source/blender/editors/space_buttons/CMakeLists.txt b/source/blender/editors/space_buttons/CMakeLists.txt index b5f6874fcfc..e2b2579c256 100644 --- a/source/blender/editors/space_buttons/CMakeLists.txt +++ b/source/blender/editors/space_buttons/CMakeLists.txt @@ -40,10 +40,6 @@ set(SRC set(LIB ) -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) diff --git a/source/blender/editors/space_clip/CMakeLists.txt b/source/blender/editors/space_clip/CMakeLists.txt index db881dafa6b..8f1a2c3c81e 100644 --- a/source/blender/editors/space_clip/CMakeLists.txt +++ b/source/blender/editors/space_clip/CMakeLists.txt @@ -68,11 +68,6 @@ set(LIB ) -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - - blender_add_lib(bf_editor_space_clip "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") # Needed so we can use dna_type_offsets.h for defaults initialization. diff --git a/source/blender/editors/space_file/CMakeLists.txt b/source/blender/editors/space_file/CMakeLists.txt index cbeb2e6f529..1df0c9c4409 100644 --- a/source/blender/editors/space_file/CMakeLists.txt +++ b/source/blender/editors/space_file/CMakeLists.txt @@ -92,10 +92,6 @@ if(WITH_IMAGE_HDR) add_definitions(-DWITH_HDR) endif() -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 2d31e8030a4..044d7aba88f 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -524,7 +524,7 @@ static int compare_apply_inverted(int val, const struct FileSortData *sort_data) * 2) If not possible (file names match) and both represent local IDs, sort by ID-type. * 3) If not possible and only one is a local ID, place files representing local IDs first. * - * TODO (not actually implemented, but should be): + * TODO: (not actually implemented, but should be): * 4) If no file represents a local ID, sort by file path, so that files higher up the file system * hierarchy are placed first. */ diff --git a/source/blender/editors/space_graph/CMakeLists.txt b/source/blender/editors/space_graph/CMakeLists.txt index 2a795dd954c..2e6e6971ce9 100644 --- a/source/blender/editors/space_graph/CMakeLists.txt +++ b/source/blender/editors/space_graph/CMakeLists.txt @@ -61,9 +61,5 @@ if(WITH_AUDASPACE) add_definitions(-DWITH_AUDASPACE) endif() -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - blender_add_lib(bf_editor_space_graph "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt index 7a1bab0ef14..25d0e02ecc0 100644 --- a/source/blender/editors/space_image/CMakeLists.txt +++ b/source/blender/editors/space_image/CMakeLists.txt @@ -53,10 +53,6 @@ set(LIB bf_editor_uvedit ) -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - if(WITH_OPENIMAGEIO) add_definitions(-DWITH_OPENIMAGEIO) endif() diff --git a/source/blender/editors/space_image/image_undo.c b/source/blender/editors/space_image/image_undo.c index e81f3b6a490..73993606a14 100644 --- a/source/blender/editors/space_image/image_undo.c +++ b/source/blender/editors/space_image/image_undo.c @@ -1000,7 +1000,7 @@ void ED_image_undosys_type(UndoType *ut) ut->step_foreach_ID_ref = image_undosys_foreach_ID_ref; - /* NOTE this is actually a confusing case, since it expects a valid context, but only in a + /* NOTE: this is actually a confusing case, since it expects a valid context, but only in a * specific case, see `image_undosys_step_encode` code. We cannot specify * `UNDOTYPE_FLAG_NEED_CONTEXT_FOR_ENCODE` though, as it can be called with a NULL context by * current code. */ diff --git a/source/blender/editors/space_info/CMakeLists.txt b/source/blender/editors/space_info/CMakeLists.txt index 144b21fb9b8..fb17a6c9709 100644 --- a/source/blender/editors/space_info/CMakeLists.txt +++ b/source/blender/editors/space_info/CMakeLists.txt @@ -48,9 +48,5 @@ set(SRC set(LIB ) -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - blender_add_lib(bf_editor_space_info "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_nla/CMakeLists.txt b/source/blender/editors/space_nla/CMakeLists.txt index 9a94d28c604..5326f1cce2b 100644 --- a/source/blender/editors/space_nla/CMakeLists.txt +++ b/source/blender/editors/space_nla/CMakeLists.txt @@ -47,9 +47,5 @@ set(LIB bf_blenlib ) -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - blender_add_lib(bf_editor_space_nla "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_node/CMakeLists.txt b/source/blender/editors/space_node/CMakeLists.txt index 41d6388c947..15e0d04c8fa 100644 --- a/source/blender/editors/space_node/CMakeLists.txt +++ b/source/blender/editors/space_node/CMakeLists.txt @@ -63,10 +63,6 @@ set(LIB bf_editor_screen ) -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - if(WITH_COMPOSITOR) add_definitions(-DWITH_COMPOSITOR) endif() diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt index bc6db978a4f..d97f48bcb68 100644 --- a/source/blender/editors/space_outliner/CMakeLists.txt +++ b/source/blender/editors/space_outliner/CMakeLists.txt @@ -95,9 +95,5 @@ set(LIB bf_editor_undo ) -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - blender_add_lib(bf_editor_space_outliner "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt index bf8cf89699d..d93dc0ac0c0 100644 --- a/source/blender/editors/space_sequencer/CMakeLists.txt +++ b/source/blender/editors/space_sequencer/CMakeLists.txt @@ -70,9 +70,5 @@ if(WITH_AUDASPACE) ) endif() -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - blender_add_lib(bf_editor_space_sequencer "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_text/CMakeLists.txt b/source/blender/editors/space_text/CMakeLists.txt index abd7620ea2b..a85c69caa50 100644 --- a/source/blender/editors/space_text/CMakeLists.txt +++ b/source/blender/editors/space_text/CMakeLists.txt @@ -61,8 +61,5 @@ if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() blender_add_lib(bf_editor_space_text "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt index 19f869ed50b..768c2d3e3a6 100644 --- a/source/blender/editors/space_view3d/CMakeLists.txt +++ b/source/blender/editors/space_view3d/CMakeLists.txt @@ -83,11 +83,6 @@ if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() - -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) endif() diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index b1f19581543..6bcb456a945 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1258,11 +1258,7 @@ static void draw_viewport_name(ARegion *region, View3D *v3d, int xoffset, int *y /* 6 is the maximum size of the axis roll text. */ /* increase size for unicode languages (Chinese in utf-8...) */ -#ifdef WITH_INTERNATIONAL char tmpstr[96 + 6]; -#else - char tmpstr[32 + 6]; -#endif BLF_enable(font_id, BLF_SHADOW); BLF_shadow(font_id, 5, (const float[4]){0.0f, 0.0f, 0.0f, 1.0f}); @@ -1689,9 +1685,9 @@ void ED_view3d_draw_offscreen(Depsgraph *depsgraph, G.f |= G_FLAG_RENDER_VIEWPORT; { - /* free images which can have changed on frame-change - * warning! can be slow so only free animated images - campbell */ - BKE_image_free_anim_gputextures(G.main); /* XXX :((( */ + /* Free images which can have changed on frame-change. + * WARNING(@campbellbarton): can be slow so only free animated images. */ + BKE_image_free_anim_gputextures(G.main); } GPU_matrix_push_projection(); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 45899880b41..34aa24a1eef 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -99,6 +99,7 @@ #include "UI_resources.h" #include "GPU_matrix.h" +#include "GPU_select.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" @@ -1566,8 +1567,8 @@ void VIEW3D_OT_select_menu(wmOperatorType *ot) static Base *object_mouse_select_menu(bContext *C, ViewContext *vc, - const uint *buffer, - int hits, + const GPUSelectResult *buffer, + const int hits, const int mval[2], bool extend, bool deselect, @@ -1585,7 +1586,7 @@ static Base *object_mouse_select_menu(bContext *C, if (buffer) { for (int a = 0; a < hits; a++) { /* index was converted */ - if (base->object->runtime.select_id == (buffer[(4 * a) + 3] & ~0xFFFF0000)) { + if (base->object->runtime.select_id == (buffer[a].id & ~0xFFFF0000)) { ok = true; break; } @@ -1742,7 +1743,7 @@ void VIEW3D_OT_bone_select_menu(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } static bool bone_mouse_select_menu(bContext *C, - const uint *buffer, + const GPUSelectResult *buffer, const int hits, const bool is_editmode, const bool extend, @@ -1760,7 +1761,7 @@ static bool bone_mouse_select_menu(bContext *C, for (int a = 0; a < hits; a++) { void *bone_ptr = NULL; Base *bone_base = NULL; - uint hitresult = buffer[3 + (a * 4)]; + uint hitresult = buffer[a].id; if (!(hitresult & BONESEL_ANY)) { /* To avoid including objects in selection. */ @@ -1874,10 +1875,10 @@ static bool bone_mouse_select_menu(bContext *C, return true; } -static bool selectbuffer_has_bones(const uint *buffer, const uint hits) +static bool selectbuffer_has_bones(const GPUSelectResult *buffer, const uint hits) { for (uint i = 0; i < hits; i++) { - if (buffer[(4 * i) + 3] & 0xFFFF0000) { + if (buffer[i].id & 0xFFFF0000) { return true; } } @@ -1885,25 +1886,25 @@ static bool selectbuffer_has_bones(const uint *buffer, const uint hits) } /* utility function for mixed_bones_object_selectbuffer */ -static int selectbuffer_ret_hits_15(uint *UNUSED(buffer), const int hits15) +static int selectbuffer_ret_hits_15(GPUSelectResult *UNUSED(buffer), const int hits15) { return hits15; } -static int selectbuffer_ret_hits_9(uint *buffer, const int hits15, const int hits9) +static int selectbuffer_ret_hits_9(GPUSelectResult *buffer, const int hits15, const int hits9) { - const int ofs = 4 * hits15; - memcpy(buffer, buffer + ofs, 4 * hits9 * sizeof(uint)); + const int ofs = hits15; + memcpy(buffer, buffer + ofs, hits9 * sizeof(GPUSelectResult)); return hits9; } -static int selectbuffer_ret_hits_5(uint *buffer, +static int selectbuffer_ret_hits_5(GPUSelectResult *buffer, const int hits15, const int hits9, const int hits5) { - const int ofs = 4 * hits15 + 4 * hits9; - memcpy(buffer, buffer + ofs, 4 * hits5 * sizeof(uint)); + const int ofs = hits15 + hits9; + memcpy(buffer, buffer + ofs, hits5 * sizeof(GPUSelectResult)); return hits5; } @@ -1916,7 +1917,8 @@ static int selectbuffer_ret_hits_5(uint *buffer, * Needed so we can step to the next, non-active object when it's already selected, see: T76445. */ static int mixed_bones_object_selectbuffer(ViewContext *vc, - uint *buffer, + GPUSelectResult *buffer, + const int buffer_len, const int mval[2], eV3DSelectObjectFilter select_filter, bool do_nearest, @@ -1941,7 +1943,7 @@ static int mixed_bones_object_selectbuffer(ViewContext *vc, BLI_rcti_init_pt_radius(&rect, mval, 14); hits15 = view3d_opengl_select_ex( - vc, buffer, MAXPICKBUF, &rect, select_mode, select_filter, do_material_slot_selection); + vc, buffer, buffer_len, &rect, select_mode, select_filter, do_material_slot_selection); if (hits15 == 1) { hits = selectbuffer_ret_hits_15(buffer, hits15); goto finally; @@ -1950,10 +1952,10 @@ static int mixed_bones_object_selectbuffer(ViewContext *vc, int ofs; has_bones15 = selectbuffer_has_bones(buffer, hits15); - ofs = 4 * hits15; + ofs = hits15; BLI_rcti_init_pt_radius(&rect, mval, 9); hits9 = view3d_opengl_select( - vc, buffer + ofs, MAXPICKBUF - ofs, &rect, select_mode, select_filter); + vc, buffer + ofs, buffer_len - ofs, &rect, select_mode, select_filter); if (hits9 == 1) { hits = selectbuffer_ret_hits_9(buffer, hits15, hits9); goto finally; @@ -1961,10 +1963,10 @@ static int mixed_bones_object_selectbuffer(ViewContext *vc, else if (hits9 > 0) { has_bones9 = selectbuffer_has_bones(buffer + ofs, hits9); - ofs += 4 * hits9; + ofs += hits9; BLI_rcti_init_pt_radius(&rect, mval, 5); hits5 = view3d_opengl_select( - vc, buffer + ofs, MAXPICKBUF - ofs, &rect, select_mode, select_filter); + vc, buffer + ofs, buffer_len - ofs, &rect, select_mode, select_filter); if (hits5 == 1) { hits = selectbuffer_ret_hits_5(buffer, hits15, hits9, hits5); goto finally; @@ -2007,7 +2009,8 @@ finally: } static int mixed_bones_object_selectbuffer_extended(ViewContext *vc, - uint *buffer, + GPUSelectResult *buffer, + const int buffer_len, const int mval[2], eV3DSelectObjectFilter select_filter, bool use_cycle, @@ -2038,7 +2041,7 @@ static int mixed_bones_object_selectbuffer_extended(ViewContext *vc, do_nearest = do_nearest && !enumerate; int hits = mixed_bones_object_selectbuffer( - vc, buffer, mval, select_filter, do_nearest, true, false); + vc, buffer, buffer_len, mval, select_filter, do_nearest, true, false); return hits; } @@ -2051,7 +2054,7 @@ static int mixed_bones_object_selectbuffer_extended(ViewContext *vc, * \return the active base or NULL. */ static Base *mouse_select_eval_buffer(ViewContext *vc, - const uint *buffer, + const GPUSelectResult *buffer, int hits, Base *startbase, bool has_bones, @@ -2071,10 +2074,10 @@ static Base *mouse_select_eval_buffer(ViewContext *vc, if (has_bones) { /* we skip non-bone hits */ for (a = 0; a < hits; a++) { - if (min > buffer[4 * a + 1] && (buffer[4 * a + 3] & 0xFFFF0000)) { - min = buffer[4 * a + 1]; - selcol = buffer[4 * a + 3] & 0xFFFF; - sub_selection_id = (buffer[4 * a + 3] & 0xFFFF0000) >> 16; + if (min > buffer[a].depth && (buffer[a].id & 0xFFFF0000)) { + min = buffer[a].depth; + selcol = buffer[a].id & 0xFFFF; + sub_selection_id = (buffer[a].id & 0xFFFF0000) >> 16; } } } @@ -2085,10 +2088,10 @@ static Base *mouse_select_eval_buffer(ViewContext *vc, } for (a = 0; a < hits; a++) { - if (min > buffer[4 * a + 1] && notcol != (buffer[4 * a + 3] & 0xFFFF)) { - min = buffer[4 * a + 1]; - selcol = buffer[4 * a + 3] & 0xFFFF; - sub_selection_id = (buffer[4 * a + 3] & 0xFFFF0000) >> 16; + if (min > buffer[a].depth && notcol != (buffer[a].id & 0xFFFF)) { + min = buffer[a].depth; + selcol = buffer[a].id & 0xFFFF; + sub_selection_id = (buffer[a].id & 0xFFFF0000) >> 16; } } } @@ -2127,14 +2130,14 @@ static Base *mouse_select_eval_buffer(ViewContext *vc, for (a = 0; a < hits; a++) { if (has_bones) { /* skip non-bone objects */ - if (buffer[4 * a + 3] & 0xFFFF0000) { - if (base->object->runtime.select_id == (buffer[(4 * a) + 3] & 0xFFFF)) { + if (buffer[a].id & 0xFFFF0000) { + if (base->object->runtime.select_id == (buffer[a].id & 0xFFFF)) { basact = base; } } } else { - if (base->object->runtime.select_id == (buffer[(4 * a) + 3] & 0xFFFF)) { + if (base->object->runtime.select_id == (buffer[a].id & 0xFFFF)) { basact = base; } } @@ -2169,7 +2172,7 @@ static Base *ed_view3d_give_base_under_cursor_ex(bContext *C, Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewContext vc; Base *basact = NULL; - uint buffer[MAXPICKBUF]; + GPUSelectResult buffer[MAXPICKELEMS]; /* setup view context for argument to callbacks */ view3d_operator_needs_opengl(C); @@ -2179,8 +2182,14 @@ static Base *ed_view3d_give_base_under_cursor_ex(bContext *C, const bool do_nearest = !XRAY_ACTIVE(vc.v3d); const bool do_material_slot_selection = r_material_slot != NULL; - const int hits = mixed_bones_object_selectbuffer( - &vc, buffer, mval, VIEW3D_SELECT_FILTER_NOP, do_nearest, false, do_material_slot_selection); + const int hits = mixed_bones_object_selectbuffer(&vc, + buffer, + ARRAY_SIZE(buffer), + mval, + VIEW3D_SELECT_FILTER_NOP, + do_nearest, + false, + do_material_slot_selection); if (hits > 0) { const bool has_bones = (r_material_slot == NULL) && selectbuffer_has_bones(buffer, hits); @@ -2342,7 +2351,7 @@ static bool ed_object_select_pick(bContext *C, } } else { - uint buffer[MAXPICKBUF]; + GPUSelectResult buffer[MAXPICKELEMS]; bool do_nearest; // TIMEIT_START(select_time); @@ -2353,7 +2362,7 @@ static bool ed_object_select_pick(bContext *C, vc.obact) : VIEW3D_SELECT_FILTER_NOP); hits = mixed_bones_object_selectbuffer_extended( - &vc, buffer, mval, select_filter, true, enumerate, &do_nearest); + &vc, buffer, ARRAY_SIZE(buffer), mval, select_filter, true, enumerate, &do_nearest); // TIMEIT_END(select_time); @@ -2383,7 +2392,7 @@ static bool ed_object_select_pick(bContext *C, bool changed = false; for (int i = 0; i < hits; i++) { - int hitresult = buffer[3 + (i * 4)]; + const int hitresult = buffer[i].id; /* if there's bundles in buffer select bundles first, * so non-camera elements should be ignored in buffer */ @@ -2394,7 +2403,7 @@ static bool ed_object_select_pick(bContext *C, /* index of bundle is 1<<16-based. if there's no "bone" index * in height word, this buffer value belongs to camera. not to bundle */ - if (buffer[4 * i + 3] & 0xFFFF0000) { + if (hitresult & 0xFFFF0000) { MovieTracking *tracking = &clip->tracking; ListBase *tracksbase; MovieTrackingTrack *track; @@ -2674,9 +2683,15 @@ static int view3d_select_exec(bContext *C, wmOperator *op) ViewContext vc; ED_view3d_viewcontext_init(C, &vc, depsgraph); - uint buffer[MAXPICKBUF]; - const int hits = mixed_bones_object_selectbuffer( - &vc, buffer, location, VIEW3D_SELECT_FILTER_NOP, false, true, false); + GPUSelectResult buffer[MAXPICKELEMS]; + const int hits = mixed_bones_object_selectbuffer(&vc, + buffer, + ARRAY_SIZE(buffer), + location, + VIEW3D_SELECT_FILTER_NOP, + false, + true, + false); retval = bone_mouse_select_menu(C, buffer, hits, true, extend, deselect, toggle); } if (!retval) { @@ -3256,11 +3271,11 @@ static bool do_meta_box_select(ViewContext *vc, const rcti *rect, const eSelectO int a; bool changed = false; - uint buffer[MAXPICKBUF]; + GPUSelectResult buffer[MAXPICKELEMS]; int hits; hits = view3d_opengl_select( - vc, buffer, MAXPICKBUF, rect, VIEW3D_SELECT_ALL, VIEW3D_SELECT_FILTER_NOP); + vc, buffer, MAXPICKELEMS, rect, VIEW3D_SELECT_ALL, VIEW3D_SELECT_FILTER_NOP); if (SEL_OP_USE_PRE_DESELECT(sel_op)) { changed |= BKE_mball_deselect_all(mb); @@ -3272,7 +3287,7 @@ static bool do_meta_box_select(ViewContext *vc, const rcti *rect, const eSelectO bool is_inside_stiff = false; for (a = 0; a < hits; a++) { - int hitresult = buffer[(4 * a) + 3]; + const int hitresult = buffer[a].id; if (hitresult == -1) { continue; @@ -3323,11 +3338,11 @@ static bool do_armature_box_select(ViewContext *vc, const rcti *rect, const eSel bool changed = false; int a; - uint buffer[MAXPICKBUF]; + GPUSelectResult buffer[MAXPICKELEMS]; int hits; hits = view3d_opengl_select( - vc, buffer, MAXPICKBUF, rect, VIEW3D_SELECT_ALL, VIEW3D_SELECT_FILTER_NOP); + vc, buffer, MAXPICKELEMS, rect, VIEW3D_SELECT_ALL, VIEW3D_SELECT_FILTER_NOP); uint bases_len = 0; Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data( @@ -3347,7 +3362,7 @@ static bool do_armature_box_select(ViewContext *vc, const rcti *rect, const eSel /* first we only check points inside the border */ for (a = 0; a < hits; a++) { - int select_id = buffer[(4 * a) + 3]; + const int select_id = buffer[a].id; if (select_id != -1) { if ((select_id & 0xFFFF0000) == 0) { continue; @@ -3375,14 +3390,13 @@ static bool do_armature_box_select(ViewContext *vc, const rcti *rect, const eSel } /** - * Compare result of 'GPU_select': 'uint[4]', + * Compare result of 'GPU_select': 'GPUSelectResult', * needed for when we need to align with object draw-order. */ static int opengl_bone_select_buffer_cmp(const void *sel_a_p, const void *sel_b_p) { - /* 4th element is select id */ - uint sel_a = ((uint *)sel_a_p)[3]; - uint sel_b = ((uint *)sel_b_p)[3]; + uint sel_a = ((GPUSelectResult *)sel_a_p)->id; + uint sel_b = ((GPUSelectResult *)sel_b_p)->id; #ifdef __BIG_ENDIAN__ BLI_endian_switch_uint32(&sel_a); @@ -3401,14 +3415,15 @@ static int opengl_bone_select_buffer_cmp(const void *sel_a_p, const void *sel_b_ static bool do_object_box_select(bContext *C, ViewContext *vc, rcti *rect, const eSelectOp sel_op) { View3D *v3d = vc->v3d; - int totobj = MAXPICKBUF; /* XXX solve later */ + int totobj = MAXPICKELEMS; /* XXX solve later */ - /* selection buffer now has bones potentially too, so we add MAXPICKBUF */ - uint *vbuffer = MEM_mallocN(4 * (totobj + MAXPICKELEMS) * sizeof(uint[4]), "selection buffer"); + /* Selection buffer has bones potentially too, so we add #MAXPICKELEMS. */ + GPUSelectResult *buffer = MEM_mallocN((totobj + MAXPICKELEMS) * sizeof(GPUSelectResult), + "selection buffer"); const eV3DSelectObjectFilter select_filter = ED_view3d_select_filter_from_mode(vc->scene, vc->obact); const int hits = view3d_opengl_select( - vc, vbuffer, 4 * (totobj + MAXPICKELEMS), rect, VIEW3D_SELECT_ALL, select_filter); + vc, buffer, (totobj + MAXPICKELEMS), rect, VIEW3D_SELECT_ALL, select_filter); LISTBASE_FOREACH (Base *, base, &vc->view_layer->object_bases) { base->object->id.tag &= ~LIB_TAG_DOIT; @@ -3435,12 +3450,13 @@ static bool do_object_box_select(bContext *C, ViewContext *vc, rcti *rect, const } /* The draw order doesn't always match the order we populate the engine, see: T51695. */ - qsort(vbuffer, hits, sizeof(uint[4]), opengl_bone_select_buffer_cmp); + qsort(buffer, hits, sizeof(GPUSelectResult), opengl_bone_select_buffer_cmp); - for (const uint *col = vbuffer + 3, *col_end = col + (hits * 4); col < col_end; col += 4) { + for (const GPUSelectResult *buf_iter = buffer, *buf_end = buf_iter + hits; buf_iter < buf_end; + buf_iter++) { bPoseChannel *pchan_dummy; Base *base = ED_armature_base_and_pchan_from_select_buffer( - bases, BLI_array_len(bases), *col, &pchan_dummy); + bases, BLI_array_len(bases), buf_iter->id, &pchan_dummy); if (base != NULL) { base->object->id.tag |= LIB_TAG_DOIT; } @@ -3463,7 +3479,7 @@ finally: MEM_freeN(bases); } - MEM_freeN(vbuffer); + MEM_freeN(buffer); if (changed) { DEG_id_tag_update(&vc->scene->id, ID_RECALC_SELECT); @@ -3477,14 +3493,15 @@ static bool do_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, const e uint bases_len; Base **bases = do_pose_tag_select_op_prepare(vc, &bases_len); - int totobj = MAXPICKBUF; /* XXX solve later */ + int totobj = MAXPICKELEMS; /* XXX solve later */ - /* selection buffer now has bones potentially too, so we add MAXPICKBUF */ - uint *vbuffer = MEM_mallocN((totobj + MAXPICKELEMS) * sizeof(uint[4]), "selection buffer"); + /* Selection buffer has bones potentially too, so add #MAXPICKELEMS. */ + GPUSelectResult *buffer = MEM_mallocN((totobj + MAXPICKELEMS) * sizeof(GPUSelectResult), + "selection buffer"); const eV3DSelectObjectFilter select_filter = ED_view3d_select_filter_from_mode(vc->scene, vc->obact); const int hits = view3d_opengl_select( - vc, vbuffer, 4 * (totobj + MAXPICKELEMS), rect, VIEW3D_SELECT_ALL, select_filter); + vc, buffer, (totobj + MAXPICKELEMS), rect, VIEW3D_SELECT_ALL, select_filter); /* * LOGIC NOTES (theeth): * The buffer and ListBase have the same relative order, which makes the selection @@ -3498,18 +3515,20 @@ static bool do_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, const e /* no need to loop if there's no hit */ /* The draw order doesn't always match the order we populate the engine, see: T51695. */ - qsort(vbuffer, hits, sizeof(uint[4]), opengl_bone_select_buffer_cmp); + qsort(buffer, hits, sizeof(GPUSelectResult), opengl_bone_select_buffer_cmp); - for (const uint *col = vbuffer + 3, *col_end = col + (hits * 4); col < col_end; col += 4) { + for (const GPUSelectResult *buf_iter = buffer, *buf_end = buf_iter + hits; buf_iter < buf_end; + buf_iter++) { Bone *bone; - Base *base = ED_armature_base_and_bone_from_select_buffer(bases, bases_len, *col, &bone); + Base *base = ED_armature_base_and_bone_from_select_buffer( + bases, bases_len, buf_iter->id, &bone); if (base == NULL) { continue; } /* Loop over contiguous bone hits for 'base'. */ - for (; col != col_end; col += 4) { + for (; buf_iter != buf_end; buf_iter++) { /* should never fail */ if (bone != NULL) { base->object->id.tag |= LIB_TAG_DOIT; @@ -3517,12 +3536,13 @@ static bool do_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, const e } /* Select the next bone if we're not switching bases. */ - if (col + 4 != col_end) { - if ((base->object->runtime.select_id & 0x0000FFFF) != (col[4] & 0x0000FFFF)) { + if (buf_iter + 1 != buf_end) { + const GPUSelectResult *col_next = buf_iter + 1; + if ((base->object->runtime.select_id & 0x0000FFFF) != (col_next->id & 0x0000FFFF)) { break; } if (base->object->pose != NULL) { - const uint hit_bone = (col[4] & ~BONESEL_ANY) >> 16; + const uint hit_bone = (col_next->id & ~BONESEL_ANY) >> 16; bPoseChannel *pchan = BLI_findlink(&base->object->pose->chanbase, hit_bone); bone = pchan ? pchan->bone : NULL; } @@ -3543,7 +3563,7 @@ static bool do_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, const e if (bases != NULL) { MEM_freeN(bases); } - MEM_freeN(vbuffer); + MEM_freeN(buffer); return changed_multi; } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 165f931394d..9a2cc76c44e 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -863,10 +863,10 @@ void view3d_opengl_select_cache_end(void) struct DrawSelectLoopUserData { uint pass; uint hits; - uint *buffer; + GPUSelectResult *buffer; uint buffer_len; const rcti *rect; - char gpu_select_mode; + eGPUSelectMode gpu_select_mode; }; static bool drw_select_loop_pass(eDRWSelectStage stage, void *user_data) @@ -927,8 +927,8 @@ static bool drw_select_filter_object_mode_lock_for_weight_paint(Object *ob, void } int view3d_opengl_select_ex(ViewContext *vc, - uint *buffer, - uint bufsize, + GPUSelectResult *buffer, + uint buffer_len, const rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter, @@ -950,7 +950,7 @@ int view3d_opengl_select_ex(ViewContext *vc, const bool use_nearest = (is_pick_select && select_mode == VIEW3D_SELECT_PICK_NEAREST); bool draw_surface = true; - char gpu_select_mode; + eGPUSelectMode gpu_select_mode; /* case not a box select */ if (input->xmin == input->xmax) { @@ -1043,7 +1043,7 @@ int view3d_opengl_select_ex(ViewContext *vc, /* Re-use cache (rect must be smaller than the cached) * other context is assumed to be unchanged */ if (GPU_select_is_cached()) { - GPU_select_begin(buffer, bufsize, &rect, gpu_select_mode, 0); + GPU_select_begin(buffer, buffer_len, &rect, gpu_select_mode, 0); GPU_select_cache_load_id(); hits = GPU_select_end(); goto finally; @@ -1071,7 +1071,7 @@ int view3d_opengl_select_ex(ViewContext *vc, .pass = 0, .hits = 0, .buffer = buffer, - .buffer_len = bufsize, + .buffer_len = buffer_len, .rect = &rect, .gpu_select_mode = gpu_select_mode, }; @@ -1101,7 +1101,7 @@ int view3d_opengl_select_ex(ViewContext *vc, .pass = 0, .hits = 0, .buffer = buffer, - .buffer_len = bufsize, + .buffer_len = buffer_len, .rect = &rect, .gpu_select_mode = gpu_select_mode, }; @@ -1144,24 +1144,24 @@ finally: } int view3d_opengl_select(ViewContext *vc, - uint *buffer, - uint bufsize, + GPUSelectResult *buffer, + uint buffer_len, const rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter) { - return view3d_opengl_select_ex(vc, buffer, bufsize, input, select_mode, select_filter, false); + return view3d_opengl_select_ex(vc, buffer, buffer_len, input, select_mode, select_filter, false); } int view3d_opengl_select_with_id_filter(ViewContext *vc, - uint *buffer, - uint bufsize, + GPUSelectResult *buffer, + const uint buffer_len, const rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter, uint select_id) { - int hits = view3d_opengl_select(vc, buffer, bufsize, input, select_mode, select_filter); + int hits = view3d_opengl_select(vc, buffer, buffer_len, input, select_mode, select_filter); /* Selection sometimes uses -1 for an invalid selection ID, remove these as they * interfere with detection of actual number of hits in the selection. */ diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt index 64a720322c1..09c53d7196c 100644 --- a/source/blender/editors/transform/CMakeLists.txt +++ b/source/blender/editors/transform/CMakeLists.txt @@ -125,9 +125,5 @@ set(LIB bf_gpu ) -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - blender_add_lib(bf_editor_transform "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/undo/CMakeLists.txt b/source/blender/editors/undo/CMakeLists.txt index 0f4152c9128..6f659e383fe 100644 --- a/source/blender/editors/undo/CMakeLists.txt +++ b/source/blender/editors/undo/CMakeLists.txt @@ -46,8 +46,4 @@ set(LIB bf_editor_physics ) -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - blender_add_lib(bf_editor_undo "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt index 90a09c87cc6..66cda0fc3f8 100644 --- a/source/blender/editors/util/CMakeLists.txt +++ b/source/blender/editors/util/CMakeLists.txt @@ -115,10 +115,6 @@ set(LIB ) -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) list(APPEND INC diff --git a/source/blender/editors/uvedit/CMakeLists.txt b/source/blender/editors/uvedit/CMakeLists.txt index 1c8a56e0608..a3b29f29354 100644 --- a/source/blender/editors/uvedit/CMakeLists.txt +++ b/source/blender/editors/uvedit/CMakeLists.txt @@ -52,9 +52,5 @@ set(LIB bf_bmesh ) -if(WITH_INTERNATIONAL) - add_definitions(-DWITH_INTERNATIONAL) -endif() - blender_add_lib(bf_editor_uvedit "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") |