Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: source/blender/editors/include/ED_transform.h
- ===================================================================
- --- source/blender/editors/include/ED_transform.h (revision 56109)
- +++ source/blender/editors/include/ED_transform.h (working copy)
- @@ -174,7 +174,8 @@
- typedef enum SnapMode {
- SNAP_ALL = 0,
- SNAP_NOT_SELECTED = 1,
- - SNAP_NOT_OBEDIT = 2
- + SNAP_NOT_OBEDIT = 2,
- + SNAP_ONLY_SELECTED = 3
- } SnapMode;
- #define SNAP_MIN_DISTANCE 30
- Index: source/blender/editors/space_view3d/view3d_ruler.c
- ===================================================================
- --- source/blender/editors/space_view3d/view3d_ruler.c (revision 56109)
- +++ source/blender/editors/space_view3d/view3d_ruler.c (working copy)
- @@ -61,7 +61,7 @@
- #include "ED_transform.h"
- static bool ED_view3d_snap_co(bContext *C, float r_co[3], const float co_ss[2], float r_no[3],
- - bool use_vert, bool use_edge, bool use_face)
- + bool snap_to_selected, bool use_vert, bool use_edge, bool use_face)
- {
- float dist_px = 12; /* snap dist */
- float r_no_dummy[3];
- @@ -72,19 +72,21 @@
- View3D *v3d = CTX_wm_view3d(C);
- ARegion *ar = CTX_wm_region(C);
- struct Object *obedit = CTX_data_edit_object(C);
- +
- + SnapMode snap_mode = snap_to_selected ? SNAP_ONLY_SELECTED : SNAP_ALL;
- /* try snap edge, then face if it fails */
- if (use_vert) {
- ret = snapObjectsEx(scene, NULL, v3d, ar, obedit, SCE_SNAP_MODE_VERTEX,
- - co_ss, &dist_px, r_co, r_no_ptr, SNAP_ALL);
- + co_ss, &dist_px, r_co, r_no_ptr, snap_mode);
- }
- if (use_edge && (ret == false)) {
- ret = snapObjectsEx(scene, NULL, v3d, ar, obedit, SCE_SNAP_MODE_EDGE,
- - co_ss, &dist_px, r_co, r_no_ptr, SNAP_ALL);
- + co_ss, &dist_px, r_co, r_no_ptr, snap_mode);
- }
- if (use_face && (ret == false)) {
- ret = snapObjectsEx(scene, NULL, v3d, ar, obedit, SCE_SNAP_MODE_FACE,
- - co_ss, &dist_px, r_co, r_no_ptr, SNAP_ALL);
- + co_ss, &dist_px, r_co, r_no_ptr, snap_mode);
- }
- return ret;
- @@ -156,6 +158,7 @@
- int flag;
- int snap_flag;
- int state;
- + int snap_to_selected;
- /* --- */
- ARegion *ar;
- @@ -685,7 +688,7 @@
- co_other = ruler_item->co[ruler_item->co_index == 0 ? 2 : 0];
- if (ED_view3d_snap_co(C, co, mval_fl, ray_normal,
- - false, false, true))
- + ruler_info->snap_to_selected, false, false, true))
- {
- negate_v3(ray_normal);
- /* add some bias */
- @@ -697,7 +700,7 @@
- else if (do_snap) {
- const float mval_fl[2] = {UNPACK2(mval)};
- ED_view3d_snap_co(C, co, mval_fl, NULL,
- - true, true, true);
- + ruler_info->snap_to_selected, true, true, true);
- }
- return true;
- }
- @@ -706,16 +709,23 @@
- }
- }
- -static void view3d_ruler_header_update(ScrArea *sa)
- +static void view3d_ruler_header_update(ScrArea *sa, RulerInfo *ruler_info)
- {
- - const char *text = "Ctrl+LMB: Add, "
- - "Del: Remove, "
- - "Ctrl+Drag: Snap, "
- - "Shift+Drag: Thickness, "
- - "Ctrl+C: Copy Value, "
- - "Enter: Store, "
- - "Esc: Cancel";
- + char text[1024];
- + const char *snap_mode_str = ruler_info->snap_to_selected ? "To-Selected" : "To-All";
- + const char *template =
- + "Ctrl+LMB: Add, "
- + "Del: Remove, "
- + "Ctrl+Drag: Snap, "
- + "Shift+Drag: Thickness, "
- + "Ctrl+C: Copy Value, "
- + "Enter: Store, "
- + "Esc: Cancel, "
- + "Ctrl+S: Toggle snap mode, "
- + "SnapMode: %s";
- + sprintf(text, template, snap_mode_str);
- +
- ED_area_headerprint(sa, text);
- }
- @@ -741,7 +751,7 @@
- ruler_info->draw_handle_pixel = ED_region_draw_cb_activate(ar->type, ruler_info_draw_pixel,
- ruler_info, REGION_DRAW_POST_PIXEL);
- - view3d_ruler_header_update(sa);
- + view3d_ruler_header_update(sa, ruler_info);
- WM_cursor_modal(win, BC_CROSSCURSOR);
- WM_event_add_modal_handler(C, op);
- @@ -866,6 +876,15 @@
- }
- }
- break;
- + case SKEY:
- + {
- + if (event->ctrl && event->val == KM_RELEASE) {
- + ruler_info->snap_to_selected = !ruler_info->snap_to_selected;
- + fprintf(stderr, "toggling snap_to_selected\n");
- + do_draw = true;
- + }
- + break;
- + }
- case CKEY:
- {
- if (event->ctrl) {
- @@ -880,6 +899,7 @@
- WM_clipboard_text_set((void *) numstr, false);
- }
- }
- + break;
- }
- case RIGHTCTRLKEY:
- case LEFTCTRLKEY:
- @@ -934,7 +954,7 @@
- if (do_draw) {
- ScrArea *sa = CTX_wm_area(C);
- - view3d_ruler_header_update(sa);
- + view3d_ruler_header_update(sa, ruler_info);
- /* all 3d views draw rulers */
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
- Index: source/blender/editors/transform/transform_snap.c
- ===================================================================
- --- source/blender/editors/transform/transform_snap.c (revision 56109)
- +++ source/blender/editors/transform/transform_snap.c (working copy)
- @@ -1577,6 +1577,7 @@
- (base->flag & (BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA)) == 0 &&
- ((mode == SNAP_NOT_SELECTED && (base->flag & (SELECT | BA_WAS_SEL)) == 0) ||
- + (mode == SNAP_ONLY_SELECTED && (base->flag & (SELECT | BA_WAS_SEL)) == 1) ||
- (ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT) && base != base_act)))
- {
- Object *ob = base->object;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement