diff options
author | Rohan Rathi <rohanrathi08@gmail.com> | 2018-07-21 16:59:15 +0300 |
---|---|---|
committer | Rohan Rathi <rohanrathi08@gmail.com> | 2018-07-21 16:59:15 +0300 |
commit | 4e6bcd10e559ab541df53a3d7b645faac1a7fe27 (patch) | |
tree | ba214c23868fe76ec5d2199b83846814bf79be25 /source/blender/editors/transform | |
parent | b6b185691f018f6b175ffb58c65418991cda75f2 (diff) | |
parent | e361e9e99c5b6140b6284e81fa315bdcc48cee58 (diff) |
Merge branch 'blender2.8' into soc-2018-bevel
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r-- | source/blender/editors/transform/CMakeLists.txt | 4 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 288 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 18 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_constraints.c | 14 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 6 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_generics.c | 20 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_gizmo_2d.c (renamed from source/blender/editors/transform/transform_manipulator_2d.c) | 156 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_gizmo_3d.c (renamed from source/blender/editors/transform/transform_manipulator_3d.c) | 409 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_ops.c | 8 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 20 |
10 files changed, 506 insertions, 437 deletions
diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt index 3e132192875..45055eb1225 100644 --- a/source/blender/editors/transform/CMakeLists.txt +++ b/source/blender/editors/transform/CMakeLists.txt @@ -46,8 +46,8 @@ set(SRC transform_conversions.c transform_generics.c transform_input.c - transform_manipulator_2d.c - transform_manipulator_3d.c + transform_gizmo_2d.c + transform_gizmo_3d.c transform_ops.c transform_orientations.c transform_snap.c diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 9a52127b201..28c59ea387f 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -820,25 +820,100 @@ enum { TFM_MODAL_INSERTOFS_TOGGLE_DIR = 27, }; +static bool transform_modal_item_poll(const wmOperator *op, int value) +{ + const TransInfo *t = op->customdata; + switch (value) { + case TFM_MODAL_PROPSIZE: + case TFM_MODAL_PROPSIZE_UP: + case TFM_MODAL_PROPSIZE_DOWN: + { + if ((t->flag & T_PROP_EDIT) == 0) { + return false; + } + break; + } + case TFM_MODAL_ADD_SNAP: + case TFM_MODAL_REMOVE_SNAP: + { + if (t->spacetype != SPACE_VIEW3D) { + return false; + } + else if (t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)) { + return false; + } + else if (!validSnap(t)) { + return false; + } + break; + } + case TFM_MODAL_AXIS_X: + case TFM_MODAL_AXIS_Y: + case TFM_MODAL_AXIS_Z: + case TFM_MODAL_PLANE_X: + case TFM_MODAL_PLANE_Y: + case TFM_MODAL_PLANE_Z: + { + if (t->flag & T_NO_CONSTRAINT) { + return false; + } + if (!ELEM(value, TFM_MODAL_AXIS_X, TFM_MODAL_AXIS_Y)) { + if (t->flag & T_2D_EDIT) { + return false; + } + } + break; + } + case TFM_MODAL_CONS_OFF: + { + if ((t->con.mode & CON_APPLY) == 0) { + return false; + } + break; + } + case TFM_MODAL_EDGESLIDE_UP: + case TFM_MODAL_EDGESLIDE_DOWN: + { + if (t->mode != TFM_EDGE_SLIDE) { + return false; + } + break; + } + case TFM_MODAL_INSERTOFS_TOGGLE_DIR: + { + if (t->spacetype != SPACE_NODE) { + return false; + } + break; + } + case TFM_MODAL_AUTOIK_LEN_INC: + case TFM_MODAL_AUTOIK_LEN_DEC: + { + if ((t->flag & T_AUTOIK) == 0) { + return false; + } + break; + } + } + return true; +} + /* called in transform_ops.c, on each regeneration of keymaps */ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) { static const EnumPropertyItem modal_items[] = { - {TFM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, {TFM_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""}, - {TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Translate", ""}, - {TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""}, - {TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""}, - {TFM_MODAL_SNAP_INV_ON, "SNAP_INV_ON", 0, "Invert Snap On", ""}, - {TFM_MODAL_SNAP_INV_OFF, "SNAP_INV_OFF", 0, "Invert Snap Off", ""}, + {TFM_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""}, + {TFM_MODAL_AXIS_X, "AXIS_X", 0, "X axis", ""}, + {TFM_MODAL_AXIS_Y, "AXIS_Y", 0, "Y axis", ""}, + {TFM_MODAL_AXIS_Z, "AXIS_Z", 0, "Z axis", ""}, + {TFM_MODAL_PLANE_X, "PLANE_X", 0, "X plane", ""}, + {TFM_MODAL_PLANE_Y, "PLANE_Y", 0, "Y plane", ""}, + {TFM_MODAL_PLANE_Z, "PLANE_Z", 0, "Z plane", ""}, + {TFM_MODAL_CONS_OFF, "CONS_OFF", 0, "Clear Constraints", ""}, + {TFM_MODAL_SNAP_INV_ON, "SNAP_INV_ON", 0, "Snap Invert", ""}, + {TFM_MODAL_SNAP_INV_OFF, "SNAP_INV_OFF", 0, "Snap Invert (Off)", ""}, {TFM_MODAL_SNAP_TOGGLE, "SNAP_TOGGLE", 0, "Snap Toggle", ""}, - {TFM_MODAL_AXIS_X, "AXIS_X", 0, "Orientation X axis", ""}, - {TFM_MODAL_AXIS_Y, "AXIS_Y", 0, "Orientation Y axis", ""}, - {TFM_MODAL_AXIS_Z, "AXIS_Z", 0, "Orientation Z axis", ""}, - {TFM_MODAL_PLANE_X, "PLANE_X", 0, "Orientation X plane", ""}, - {TFM_MODAL_PLANE_Y, "PLANE_Y", 0, "Orientation Y plane", ""}, - {TFM_MODAL_PLANE_Z, "PLANE_Z", 0, "Orientation Z plane", ""}, - {TFM_MODAL_CONS_OFF, "CONS_OFF", 0, "Remove Constraints", ""}, {TFM_MODAL_ADD_SNAP, "ADD_SNAP", 0, "Add Snap Point", ""}, {TFM_MODAL_REMOVE_SNAP, "REMOVE_SNAP", 0, "Remove Last Snap Point", ""}, {NUM_MODAL_INCREMENT_UP, "INCREMENT_UP", 0, "Numinput Increment Up", ""}, @@ -851,6 +926,9 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) {TFM_MODAL_EDGESLIDE_DOWN, "EDGESLIDE_PREV_NEXT", 0, "Select previous Edge Slide Edge", ""}, {TFM_MODAL_PROPSIZE, "PROPORTIONAL_SIZE", 0, "Adjust Proportional Influence", ""}, {TFM_MODAL_INSERTOFS_TOGGLE_DIR, "INSERTOFS_TOGGLE_DIR", 0, "Toggle Direction for Node Auto-offset", ""}, + {TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Translate", ""}, + {TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""}, + {TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""}, {0, NULL, 0, NULL, NULL} }; @@ -860,12 +938,24 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) if (keymap && keymap->modal_items) return NULL; keymap = WM_modalkeymap_add(keyconf, "Transform Modal Map", modal_items); + keymap->poll_modal_item = transform_modal_item_poll; /* items for modal map */ - WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_CANCEL); - WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM); - WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM); - WM_modalkeymap_add_item(keymap, PADENTER, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM); + WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM); + WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM); + WM_modalkeymap_add_item(keymap, PADENTER, KM_PRESS, KM_ANY, 0, TFM_MODAL_CONFIRM); + WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_PRESS, KM_ANY, 0, TFM_MODAL_CANCEL); + WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_CANCEL); + + WM_modalkeymap_add_item(keymap, XKEY, KM_PRESS, 0, 0, TFM_MODAL_AXIS_X); + WM_modalkeymap_add_item(keymap, YKEY, KM_PRESS, 0, 0, TFM_MODAL_AXIS_Y); + WM_modalkeymap_add_item(keymap, ZKEY, KM_PRESS, 0, 0, TFM_MODAL_AXIS_Z); + + WM_modalkeymap_add_item(keymap, XKEY, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_PLANE_X); + WM_modalkeymap_add_item(keymap, YKEY, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_PLANE_Y); + WM_modalkeymap_add_item(keymap, ZKEY, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_PLANE_Z); + + WM_modalkeymap_add_item(keymap, CKEY, KM_PRESS, 0, 0, TFM_MODAL_CONS_OFF); WM_modalkeymap_add_item(keymap, GKEY, KM_PRESS, 0, 0, TFM_MODAL_TRANSLATE); WM_modalkeymap_add_item(keymap, RKEY, KM_PRESS, 0, 0, TFM_MODAL_ROTATE); @@ -906,7 +996,7 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) return keymap; } -static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cmode) +static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cmode, bool is_plane) { if (!(t->flag & T_NO_CONSTRAINT)) { int constraint_axis, constraint_plane; @@ -959,17 +1049,21 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm else { short orientation = (t->current_orientation != V3D_MANIP_GLOBAL ? t->current_orientation : V3D_MANIP_LOCAL); - if (!(t->modifiers & MOD_CONSTRAINT_PLANE)) + if (is_plane == false) { setUserConstraint(t, orientation, constraint_axis, msg2); - else if (t->modifiers & MOD_CONSTRAINT_PLANE) + } + else { setUserConstraint(t, orientation, constraint_plane, msg3); + } } } else { - if (!(t->modifiers & MOD_CONSTRAINT_PLANE)) + if (is_plane == false) { setUserConstraint(t, V3D_MANIP_GLOBAL, constraint_axis, msg2); - else if (t->modifiers & MOD_CONSTRAINT_PLANE) + } + else { setUserConstraint(t, V3D_MANIP_GLOBAL, constraint_plane, msg3); + } } } t->redraw |= TREDRAW_HARD; @@ -1149,57 +1243,42 @@ int transformEvent(TransInfo *t, const wmEvent *event) break; case TFM_MODAL_AXIS_X: if (!(t->flag & T_NO_CONSTRAINT)) { - transform_event_xyz_constraint(t, XKEY, cmode); + transform_event_xyz_constraint(t, XKEY, cmode, false); t->redraw |= TREDRAW_HARD; handled = true; } break; case TFM_MODAL_AXIS_Y: if ((t->flag & T_NO_CONSTRAINT) == 0) { - transform_event_xyz_constraint(t, YKEY, cmode); + transform_event_xyz_constraint(t, YKEY, cmode, false); t->redraw |= TREDRAW_HARD; handled = true; } break; case TFM_MODAL_AXIS_Z: if ((t->flag & (T_NO_CONSTRAINT)) == 0) { - transform_event_xyz_constraint(t, ZKEY, cmode); + transform_event_xyz_constraint(t, ZKEY, cmode, false); t->redraw |= TREDRAW_HARD; handled = true; } break; case TFM_MODAL_PLANE_X: if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) { - if (cmode == 'X') { - stopConstraint(t); - } - else { - setUserConstraint(t, t->current_orientation, (CON_AXIS1 | CON_AXIS2), IFACE_("locking %s X")); - } + transform_event_xyz_constraint(t, XKEY, cmode, true); t->redraw |= TREDRAW_HARD; handled = true; } break; case TFM_MODAL_PLANE_Y: if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) { - if (cmode == 'Y') { - stopConstraint(t); - } - else { - setUserConstraint(t, t->current_orientation, (CON_AXIS0 | CON_AXIS2), IFACE_("locking %s Y")); - } + transform_event_xyz_constraint(t, YKEY, cmode, true); t->redraw |= TREDRAW_HARD; handled = true; } break; case TFM_MODAL_PLANE_Z: if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) { - if (cmode == 'Z') { - stopConstraint(t); - } - else { - setUserConstraint(t, t->current_orientation, (CON_AXIS0 | CON_AXIS1), IFACE_("locking %s Z")); - } + transform_event_xyz_constraint(t, ZKEY, cmode, true); t->redraw |= TREDRAW_HARD; handled = true; } @@ -1417,21 +1496,6 @@ int transformEvent(TransInfo *t, const wmEvent *event) handled = true; } } - else { - if (!(t->flag & T_NO_CONSTRAINT)) { - stopConstraint(t); - t->redraw |= TREDRAW_HARD; - handled = true; - } - } - break; - case XKEY: - case YKEY: - case ZKEY: - if (!(t->flag & T_NO_CONSTRAINT)) { - transform_event_xyz_constraint(t, event->type, cmode); - handled = true; - } break; case OKEY: if (t->flag & T_PROP_EDIT && event->shift) { @@ -1570,6 +1634,12 @@ int transformEvent(TransInfo *t, const wmEvent *event) handled = true; } + if (t->redraw && + !ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) + { + WM_window_status_area_tag_redraw(CTX_wm_window(t->context)); + } + if (handled || t->redraw) { return 0; } @@ -1638,13 +1708,13 @@ typedef enum { } ArrowDirection; #define POS_INDEX 0 -/* NOTE: this --^ is a bit hackish, but simplifies Gwn_VertFormat usage among functions +/* NOTE: this --^ is a bit hackish, but simplifies GPUVertFormat usage among functions * private to this file - merwin */ static void drawArrow(ArrowDirection d, short offset, short length, short size) { - immBegin(GWN_PRIM_LINES, 6); + immBegin(GPU_PRIM_LINES, 6); switch (d) { case LEFT: @@ -1681,7 +1751,7 @@ static void drawArrow(ArrowDirection d, short offset, short length, short size) static void drawArrowHead(ArrowDirection d, short size) { - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); switch (d) { case LEFT: @@ -1714,7 +1784,7 @@ static void drawArc(float size, float angle_start, float angle_end, int segments float angle; int a; - immBegin(GWN_PRIM_LINE_STRIP, segments + 1); + immBegin(GPU_PRIM_LINE_STRIP, segments + 1); for (angle = angle_start, a = 0; a < segments; angle += delta, a++) { immVertex2f(POS_INDEX, cosf(angle) * size, sinf(angle) * size); @@ -1762,11 +1832,11 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) tmval[i] += offset[i]; } - gpuPushMatrix(); + GPU_matrix_push(); /* Dashed lines first. */ if (ELEM(t->helpline, HLP_SPRING, HLP_ANGLE)) { - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); UNUSED_VARS_NDEBUG(shdr_pos); /* silence warning */ BLI_assert(shdr_pos == POS_INDEX); @@ -1784,7 +1854,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) immUniform1f("dash_width", 6.0f); immUniform1f("dash_factor", 0.5f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(POS_INDEX, cent); immVertex2f(POS_INDEX, tmval[0], tmval[1]); immEnd(); @@ -1793,7 +1863,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) } /* And now, solid lines. */ - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); UNUSED_VARS_NDEBUG(pos); /* silence warning */ BLI_assert(pos == POS_INDEX); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1802,8 +1872,8 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) case HLP_SPRING: immUniformThemeColor(TH_VIEW_OVERLAY); - gpuTranslate3fv(mval); - gpuRotateAxis(-RAD2DEGF(atan2f(cent[0] - tmval[0], cent[1] - tmval[1])), 'Z'); + GPU_matrix_translate_3fv(mval); + GPU_matrix_rotate_axis(-RAD2DEGF(atan2f(cent[0] - tmval[0], cent[1] - tmval[1])), 'Z'); GPU_line_width(3.0f); drawArrow(UP, 5, 10, 5); @@ -1811,7 +1881,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) break; case HLP_HARROW: immUniformThemeColor(TH_VIEW_OVERLAY); - gpuTranslate3fv(mval); + GPU_matrix_translate_3fv(mval); GPU_line_width(3.0f); drawArrow(RIGHT, 5, 10, 5); @@ -1820,7 +1890,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) case HLP_VARROW: immUniformThemeColor(TH_VIEW_OVERLAY); - gpuTranslate3fv(mval); + GPU_matrix_translate_3fv(mval); GPU_line_width(3.0f); drawArrow(UP, 5, 10, 5); @@ -1836,23 +1906,23 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) immUniformThemeColor(TH_VIEW_OVERLAY); - gpuTranslate3f(cent[0] - tmval[0] + mval[0], cent[1] - tmval[1] + mval[1], 0); + GPU_matrix_translate_3f(cent[0] - tmval[0] + mval[0], cent[1] - tmval[1] + mval[1], 0); GPU_line_width(3.0f); drawArc(dist, angle - delta_angle, angle - spacing_angle, 10); drawArc(dist, angle + spacing_angle, angle + delta_angle, 10); - gpuPushMatrix(); + GPU_matrix_push(); - gpuTranslate3f(cosf(angle - delta_angle) * dist, sinf(angle - delta_angle) * dist, 0); - gpuRotateAxis(RAD2DEGF(angle - delta_angle), 'Z'); + GPU_matrix_translate_3f(cosf(angle - delta_angle) * dist, sinf(angle - delta_angle) * dist, 0); + GPU_matrix_rotate_axis(RAD2DEGF(angle - delta_angle), 'Z'); drawArrowHead(DOWN, 5); - gpuPopMatrix(); + GPU_matrix_pop(); - gpuTranslate3f(cosf(angle + delta_angle) * dist, sinf(angle + delta_angle) * dist, 0); - gpuRotateAxis(RAD2DEGF(angle + delta_angle), 'Z'); + GPU_matrix_translate_3f(cosf(angle + delta_angle) * dist, sinf(angle + delta_angle) * dist, 0); + GPU_matrix_rotate_axis(RAD2DEGF(angle + delta_angle), 'Z'); drawArrowHead(UP, 5); break; @@ -1862,7 +1932,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) unsigned char col[3], col2[3]; UI_GetThemeColor3ubv(TH_GRID, col); - gpuTranslate3fv(mval); + GPU_matrix_translate_3fv(mval); GPU_line_width(3.0f); @@ -1882,7 +1952,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) } immUnbindProgram(); - gpuPopMatrix(); + GPU_matrix_pop(); } } @@ -2164,7 +2234,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->launch_event = event ? WM_userdef_event_type_from_keymap_type(event->type) : -1; // XXX Remove this when wm_operator_call_internal doesn't use window->eventstate (which can have type = 0) - // For manipulator only, so assume LEFTMOUSE + // For gizmo only, so assume LEFTMOUSE if (t->launch_event == 0) { t->launch_event = LEFTMOUSE; } @@ -2216,10 +2286,10 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve /* keymap for shortcut header prints */ t->keymap = WM_keymap_active(CTX_wm_manager(C), op->type->modalkeymap); - /* Stupid code to have Ctrl-Click on manipulator work ok + /* Stupid code to have Ctrl-Click on gizmo work ok * * do this only for translation/rotation/resize due to only this - * moded are available from manipulator and doing such check could + * moded are available from gizmo and doing such check could * lead to keymap conflicts for other modes (see #31584) */ if (ELEM(mode, TFM_TRANSLATION, TFM_ROTATION, TFM_RESIZE)) { @@ -3581,7 +3651,7 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2])) t->con.applySize(t, NULL, NULL, mat); } - copy_m3_m3(t->mat, mat); // used in manipulator + copy_m3_m3(t->mat, mat); // used in gizmo headerResize(t, t->values, str); @@ -4301,7 +4371,7 @@ static void applyTrackball(TransInfo *t, const int UNUSED(mval[2])) mul_m3_m3m3(mat, smat, totmat); // TRANSFORM_FIX_ME - //copy_m3_m3(t->mat, mat); // used in manipulator + //copy_m3_m3(t->mat, mat); // used in gizmo #endif applyTrackballValue(t, axis1, axis2, phi); @@ -5573,7 +5643,7 @@ static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2])) t->con.applySize(t, NULL, NULL, mat); } - copy_m3_m3(t->mat, mat); // used in manipulator + copy_m3_m3(t->mat, mat); // used in gizmo headerBoneSize(t, size, str); @@ -6774,7 +6844,7 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, TransDataContainer *t if (t->spacetype == SPACE_VIEW3D) { v3d = t->sa ? t->sa->spacedata.first : NULL; rv3d = t->ar ? t->ar->regiondata : NULL; - use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE && v3d->drawtype > OB_WIRE); + use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE && v3d->shading.type > OB_WIRE); } calcEdgeSlide_mval_range(t, tc, sld, sv_table, loop_nr, mval, use_occlude_geometry, true); @@ -6969,7 +7039,7 @@ static bool createEdgeSlideVerts_single_side(TransInfo *t, TransDataContainer *t if (t->spacetype == SPACE_VIEW3D) { v3d = t->sa ? t->sa->spacedata.first : NULL; rv3d = t->ar ? t->ar->regiondata : NULL; - use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE && v3d->drawtype > OB_WIRE); + use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE && v3d->shading.type > OB_WIRE); } calcEdgeSlide_mval_range(t, tc, sld, sv_table, loop_nr, mval, use_occlude_geometry, false); @@ -7162,19 +7232,17 @@ static void drawEdgeSlide(TransInfo *t) /* Even mode */ if ((slp->use_even == true) || (is_clamp == false)) { - View3D *v3d = t->view; const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f; - if (v3d && v3d->zbuf) - GPU_depth_test(false); + GPU_depth_test(false); GPU_blend(true); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - gpuPushMatrix(); - gpuMultMatrix(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); + GPU_matrix_push(); + GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); @@ -7191,7 +7259,7 @@ static void drawEdgeSlide(TransInfo *t) GPU_line_width(line_size); immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); - immBeginAtMost(GWN_PRIM_LINES, 4); + immBeginAtMost(GPU_PRIM_LINES, 4); if (curr_sv->v_side[0]) { immVertex3fv(pos, curr_sv->v_side[0]->co); immVertex3fv(pos, curr_sv->v_co_orig); @@ -7204,7 +7272,7 @@ static void drawEdgeSlide(TransInfo *t) immUniformThemeColorShadeAlpha(TH_SELECT, -30, alpha_shade); GPU_point_size(ctrl_size); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); if (slp->flipped) { if (curr_sv->v_side[1]) immVertex3fv(pos, curr_sv->v_side[1]->co); } @@ -7215,7 +7283,7 @@ static void drawEdgeSlide(TransInfo *t) immUniformThemeColorShadeAlpha(TH_SELECT, 255, alpha_shade); GPU_point_size(guide_size); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); interp_line_v3_v3v3v3(co_mark, co_b, curr_sv->v_co_orig, co_a, fac); immVertex3fv(pos, co_mark); immEnd(); @@ -7229,7 +7297,7 @@ static void drawEdgeSlide(TransInfo *t) GPU_line_width(line_size); immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); - immBegin(GWN_PRIM_LINES, sld->totsv * 2); + immBegin(GPU_PRIM_LINES, sld->totsv * 2); /* TODO(campbell): Loop over all verts */ sv = sld->sv; @@ -7260,12 +7328,11 @@ static void drawEdgeSlide(TransInfo *t) immUnbindProgram(); - gpuPopMatrix(); + GPU_matrix_pop(); GPU_blend(false); - if (v3d && v3d->zbuf) - GPU_depth_test(true); + GPU_depth_test(true); } } } @@ -7793,7 +7860,6 @@ static void drawVertSlide(TransInfo *t) /* Non-Prop mode */ { - View3D *v3d = t->view; TransDataVertSlideVert *curr_sv = &sld->sv[sld->curr_sv_index]; TransDataVertSlideVert *sv; const float ctrl_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5f; @@ -7801,23 +7867,22 @@ static void drawVertSlide(TransInfo *t) const int alpha_shade = -160; int i; - if (v3d && v3d->zbuf) - GPU_depth_test(false); + GPU_depth_test(false); GPU_blend(true); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - gpuPushMatrix(); - gpuMultMatrix(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); + GPU_matrix_push(); + GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); GPU_line_width(line_size); - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); - immBegin(GWN_PRIM_LINES, sld->totsv * 2); + immBegin(GPU_PRIM_LINES, sld->totsv * 2); if (is_clamp) { sv = sld->sv; for (i = 0; i < sld->totsv; i++, sv++) { @@ -7843,7 +7908,7 @@ static void drawVertSlide(TransInfo *t) GPU_point_size(ctrl_size); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex3fv(shdr_pos, (slp->flipped && slp->use_even) ? curr_sv->co_link_orig_3d[curr_sv->co_link_curr] : curr_sv->co_orig_3d); @@ -7886,7 +7951,7 @@ static void drawVertSlide(TransInfo *t) immUniform1f("dash_width", 6.0f); immUniform1f("dash_factor", 0.5f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex3fv(shdr_pos, curr_sv->co_orig_3d); immVertex3fv(shdr_pos, co_dest_3d); immEnd(); @@ -7894,10 +7959,9 @@ static void drawVertSlide(TransInfo *t) immUnbindProgram(); } - gpuPopMatrix(); + GPU_matrix_pop(); - if (v3d && v3d->zbuf) - GPU_depth_test(true); + GPU_depth_test(true); } } } diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index b9fbb37722c..dfcd3e4cfd6 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -491,7 +491,7 @@ typedef struct TransInfo { short persp; short around; char spacetype; /* spacetype where transforming is */ - char helpline; /* Choice of custom cursor with or without a help line from the manipulator to the mouse position. */ + char helpline; /* Choice of custom cursor with or without a help line from the gizmo to the mouse position. */ short obedit_type; /* Avoid looking inside TransDataContainer obedit. */ float vec[3]; /* translation, to show for widget */ @@ -505,7 +505,7 @@ typedef struct TransInfo { short current_orientation; TransformOrientation *custom_orientation; /* this gets used when current_orientation is V3D_MANIP_CUSTOM */ - short twflag; /* backup from view3d, to restore on end */ + short gizmo_flag; /* backup from view3d, to restore on end */ short prop_mode; @@ -712,9 +712,9 @@ void flushTransMasking(TransInfo *t); void flushTransPaintCurve(TransInfo *t); void restoreBones(TransDataContainer *tc); -/*********************** transform_manipulator.c ********** */ +/*********************** transform_gizmo.c ********** */ -#define MANIPULATOR_AXIS_LINE_WIDTH 2.0f +#define GIZMO_AXIS_LINE_WIDTH 2.0f /* return 0 when no gimbal for selection */ bool gimbal_axis(struct Object *ob, float gmat[3][3]); @@ -774,8 +774,8 @@ void snapGridIncrementAction(TransInfo *t, float *val, GearsType action); void snapSequenceBounds(TransInfo *t, const int mval[2]); -bool activeSnap(TransInfo *t); -bool validSnap(TransInfo *t); +bool activeSnap(const TransInfo *t); +bool validSnap(const TransInfo *t); void initSnapping(struct TransInfo *t, struct wmOperator *op); void freeSnapping(struct TransInfo *t); @@ -785,10 +785,10 @@ void applySnapping(TransInfo *t, float *vec); void resetSnapping(TransInfo *t); eRedrawFlag handleSnapping(TransInfo *t, const struct wmEvent *event); void drawSnapping(const struct bContext *C, TransInfo *t); -bool usingSnappingNormal(TransInfo *t); -bool validSnappingNormal(TransInfo *t); +bool usingSnappingNormal(const TransInfo *t); +bool validSnappingNormal(const TransInfo *t); -void getSnapPoint(TransInfo *t, float vec[3]); +void getSnapPoint(const TransInfo *t, float vec[3]); void addSnapPoint(TransInfo *t); eRedrawFlag updateSelectedSnapPoint(TransInfo *t); void removeSnapPoint(TransInfo *t); diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 9df8264cc76..c8f74cbcd4f 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -747,7 +747,7 @@ void drawConstraint(TransInfo *t) if (depth_test_enabled) GPU_depth_test(false); - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR); @@ -760,7 +760,7 @@ void drawConstraint(TransInfo *t) immUniform1f("dash_width", 2.0f); immUniform1f("dash_factor", 0.5f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex3fv(shdr_pos, t->center_global); immVertex3fv(shdr_pos, vec); immEnd(); @@ -800,13 +800,13 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) unit_m4(imat); } - gpuPushMatrix(); + GPU_matrix_push(); if (t->spacetype == SPACE_VIEW3D) { /* pass */ } else if (t->spacetype == SPACE_IMAGE) { - gpuScale2f(1.0f / t->aspect[0], 1.0f / t->aspect[1]); + GPU_matrix_scale_2f(1.0f / t->aspect[0], 1.0f / t->aspect[1]); } else if (ELEM(t->spacetype, SPACE_IPO, SPACE_ACTION)) { /* only scale y */ @@ -816,14 +816,14 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) float ysize = BLI_rctf_size_y(datamask); float xmask = BLI_rcti_size_x(mask); float ymask = BLI_rcti_size_y(mask); - gpuScale2f(1.0f, (ysize / xsize) * (xmask / ymask)); + GPU_matrix_scale_2f(1.0f, (ysize / xsize) * (xmask / ymask)); } depth_test_enabled = GPU_depth_test_enabled(); if (depth_test_enabled) GPU_depth_test(false); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformThemeColor(TH_GRID); @@ -837,7 +837,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) if (depth_test_enabled) GPU_depth_test(true); - gpuPopMatrix(); + GPU_matrix_pop(); } } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index c622a50ff11..a5706f4a003 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5463,10 +5463,6 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c MEM_freeN(custom_data->data); custom_data->data = NULL; } - if (tc->data) { - MEM_freeN(tc->data); // XXX postTrans usually does this - tc->data = NULL; - } } static void createTransSeqData(bContext *C, TransInfo *t) @@ -6688,7 +6684,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) BKE_pose_where_is(t->depsgraph, t->scene, pose_ob); } - /* set BONE_TRANSFORM flags for autokey, manipulator draw might have changed them */ + /* set BONE_TRANSFORM flags for autokey, gizmo draw might have changed them */ if (!canceled && (t->mode != TFM_DUMMY)) { count_set_pose_transflags(ob, t->mode, t->around, NULL); } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index db8bbe05c69..3618d57b3ed 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -463,13 +463,13 @@ static void recalcData_graphedit(TransInfo *t) /* helper for recalcData() - for NLA Editor transforms */ static void recalcData_nla(TransInfo *t) { - TransDataNla *tdn = t->custom.type.data; SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first; Scene *scene = t->scene; double secf = FPS; int i; TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); + TransDataNla *tdn = tc->custom.type.data; /* for each strip we've got, perform some additional validation of the values that got set before * using RNA to set the value (which does some special operations when setting these values to make @@ -1116,7 +1116,7 @@ void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis if (t->spacetype == SPACE_VIEW3D) { View3D *v3d = t->view; - gpuPushMatrix(); + GPU_matrix_push(); copy_v3_v3(v3, dir); mul_v3_fl(v3, v3d->far); @@ -1132,19 +1132,19 @@ void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis } UI_make_axis_color(col, col2, axis); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor3ubv(col2); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex3fv(pos, v1); immVertex3fv(pos, v2); immEnd(); immUnbindProgram(); - gpuPopMatrix(); + GPU_matrix_pop(); } } @@ -1348,10 +1348,10 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->view = v3d; t->animtimer = (animscreen) ? animscreen->animtimer : NULL; - /* turn manipulator off during transform */ + /* turn gizmo off during transform */ if (t->flag & T_MODAL) { - t->twflag = v3d->twflag; - v3d->twflag = 0; + t->gizmo_flag = v3d->gizmo_flag; + v3d->gizmo_flag = V3D_GIZMO_HIDE; } if (t->scene->toolsettings->transform_flag & SCE_XFORM_AXIS_ALIGN) { @@ -1688,9 +1688,9 @@ void postTrans(bContext *C, TransInfo *t) } else if (t->spacetype == SPACE_VIEW3D) { View3D *v3d = t->sa->spacedata.first; - /* restore manipulator */ + /* restore gizmo */ if (t->flag & T_MODAL) { - v3d->twflag = t->twflag; + v3d->gizmo_flag = t->gizmo_flag; } } diff --git a/source/blender/editors/transform/transform_manipulator_2d.c b/source/blender/editors/transform/transform_gizmo_2d.c index fd6e7ed5442..ff69c2859fc 100644 --- a/source/blender/editors/transform/transform_manipulator_2d.c +++ b/source/blender/editors/transform/transform_gizmo_2d.c @@ -18,10 +18,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/transform/transform_manipulator_2d.c +/** \file blender/editors/transform/transform_gizmo_2d.c * \ingroup edtransform * - * \name 2D Transform Manipulator + * \name 2D Transform Gizmo * * Used for UV/Image Editor */ @@ -52,7 +52,7 @@ #include "ED_image.h" #include "ED_screen.h" #include "ED_uvedit.h" -#include "ED_manipulator_library.h" +#include "ED_gizmo_library.h" #include "transform.h" /* own include */ @@ -64,18 +64,18 @@ enum { MAN2D_AXIS_LAST, }; -typedef struct ManipulatorGroup2D { - wmManipulator *translate_x, +typedef struct GizmoGroup2D { + wmGizmo *translate_x, *translate_y; - wmManipulator *cage; + wmGizmo *cage; /* Current origin in view space, used to update widget origin for possible view changes */ float origin[2]; float min[2]; float max[2]; -} ManipulatorGroup2D; +} GizmoGroup2D; /* **************** Utilities **************** */ @@ -83,16 +83,16 @@ typedef struct ManipulatorGroup2D { /* loop over axes */ #define MAN2D_ITER_AXES_BEGIN(axis, axis_idx) \ { \ - wmManipulator *axis; \ + wmGizmo *axis; \ int axis_idx; \ for (axis_idx = 0; axis_idx < MAN2D_AXIS_LAST; axis_idx++) { \ - axis = manipulator2d_get_axis_from_index(man, axis_idx); + axis = gizmo2d_get_axis_from_index(man, axis_idx); #define MAN2D_ITER_AXES_END \ } \ } ((void)0) -static wmManipulator *manipulator2d_get_axis_from_index(const ManipulatorGroup2D *man, const short axis_idx) +static wmGizmo *gizmo2d_get_axis_from_index(const GizmoGroup2D *man, const short axis_idx) { BLI_assert(IN_RANGE_INCL(axis_idx, (float)MAN2D_AXIS_TRANS_X, (float)MAN2D_AXIS_TRANS_Y)); @@ -106,7 +106,7 @@ static wmManipulator *manipulator2d_get_axis_from_index(const ManipulatorGroup2D return NULL; } -static void manipulator2d_get_axis_color(const int axis_idx, float *r_col, float *r_col_hi) +static void gizmo2d_get_axis_color(const int axis_idx, float *r_col, float *r_col_hi) { const float alpha = 0.6f; const float alpha_hi = 1.0f; @@ -128,29 +128,29 @@ static void manipulator2d_get_axis_color(const int axis_idx, float *r_col, float r_col_hi[3] *= alpha_hi; } -static ManipulatorGroup2D *manipulatorgroup2d_init(wmManipulatorGroup *mgroup) +static GizmoGroup2D *gizmogroup2d_init(wmGizmoGroup *gzgroup) { - const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_2d", true); - const wmManipulatorType *wt_cage = WM_manipulatortype_find("MANIPULATOR_WT_cage_2d", true); + const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_2d", true); + const wmGizmoType *gzt_cage = WM_gizmotype_find("GIZMO_GT_cage_2d", true); - ManipulatorGroup2D *man = MEM_callocN(sizeof(ManipulatorGroup2D), __func__); + GizmoGroup2D *man = MEM_callocN(sizeof(GizmoGroup2D), __func__); - man->translate_x = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); - man->translate_y = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); - man->cage = WM_manipulator_new_ptr(wt_cage, mgroup, NULL); + man->translate_x = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL); + man->translate_y = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL); + man->cage = WM_gizmo_new_ptr(gzt_cage, gzgroup, NULL); RNA_enum_set(man->cage->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE | - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE | - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_ROTATE); + ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE | + ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE | + ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE); return man; } /** - * Calculates origin in view space, use with #manipulator2d_origin_to_region. + * Calculates origin in view space, use with #gizmo2d_origin_to_region. */ -static void manipulator2d_calc_bounds(const bContext *C, float *r_center, float *r_min, float *r_max) +static void gizmo2d_calc_bounds(const bContext *C, float *r_center, float *r_min, float *r_max) { SpaceImage *sima = CTX_wm_space_image(C); Image *ima = ED_space_image(sima); @@ -173,56 +173,56 @@ static void manipulator2d_calc_bounds(const bContext *C, float *r_center, float /** * Convert origin (or any other point) from view to region space. */ -BLI_INLINE void manipulator2d_origin_to_region(ARegion *ar, float *r_origin) +BLI_INLINE void gizmo2d_origin_to_region(ARegion *ar, float *r_origin) { UI_view2d_view_to_region_fl(&ar->v2d, r_origin[0], r_origin[1], &r_origin[0], &r_origin[1]); } /** - * Custom handler for manipulator widgets + * Custom handler for gizmo widgets */ -static int manipulator2d_modal( - bContext *C, wmManipulator *widget, const wmEvent *UNUSED(event), - eWM_ManipulatorTweak UNUSED(tweak_flag)) +static int gizmo2d_modal( + bContext *C, wmGizmo *widget, const wmEvent *UNUSED(event), + eWM_GizmoFlagTweak UNUSED(tweak_flag)) { ARegion *ar = CTX_wm_region(C); float origin[3]; - manipulator2d_calc_bounds(C, origin, NULL, NULL); - manipulator2d_origin_to_region(ar, origin); - WM_manipulator_set_matrix_location(widget, origin); + gizmo2d_calc_bounds(C, origin, NULL, NULL); + gizmo2d_origin_to_region(ar, origin); + WM_gizmo_set_matrix_location(widget, origin); ED_region_tag_redraw(ar); return OPERATOR_RUNNING_MODAL; } -void ED_widgetgroup_manipulator2d_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +void ED_widgetgroup_gizmo2d_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { wmOperatorType *ot_translate = WM_operatortype_find("TRANSFORM_OT_translate", true); - ManipulatorGroup2D *man = manipulatorgroup2d_init(mgroup); - mgroup->customdata = man; + GizmoGroup2D *man = gizmogroup2d_init(gzgroup); + gzgroup->customdata = man; MAN2D_ITER_AXES_BEGIN(axis, axis_idx) { const float offset[3] = {0.0f, 0.2f}; float color[4], color_hi[4]; - manipulator2d_get_axis_color(axis_idx, color, color_hi); + gizmo2d_get_axis_color(axis_idx, color, color_hi); /* custom handler! */ - WM_manipulator_set_fn_custom_modal(axis, manipulator2d_modal); + WM_gizmo_set_fn_custom_modal(axis, gizmo2d_modal); /* set up widget data */ RNA_float_set(axis->ptr, "angle", -M_PI_2 * axis_idx); RNA_float_set(axis->ptr, "length", 0.8f); - WM_manipulator_set_matrix_offset_location(axis, offset); - WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH); - WM_manipulator_set_scale(axis, U.manipulator_size); - WM_manipulator_set_color(axis, color); - WM_manipulator_set_color_highlight(axis, color_hi); + WM_gizmo_set_matrix_offset_location(axis, offset); + WM_gizmo_set_line_width(axis, GIZMO_AXIS_LINE_WIDTH); + WM_gizmo_set_scale(axis, U.gizmo_size); + WM_gizmo_set_color(axis, color); + WM_gizmo_set_color_highlight(axis, color_hi); /* assign operator */ - PointerRNA *ptr = WM_manipulator_operator_set(axis, 0, ot_translate, NULL); + PointerRNA *ptr = WM_gizmo_operator_set(axis, 0, ot_translate, NULL); bool constraint[3] = {0}; constraint[(axis_idx + 1) % 2] = 1; if (RNA_struct_find_property(ptr, "constraint_axis")) @@ -237,107 +237,107 @@ void ED_widgetgroup_manipulator2d_setup(const bContext *UNUSED(C), wmManipulator PointerRNA *ptr; /* assign operator */ - ptr = WM_manipulator_operator_set(man->cage, 0, ot_translate, NULL); + ptr = WM_gizmo_operator_set(man->cage, 0, ot_translate, NULL); RNA_boolean_set(ptr, "release_confirm", 1); bool constraint_x[3] = {1, 0, 0}; bool constraint_y[3] = {0, 1, 0}; - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X, ot_resize, NULL); + ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X, ot_resize, NULL); PropertyRNA *prop_release_confirm = RNA_struct_find_property(ptr, "release_confirm"); PropertyRNA *prop_constraint_axis = RNA_struct_find_property(ptr, "constraint_axis"); RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_x); RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X, ot_resize, NULL); + ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_X, ot_resize, NULL); RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_x); RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y, ot_resize, NULL); + ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y, ot_resize, NULL); RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_y); RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y, ot_resize, NULL); + ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y, ot_resize, NULL); RNA_property_boolean_set_array(ptr, prop_constraint_axis, constraint_y); RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y, ot_resize, NULL); + ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y, ot_resize, NULL); RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y, ot_resize, NULL); + ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y, ot_resize, NULL); RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y, ot_resize, NULL); + ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y, ot_resize, NULL); RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y, ot_resize, NULL); + ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y, ot_resize, NULL); RNA_property_boolean_set(ptr, prop_release_confirm, true); - ptr = WM_manipulator_operator_set(man->cage, ED_MANIPULATOR_CAGE2D_PART_ROTATE, ot_rotate, NULL); + ptr = WM_gizmo_operator_set(man->cage, ED_GIZMO_CAGE2D_PART_ROTATE, ot_rotate, NULL); RNA_property_boolean_set(ptr, prop_release_confirm, true); } } -void ED_widgetgroup_manipulator2d_refresh(const bContext *C, wmManipulatorGroup *mgroup) +void ED_widgetgroup_gizmo2d_refresh(const bContext *C, wmGizmoGroup *gzgroup) { - ManipulatorGroup2D *man = mgroup->customdata; + GizmoGroup2D *man = gzgroup->customdata; float origin[3]; - manipulator2d_calc_bounds(C, origin, man->min, man->max); + gizmo2d_calc_bounds(C, origin, man->min, man->max); copy_v2_v2(man->origin, origin); bool show_cage = !equals_v2v2(man->min, man->max); if (show_cage) { - man->cage->flag &= ~WM_MANIPULATOR_HIDDEN; - man->translate_x->flag |= WM_MANIPULATOR_HIDDEN; - man->translate_y->flag |= WM_MANIPULATOR_HIDDEN; + man->cage->flag &= ~WM_GIZMO_HIDDEN; + man->translate_x->flag |= WM_GIZMO_HIDDEN; + man->translate_y->flag |= WM_GIZMO_HIDDEN; } else { - man->cage->flag |= WM_MANIPULATOR_HIDDEN; - man->translate_x->flag &= ~WM_MANIPULATOR_HIDDEN; - man->translate_y->flag &= ~WM_MANIPULATOR_HIDDEN; + man->cage->flag |= WM_GIZMO_HIDDEN; + man->translate_x->flag &= ~WM_GIZMO_HIDDEN; + man->translate_y->flag &= ~WM_GIZMO_HIDDEN; } if (show_cage) { - wmManipulatorOpElem *mpop; + wmGizmoOpElem *mpop; float mid[2]; const float *min = man->min; const float *max = man->max; mid_v2_v2v2(mid, min, max); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X); + mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X); PropertyRNA *prop_center_override = RNA_struct_find_property(&mpop->ptr, "center_override"); RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){max[0], mid[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X); + mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_X); RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){min[0], mid[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_Y); + mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y); RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){mid[0], max[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_Y); + mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y); RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){mid[0], min[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MIN_Y); + mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y); RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){max[0], max[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MIN_X_MAX_Y); + mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y); RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){max[0], min[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MIN_Y); + mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y); RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){min[0], max[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_SCALE_MAX_X_MAX_Y); + mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y); RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){min[0], min[1], 0.0f}); - mpop = WM_manipulator_operator_get(man->cage, ED_MANIPULATOR_CAGE2D_PART_ROTATE); + mpop = WM_gizmo_operator_get(man->cage, ED_GIZMO_CAGE2D_PART_ROTATE); RNA_property_float_set_array(&mpop->ptr, prop_center_override, (float[3]){mid[0], mid[1], 0.0f}); } } -void ED_widgetgroup_manipulator2d_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +void ED_widgetgroup_gizmo2d_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) { ARegion *ar = CTX_wm_region(C); - ManipulatorGroup2D *man = mgroup->customdata; + GizmoGroup2D *man = gzgroup->customdata; float origin[3] = {UNPACK2(man->origin), 0.0f}; float origin_aa[3] = {UNPACK2(man->origin), 0.0f}; - manipulator2d_origin_to_region(ar, origin); + gizmo2d_origin_to_region(ar, origin); MAN2D_ITER_AXES_BEGIN(axis, axis_idx) { - WM_manipulator_set_matrix_location(axis, origin); + WM_gizmo_set_matrix_location(axis, origin); } MAN2D_ITER_AXES_END; UI_view2d_view_to_region_m4(&ar->v2d, man->cage->matrix_space); - WM_manipulator_set_matrix_offset_location(man->cage, origin_aa); + WM_gizmo_set_matrix_offset_location(man->cage, origin_aa); man->cage->matrix_offset[0][0] = (man->max[0] - man->min[0]); man->cage->matrix_offset[1][1] = (man->max[1] - man->min[1]); } @@ -346,9 +346,9 @@ void ED_widgetgroup_manipulator2d_draw_prepare(const bContext *C, wmManipulatorG * - Called on every redraw, better to do a more simple poll and check for selection in _refresh * - UV editing only, could be expanded for other things. */ -bool ED_widgetgroup_manipulator2d_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt)) +bool ED_widgetgroup_gizmo2d_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt)) { - if ((U.manipulator_flag & USER_MANIPULATOR_DRAW) == 0) { + if ((U.gizmo_flag & USER_GIZMO_DRAW) == 0) { return false; } diff --git a/source/blender/editors/transform/transform_manipulator_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c index 8f547fb7451..cbc2b312512 100644 --- a/source/blender/editors/transform/transform_manipulator_3d.c +++ b/source/blender/editors/transform/transform_gizmo_3d.c @@ -18,10 +18,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/transform/transform_manipulator_3d.c +/** \file blender/editors/transform/transform_gizmo_3d.c * \ingroup edtransform * - * \name 3D Transform Manipulator + * \name 3D Transform Gizmo * * Used for 3D View */ @@ -74,7 +74,7 @@ #include "ED_view3d.h" #include "ED_gpencil.h" #include "ED_screen.h" -#include "ED_manipulator_library.h" +#include "ED_gizmo_library.h" #include "UI_resources.h" @@ -106,7 +106,7 @@ #define MAN_SCALE_Z (1 << 10) #define MAN_SCALE_C (MAN_SCALE_X | MAN_SCALE_Y | MAN_SCALE_Z) -/* threshold for testing view aligned manipulator axis */ +/* threshold for testing view aligned gizmo axis */ struct { float min, max; } g_tw_axis_range[2] = { @@ -159,17 +159,17 @@ enum { MAN_AXES_SCALE, }; -typedef struct ManipulatorGroup { +typedef struct GizmoGroup { bool all_hidden; int twtype; - /* Users may change the twtype, detect changes to re-setup manipulator options. */ + /* Users may change the twtype, detect changes to re-setup gizmo options. */ int twtype_init; int twtype_prev; int use_twtype_refresh; - struct wmManipulator *manipulators[MAN_AXIS_LAST]; -} ManipulatorGroup; + struct wmGizmo *gizmos[MAN_AXIS_LAST]; +} GizmoGroup; /* -------------------------------------------------------------------- */ /** \name Utilities @@ -178,22 +178,22 @@ typedef struct ManipulatorGroup { /* loop over axes */ #define MAN_ITER_AXES_BEGIN(axis, axis_idx) \ { \ - wmManipulator *axis; \ + wmGizmo *axis; \ int axis_idx; \ for (axis_idx = 0; axis_idx < MAN_AXIS_LAST; axis_idx++) { \ - axis = manipulator_get_axis_from_index(man, axis_idx); + axis = gizmo_get_axis_from_index(man, axis_idx); #define MAN_ITER_AXES_END \ } \ } ((void)0) -static wmManipulator *manipulator_get_axis_from_index(const ManipulatorGroup *man, const short axis_idx) +static wmGizmo *gizmo_get_axis_from_index(const GizmoGroup *man, const short axis_idx) { BLI_assert(IN_RANGE_INCL(axis_idx, (float)MAN_AXIS_TRANS_X, (float)MAN_AXIS_LAST)); - return man->manipulators[axis_idx]; + return man->gizmos[axis_idx]; } -static short manipulator_get_axis_type(const int axis_idx) +static short gizmo_get_axis_type(const int axis_idx) { if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { return MAN_AXES_TRANSLATE; @@ -208,7 +208,7 @@ static short manipulator_get_axis_type(const int axis_idx) return -1; } -static uint manipulator_orientation_axis(const int axis_idx, bool *r_is_plane) +static uint gizmo_orientation_axis(const int axis_idx, bool *r_is_plane) { switch (axis_idx) { case MAN_AXIS_TRANS_YZ: @@ -247,13 +247,13 @@ static uint manipulator_orientation_axis(const int axis_idx, bool *r_is_plane) return 3; } -static bool manipulator_is_axis_visible( +static bool gizmo_is_axis_visible( const RegionView3D *rv3d, const int twtype, const float idot[3], const int axis_type, const int axis_idx) { if ((axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END) == 0) { bool is_plane = false; - const uint aidx_norm = manipulator_orientation_axis(axis_idx, &is_plane); + const uint aidx_norm = gizmo_orientation_axis(axis_idx, &is_plane); /* don't draw axis perpendicular to the view */ if (aidx_norm < 3) { float idot_axis = idot[aidx_norm]; @@ -330,7 +330,7 @@ static bool manipulator_is_axis_visible( return false; } -static void manipulator_get_axis_color( +static void gizmo_get_axis_color( const int axis_idx, const float idot[3], float r_col[4], float r_col_hi[4]) { @@ -346,7 +346,7 @@ static void manipulator_get_axis_color( } else { bool is_plane = false; - const int axis_idx_norm = manipulator_orientation_axis(axis_idx, &is_plane); + const int axis_idx_norm = gizmo_orientation_axis(axis_idx, &is_plane); /* get alpha fac based on axis angle, to fade axis out when hiding it because it points towards view */ if (axis_idx_norm < 3) { const float idot_min = g_tw_axis_range[is_plane].min; @@ -401,7 +401,7 @@ static void manipulator_get_axis_color( r_col_hi[3] = alpha_hi * alpha_fac; } -static void manipulator_get_axis_constraint(const int axis_idx, bool r_axis[3]) +static void gizmo_get_axis_constraint(const int axis_idx, bool r_axis[3]) { ARRAY_SET_ITEMS(r_axis, 0, 0, 0); @@ -596,7 +596,7 @@ bool gimbal_axis(Object *ob, float gmat[3][3]) /* centroid, boundbox, of selection */ /* returns total items selected */ -int ED_transform_calc_manipulator_stats( +int ED_transform_calc_gizmo_stats( const bContext *C, const struct TransformCalcParams *params, struct TransformBounds *tbounds) @@ -952,7 +952,7 @@ int ED_transform_calc_manipulator_stats( } else if (ob && (ob->mode & OB_MODE_POSE)) { bPoseChannel *pchan; - int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed + int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the gizmo mode, could be mixed bool ok = false; if ((pivot_point == V3D_AROUND_ACTIVE) && (pchan = BKE_pose_channel_active(ob))) { @@ -1061,7 +1061,7 @@ int ED_transform_calc_manipulator_stats( return totsel; } -static void manipulator_get_idot(RegionView3D *rv3d, float r_idot[3]) +static void gizmo_get_idot(RegionView3D *rv3d, float r_idot[3]) { float view_vec[3], axis_vec[3]; ED_view3d_global_to_vector(rv3d, rv3d->twmat[3], view_vec); @@ -1071,7 +1071,7 @@ static void manipulator_get_idot(RegionView3D *rv3d, float r_idot[3]) } } -static void manipulator_prepare_mat( +static void gizmo_prepare_mat( const bContext *C, View3D *v3d, RegionView3D *rv3d, const struct TransformBounds *tbounds) { Scene *scene = CTX_data_scene(C); @@ -1108,9 +1108,9 @@ static void manipulator_prepare_mat( /** * Sets up \a r_start and \a r_len to define arrow line range. - * Needed to adjust line drawing for combined manipulator axis types. + * Needed to adjust line drawing for combined gizmo axis types. */ -static void manipulator_line_range(const int twtype, const short axis_type, float *r_start, float *r_len) +static void gizmo_line_range(const int twtype, const short axis_type, float *r_start, float *r_len) { const float ofs = 0.2f; @@ -1136,15 +1136,15 @@ static void manipulator_line_range(const int twtype, const short axis_type, floa *r_len -= *r_start; } -static void manipulator_xform_message_subscribe( - wmManipulatorGroup *mgroup, struct wmMsgBus *mbus, +static void gizmo_xform_message_subscribe( + wmGizmoGroup *gzgroup, struct wmMsgBus *mbus, Scene *scene, bScreen *UNUSED(screen), ScrArea *UNUSED(sa), ARegion *ar, const void *type_fn) { /* Subscribe to view properties */ - wmMsgSubscribeValue msg_sub_value_mpr_tag_refresh = { + wmMsgSubscribeValue msg_sub_value_gz_tag_refresh = { .owner = ar, - .user_data = mgroup->parent_mmap, - .notify = WM_manipulator_do_msg_notify_tag_refresh, + .user_data = gzgroup->parent_gzmap, + .notify = WM_gizmo_do_msg_notify_tag_refresh, }; PointerRNA scene_ptr; @@ -1159,7 +1159,7 @@ static void manipulator_xform_message_subscribe( }; for (int i = 0; i < ARRAY_SIZE(props); i++) { if (props[i]) { - WM_msg_subscribe_rna(mbus, &scene_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__); + WM_msg_subscribe_rna(mbus, &scene_ptr, props[i], &msg_sub_value_gz_tag_refresh, __func__); } } } @@ -1167,96 +1167,98 @@ static void manipulator_xform_message_subscribe( PointerRNA toolsettings_ptr; RNA_pointer_create(&scene->id, &RNA_ToolSettings, scene->toolsettings, &toolsettings_ptr); - if (type_fn == TRANSFORM_WGT_manipulator) { + if (type_fn == TRANSFORM_GGT_gizmo) { extern PropertyRNA rna_ToolSettings_transform_pivot_point; - extern PropertyRNA rna_ToolSettings_use_manipulator_mode; + extern PropertyRNA rna_ToolSettings_use_gizmo_mode; const PropertyRNA *props[] = { &rna_ToolSettings_transform_pivot_point, - &rna_ToolSettings_use_manipulator_mode, + &rna_ToolSettings_use_gizmo_mode, }; for (int i = 0; i < ARRAY_SIZE(props); i++) { - WM_msg_subscribe_rna(mbus, &toolsettings_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__); + WM_msg_subscribe_rna(mbus, &toolsettings_ptr, props[i], &msg_sub_value_gz_tag_refresh, __func__); } } - else if (type_fn == VIEW3D_WGT_xform_cage) { + else if (type_fn == VIEW3D_GGT_xform_cage) { /* pass */ } else { BLI_assert(0); } - WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_mpr_tag_refresh); + WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_gz_tag_refresh); } /** \} */ /* -------------------------------------------------------------------- */ -/** \name Transform Manipulator +/** \name Transform Gizmo * \{ */ -static ManipulatorGroup *manipulatorgroup_init(wmManipulatorGroup *mgroup) +static GizmoGroup *gizmogroup_init(wmGizmoGroup *gzgroup) { - ManipulatorGroup *man; + GizmoGroup *man; - man = MEM_callocN(sizeof(ManipulatorGroup), "manipulator_data"); + man = MEM_callocN(sizeof(GizmoGroup), "gizmo_data"); - const wmManipulatorType *wt_arrow = WM_manipulatortype_find("MANIPULATOR_WT_arrow_3d", true); - const wmManipulatorType *wt_dial = WM_manipulatortype_find("MANIPULATOR_WT_dial_3d", true); - const wmManipulatorType *wt_prim = WM_manipulatortype_find("MANIPULATOR_WT_primitive_3d", true); + const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_3d", true); + const wmGizmoType *gzt_dial = WM_gizmotype_find("GIZMO_GT_dial_3d", true); + const wmGizmoType *gzt_prim = WM_gizmotype_find("GIZMO_GT_primitive_3d", true); -#define MANIPULATOR_NEW_ARROW(v, draw_style) { \ - man->manipulators[v] = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); \ - RNA_enum_set(man->manipulators[v]->ptr, "draw_style", draw_style); \ +#define GIZMO_NEW_ARROW(v, draw_style) { \ + man->gizmos[v] = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL); \ + RNA_enum_set(man->gizmos[v]->ptr, "draw_style", draw_style); \ } ((void)0) -#define MANIPULATOR_NEW_DIAL(v, draw_options) { \ - man->manipulators[v] = WM_manipulator_new_ptr(wt_dial, mgroup, NULL); \ - RNA_enum_set(man->manipulators[v]->ptr, "draw_options", draw_options); \ +#define GIZMO_NEW_DIAL(v, draw_options) { \ + man->gizmos[v] = WM_gizmo_new_ptr(gzt_dial, gzgroup, NULL); \ + RNA_enum_set(man->gizmos[v]->ptr, "draw_options", draw_options); \ } ((void)0) -#define MANIPULATOR_NEW_PRIM(v, draw_style) { \ - man->manipulators[v] = WM_manipulator_new_ptr(wt_prim, mgroup, NULL); \ - RNA_enum_set(man->manipulators[v]->ptr, "draw_style", draw_style); \ +#define GIZMO_NEW_PRIM(v, draw_style) { \ + man->gizmos[v] = WM_gizmo_new_ptr(gzt_prim, gzgroup, NULL); \ + RNA_enum_set(man->gizmos[v]->ptr, "draw_style", draw_style); \ } ((void)0) /* add/init widgets - order matters! */ - MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_T, ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL); + GIZMO_NEW_DIAL(MAN_AXIS_ROT_T, ED_GIZMO_DIAL_DRAW_FLAG_FILL); - MANIPULATOR_NEW_DIAL(MAN_AXIS_SCALE_C, ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP); + GIZMO_NEW_DIAL(MAN_AXIS_SCALE_C, ED_GIZMO_DIAL_DRAW_FLAG_NOP); - MANIPULATOR_NEW_ARROW(MAN_AXIS_SCALE_X, ED_MANIPULATOR_ARROW_STYLE_BOX); - MANIPULATOR_NEW_ARROW(MAN_AXIS_SCALE_Y, ED_MANIPULATOR_ARROW_STYLE_BOX); - MANIPULATOR_NEW_ARROW(MAN_AXIS_SCALE_Z, ED_MANIPULATOR_ARROW_STYLE_BOX); + GIZMO_NEW_ARROW(MAN_AXIS_SCALE_X, ED_GIZMO_ARROW_STYLE_BOX); + GIZMO_NEW_ARROW(MAN_AXIS_SCALE_Y, ED_GIZMO_ARROW_STYLE_BOX); + GIZMO_NEW_ARROW(MAN_AXIS_SCALE_Z, ED_GIZMO_ARROW_STYLE_BOX); - MANIPULATOR_NEW_PRIM(MAN_AXIS_SCALE_XY, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); - MANIPULATOR_NEW_PRIM(MAN_AXIS_SCALE_YZ, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); - MANIPULATOR_NEW_PRIM(MAN_AXIS_SCALE_ZX, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); + GIZMO_NEW_PRIM(MAN_AXIS_SCALE_XY, ED_GIZMO_PRIMITIVE_STYLE_PLANE); + GIZMO_NEW_PRIM(MAN_AXIS_SCALE_YZ, ED_GIZMO_PRIMITIVE_STYLE_PLANE); + GIZMO_NEW_PRIM(MAN_AXIS_SCALE_ZX, ED_GIZMO_PRIMITIVE_STYLE_PLANE); - MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_X, ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP); - MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_Y, ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP); - MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_Z, ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP); + GIZMO_NEW_DIAL(MAN_AXIS_ROT_X, ED_GIZMO_DIAL_DRAW_FLAG_CLIP); + GIZMO_NEW_DIAL(MAN_AXIS_ROT_Y, ED_GIZMO_DIAL_DRAW_FLAG_CLIP); + GIZMO_NEW_DIAL(MAN_AXIS_ROT_Z, ED_GIZMO_DIAL_DRAW_FLAG_CLIP); /* init screen aligned widget last here, looks better, behaves better */ - MANIPULATOR_NEW_DIAL(MAN_AXIS_ROT_C, ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP); + GIZMO_NEW_DIAL(MAN_AXIS_ROT_C, ED_GIZMO_DIAL_DRAW_FLAG_NOP); - MANIPULATOR_NEW_DIAL(MAN_AXIS_TRANS_C, ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP); + GIZMO_NEW_DIAL(MAN_AXIS_TRANS_C, ED_GIZMO_DIAL_DRAW_FLAG_NOP); - MANIPULATOR_NEW_ARROW(MAN_AXIS_TRANS_X, ED_MANIPULATOR_ARROW_STYLE_NORMAL); - MANIPULATOR_NEW_ARROW(MAN_AXIS_TRANS_Y, ED_MANIPULATOR_ARROW_STYLE_NORMAL); - MANIPULATOR_NEW_ARROW(MAN_AXIS_TRANS_Z, ED_MANIPULATOR_ARROW_STYLE_NORMAL); + GIZMO_NEW_ARROW(MAN_AXIS_TRANS_X, ED_GIZMO_ARROW_STYLE_NORMAL); + GIZMO_NEW_ARROW(MAN_AXIS_TRANS_Y, ED_GIZMO_ARROW_STYLE_NORMAL); + GIZMO_NEW_ARROW(MAN_AXIS_TRANS_Z, ED_GIZMO_ARROW_STYLE_NORMAL); - MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_XY, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); - MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_YZ, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); - MANIPULATOR_NEW_PRIM(MAN_AXIS_TRANS_ZX, ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE); + GIZMO_NEW_PRIM(MAN_AXIS_TRANS_XY, ED_GIZMO_PRIMITIVE_STYLE_PLANE); + GIZMO_NEW_PRIM(MAN_AXIS_TRANS_YZ, ED_GIZMO_PRIMITIVE_STYLE_PLANE); + GIZMO_NEW_PRIM(MAN_AXIS_TRANS_ZX, ED_GIZMO_PRIMITIVE_STYLE_PLANE); + + man->gizmos[MAN_AXIS_ROT_T]->flag |= WM_GIZMO_SELECT_BACKGROUND; return man; } /** - * Custom handler for manipulator widgets + * Custom handler for gizmo widgets */ -static int manipulator_modal( - bContext *C, wmManipulator *widget, const wmEvent *event, - eWM_ManipulatorTweak UNUSED(tweak_flag)) +static int gizmo_modal( + bContext *C, wmGizmo *widget, const wmEvent *event, + eWM_GizmoFlagTweak UNUSED(tweak_flag)) { /* Avoid unnecessary updates, partially address: T55458. */ if (ELEM(event->type, TIMER, INBETWEEN_MOUSEMOVE)) { @@ -1270,13 +1272,13 @@ static int manipulator_modal( struct TransformBounds tbounds; - if (ED_transform_calc_manipulator_stats( + if (ED_transform_calc_gizmo_stats( C, &(struct TransformCalcParams){ .use_only_center = true, }, &tbounds)) { - manipulator_prepare_mat(C, v3d, rv3d, &tbounds); - WM_manipulator_set_matrix_location(widget, rv3d->twmat[3]); + gizmo_prepare_mat(C, v3d, rv3d, &tbounds); + WM_gizmo_set_matrix_location(widget, rv3d->twmat[3]); } ED_region_tag_redraw(ar); @@ -1284,22 +1286,22 @@ static int manipulator_modal( return OPERATOR_RUNNING_MODAL; } -static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgroup) +static void gizmogroup_init_properties_from_twtype(wmGizmoGroup *gzgroup) { struct { wmOperatorType *translate, *rotate, *trackball, *resize; } ot_store = {NULL}; - ManipulatorGroup *man = mgroup->customdata; + GizmoGroup *man = gzgroup->customdata; MAN_ITER_AXES_BEGIN(axis, axis_idx) { - const short axis_type = manipulator_get_axis_type(axis_idx); + const short axis_type = gizmo_get_axis_type(axis_idx); bool constraint_axis[3] = {1, 0, 0}; PointerRNA *ptr; - manipulator_get_axis_constraint(axis_idx, constraint_axis); + gizmo_get_axis_constraint(axis_idx, constraint_axis); /* custom handler! */ - WM_manipulator_set_fn_custom_modal(axis, manipulator_modal); + WM_gizmo_set_fn_custom_modal(axis, gizmo_modal); switch (axis_idx) { case MAN_AXIS_TRANS_X: @@ -1311,19 +1313,19 @@ static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgr if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { int draw_options = 0; if ((man->twtype & (SCE_MANIP_ROTATE | SCE_MANIP_SCALE)) == 0) { - draw_options |= ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM; + draw_options |= ED_GIZMO_ARROW_DRAW_FLAG_STEM; } RNA_enum_set(axis->ptr, "draw_options", draw_options); } - WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH); + WM_gizmo_set_line_width(axis, GIZMO_AXIS_LINE_WIDTH); break; case MAN_AXIS_ROT_X: case MAN_AXIS_ROT_Y: case MAN_AXIS_ROT_Z: /* increased line width for better display */ - WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH + 1.0f); - WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_VALUE, true); + WM_gizmo_set_line_width(axis, GIZMO_AXIS_LINE_WIDTH + 1.0f); + WM_gizmo_set_flag(axis, WM_GIZMO_DRAW_VALUE, true); break; case MAN_AXIS_TRANS_XY: case MAN_AXIS_TRANS_YZ: @@ -1334,25 +1336,25 @@ static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgr { const float ofs_ax = 7.0f; const float ofs[3] = {ofs_ax, ofs_ax, 0.0f}; - WM_manipulator_set_scale(axis, 0.07f); - WM_manipulator_set_matrix_offset_location(axis, ofs); - WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true); + WM_gizmo_set_scale(axis, 0.07f); + WM_gizmo_set_matrix_offset_location(axis, ofs); + WM_gizmo_set_flag(axis, WM_GIZMO_DRAW_OFFSET_SCALE, true); break; } case MAN_AXIS_TRANS_C: case MAN_AXIS_ROT_C: case MAN_AXIS_SCALE_C: case MAN_AXIS_ROT_T: - WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH); + WM_gizmo_set_line_width(axis, GIZMO_AXIS_LINE_WIDTH); if (axis_idx == MAN_AXIS_ROT_T) { - WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_HOVER, true); + WM_gizmo_set_flag(axis, WM_GIZMO_DRAW_HOVER, true); } else if (axis_idx == MAN_AXIS_ROT_C) { - WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_VALUE, true); - WM_manipulator_set_scale(axis, 1.2f); + WM_gizmo_set_flag(axis, WM_GIZMO_DRAW_VALUE, true); + WM_gizmo_set_scale(axis, 1.2f); } else { - WM_manipulator_set_scale(axis, 0.2f); + WM_gizmo_set_scale(axis, 0.2f); } break; } @@ -1362,7 +1364,7 @@ static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgr if (ot_store.translate == NULL) { ot_store.translate = WM_operatortype_find("TRANSFORM_OT_translate", true); } - ptr = WM_manipulator_operator_set(axis, 0, ot_store.translate, NULL); + ptr = WM_gizmo_operator_set(axis, 0, ot_store.translate, NULL); break; case MAN_AXES_ROTATE: { @@ -1379,7 +1381,7 @@ static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgr } ot_rotate = ot_store.rotate; } - ptr = WM_manipulator_operator_set(axis, 0, ot_rotate, NULL); + ptr = WM_gizmo_operator_set(axis, 0, ot_rotate, NULL); break; } case MAN_AXES_SCALE: @@ -1387,7 +1389,7 @@ static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgr if (ot_store.resize == NULL) { ot_store.resize = WM_operatortype_find("TRANSFORM_OT_resize", true); } - ptr = WM_manipulator_operator_set(axis, 0, ot_store.resize, NULL); + ptr = WM_gizmo_operator_set(axis, 0, ot_store.resize, NULL); break; } } @@ -1404,11 +1406,11 @@ static void manipulatorgroup_init_properties_from_twtype(wmManipulatorGroup *mgr MAN_ITER_AXES_END; } -static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_gizmo_setup(const bContext *C, wmGizmoGroup *gzgroup) { - ManipulatorGroup *man = manipulatorgroup_init(mgroup); + GizmoGroup *man = gizmogroup_init(gzgroup); - mgroup->customdata = man; + gzgroup->customdata = man; { man->twtype = 0; @@ -1416,11 +1418,11 @@ static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup const bToolRef *tref = sa->runtime.tool; if (tref == NULL || STREQ(tref->idname, "Transform")) { - /* Setup all manipulators, they can be toggled via 'ToolSettings.manipulator_flag' */ + /* Setup all gizmos, they can be toggled via 'ToolSettings.gizmo_flag' */ man->twtype = SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE; man->use_twtype_refresh = true; } - else if (STREQ(tref->idname, "Move")) { + else if (STREQ(tref->idname, "Grab")) { man->twtype |= SCE_MANIP_TRANSLATE; } else if (STREQ(tref->idname, "Rotate")) { @@ -1434,12 +1436,12 @@ static void WIDGETGROUP_manipulator_setup(const bContext *C, wmManipulatorGroup } /* *** set properties for axes *** */ - manipulatorgroup_init_properties_from_twtype(mgroup); + gizmogroup_init_properties_from_twtype(gzgroup); } -static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_gizmo_refresh(const bContext *C, wmGizmoGroup *gzgroup) { - ManipulatorGroup *man = mgroup->customdata; + GizmoGroup *man = gzgroup->customdata; ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); View3D *v3d = sa->spacedata.first; @@ -1448,16 +1450,16 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou if (man->use_twtype_refresh) { Scene *scene = CTX_data_scene(C); - man->twtype = scene->toolsettings->manipulator_flag & man->twtype_init; + man->twtype = scene->toolsettings->gizmo_flag & man->twtype_init; if (man->twtype != man->twtype_prev) { man->twtype_prev = man->twtype; - manipulatorgroup_init_properties_from_twtype(mgroup); + gizmogroup_init_properties_from_twtype(gzgroup); } } /* skip, we don't draw anything anyway */ if ((man->all_hidden = - (ED_transform_calc_manipulator_stats( + (ED_transform_calc_gizmo_stats( C, &(struct TransformCalcParams){ .use_only_center = true, }, &tbounds) == 0))) @@ -1465,16 +1467,16 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou return; } - manipulator_prepare_mat(C, v3d, rv3d, &tbounds); + gizmo_prepare_mat(C, v3d, rv3d, &tbounds); /* *** set properties for axes *** */ MAN_ITER_AXES_BEGIN(axis, axis_idx) { - const short axis_type = manipulator_get_axis_type(axis_idx); - const int aidx_norm = manipulator_orientation_axis(axis_idx, NULL); + const short axis_type = gizmo_get_axis_type(axis_idx); + const int aidx_norm = gizmo_orientation_axis(axis_idx, NULL); - WM_manipulator_set_matrix_location(axis, rv3d->twmat[3]); + WM_gizmo_set_matrix_location(axis, rv3d->twmat[3]); switch (axis_idx) { case MAN_AXIS_TRANS_X: @@ -1487,9 +1489,9 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou float start_co[3] = {0.0f, 0.0f, 0.0f}; float len; - manipulator_line_range(man->twtype, axis_type, &start_co[2], &len); + gizmo_line_range(man->twtype, axis_type, &start_co[2], &len); - WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]); + WM_gizmo_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]); RNA_float_set(axis->ptr, "length", len); if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) { @@ -1498,14 +1500,14 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou start_co[2] += 0.215f; } } - WM_manipulator_set_matrix_offset_location(axis, start_co); - WM_manipulator_set_flag(axis, WM_MANIPULATOR_DRAW_OFFSET_SCALE, true); + WM_gizmo_set_matrix_offset_location(axis, start_co); + WM_gizmo_set_flag(axis, WM_GIZMO_DRAW_OFFSET_SCALE, true); break; } case MAN_AXIS_ROT_X: case MAN_AXIS_ROT_Y: case MAN_AXIS_ROT_Z: - WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]); + WM_gizmo_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]); break; case MAN_AXIS_TRANS_XY: case MAN_AXIS_TRANS_YZ: @@ -1516,7 +1518,7 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou { const float *y_axis = rv3d->twmat[aidx_norm - 1 < 0 ? 2 : aidx_norm - 1]; const float *z_axis = rv3d->twmat[aidx_norm]; - WM_manipulator_set_matrix_rotation_from_yz_axis(axis, y_axis, z_axis); + WM_gizmo_set_matrix_rotation_from_yz_axis(axis, y_axis, z_axis); break; } } @@ -1524,134 +1526,139 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou MAN_ITER_AXES_END; } -static void WIDGETGROUP_manipulator_message_subscribe( - const bContext *C, wmManipulatorGroup *mgroup, struct wmMsgBus *mbus) +static void WIDGETGROUP_gizmo_message_subscribe( + const bContext *C, wmGizmoGroup *gzgroup, struct wmMsgBus *mbus) { Scene *scene = CTX_data_scene(C); bScreen *screen = CTX_wm_screen(C); ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); - manipulator_xform_message_subscribe(mgroup, mbus, scene, screen, sa, ar, TRANSFORM_WGT_manipulator); + gizmo_xform_message_subscribe(gzgroup, mbus, scene, screen, sa, ar, TRANSFORM_GGT_gizmo); } -static void WIDGETGROUP_manipulator_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_gizmo_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) { - ManipulatorGroup *man = mgroup->customdata; + GizmoGroup *man = gzgroup->customdata; // ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); // View3D *v3d = sa->spacedata.first; RegionView3D *rv3d = ar->regiondata; float idot[3]; - /* when looking through a selected camera, the manipulator can be at the + /* when looking through a selected camera, the gizmo can be at the * exact same position as the view, skip so we don't break selection */ if (man->all_hidden || fabsf(ED_view3d_pixel_size(rv3d, rv3d->twmat[3])) < 1e-6f) { MAN_ITER_AXES_BEGIN(axis, axis_idx) { - WM_manipulator_set_flag(axis, WM_MANIPULATOR_HIDDEN, true); + WM_gizmo_set_flag(axis, WM_GIZMO_HIDDEN, true); } MAN_ITER_AXES_END; return; } - manipulator_get_idot(rv3d, idot); + gizmo_get_idot(rv3d, idot); /* *** set properties for axes *** */ MAN_ITER_AXES_BEGIN(axis, axis_idx) { - const short axis_type = manipulator_get_axis_type(axis_idx); + const short axis_type = gizmo_get_axis_type(axis_idx); /* XXX maybe unset _HIDDEN flag on redraw? */ - if (manipulator_is_axis_visible(rv3d, man->twtype, idot, axis_type, axis_idx)) { - WM_manipulator_set_flag(axis, WM_MANIPULATOR_HIDDEN, false); + if (gizmo_is_axis_visible(rv3d, man->twtype, idot, axis_type, axis_idx)) { + WM_gizmo_set_flag(axis, WM_GIZMO_HIDDEN, false); } else { - WM_manipulator_set_flag(axis, WM_MANIPULATOR_HIDDEN, true); + WM_gizmo_set_flag(axis, WM_GIZMO_HIDDEN, true); continue; } float color[4], color_hi[4]; - manipulator_get_axis_color(axis_idx, idot, color, color_hi); - WM_manipulator_set_color(axis, color); - WM_manipulator_set_color_highlight(axis, color_hi); + gizmo_get_axis_color(axis_idx, idot, color, color_hi); + WM_gizmo_set_color(axis, color); + WM_gizmo_set_color_highlight(axis, color_hi); switch (axis_idx) { case MAN_AXIS_TRANS_C: case MAN_AXIS_ROT_C: case MAN_AXIS_SCALE_C: case MAN_AXIS_ROT_T: - WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->viewinv[2]); + WM_gizmo_set_matrix_rotation_from_z_axis(axis, rv3d->viewinv[2]); break; } } MAN_ITER_AXES_END; } -static bool WIDGETGROUP_manipulator_poll(const struct bContext *C, struct wmManipulatorGroupType *wgt) +static bool WIDGETGROUP_gizmo_poll(const struct bContext *C, struct wmGizmoGroupType *gzgt) { /* it's a given we only use this in 3D view */ bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); if ((tref_rt == NULL) || - !STREQ(wgt->idname, tref_rt->manipulator_group)) + !STREQ(gzgt->idname, tref_rt->gizmo_group)) { - WM_manipulator_group_type_unlink_delayed_ptr(wgt); + WM_gizmo_group_type_unlink_delayed_ptr(gzgt); + return false; + } + + View3D *v3d = CTX_wm_view3d(C); + if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)) { return false; } return true; } -void TRANSFORM_WGT_manipulator(wmManipulatorGroupType *wgt) +void TRANSFORM_GGT_gizmo(wmGizmoGroupType *gzgt) { - wgt->name = "Transform Manipulator"; - wgt->idname = "TRANSFORM_WGT_manipulator"; + gzgt->name = "Transform Gizmo"; + gzgt->idname = "TRANSFORM_GGT_gizmo"; - wgt->flag |= WM_MANIPULATORGROUPTYPE_3D; + gzgt->flag |= WM_GIZMOGROUPTYPE_3D; - wgt->mmap_params.spaceid = SPACE_VIEW3D; - wgt->mmap_params.regionid = RGN_TYPE_WINDOW; + gzgt->gzmap_params.spaceid = SPACE_VIEW3D; + gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW; - wgt->poll = WIDGETGROUP_manipulator_poll; - wgt->setup = WIDGETGROUP_manipulator_setup; - wgt->refresh = WIDGETGROUP_manipulator_refresh; - wgt->message_subscribe = WIDGETGROUP_manipulator_message_subscribe; - wgt->draw_prepare = WIDGETGROUP_manipulator_draw_prepare; + gzgt->poll = WIDGETGROUP_gizmo_poll; + gzgt->setup = WIDGETGROUP_gizmo_setup; + gzgt->refresh = WIDGETGROUP_gizmo_refresh; + gzgt->message_subscribe = WIDGETGROUP_gizmo_message_subscribe; + gzgt->draw_prepare = WIDGETGROUP_gizmo_draw_prepare; } /** \} */ /* -------------------------------------------------------------------- */ -/** \name Scale Cage Manipulator +/** \name Scale Cage Gizmo * \{ */ struct XFormCageWidgetGroup { - wmManipulator *manipulator; + wmGizmo *gizmo; }; -static bool WIDGETGROUP_xform_cage_poll(const bContext *C, wmManipulatorGroupType *wgt) +static bool WIDGETGROUP_xform_cage_poll(const bContext *C, wmGizmoGroupType *gzgt) { bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C); - if (!STREQ(wgt->idname, tref_rt->manipulator_group)) { - WM_manipulator_group_type_unlink_delayed_ptr(wgt); + if (!STREQ(gzgt->idname, tref_rt->gizmo_group)) { + WM_gizmo_group_type_unlink_delayed_ptr(gzgt); return false; } return true; } -static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmManipulatorGroup *mgroup) +static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { - struct XFormCageWidgetGroup *xmgroup = MEM_mallocN(sizeof(struct XFormCageWidgetGroup), __func__); - const wmManipulatorType *wt_cage = WM_manipulatortype_find("MANIPULATOR_WT_cage_3d", true); - xmgroup->manipulator = WM_manipulator_new_ptr(wt_cage, mgroup, NULL); - wmManipulator *mpr = xmgroup->manipulator; + struct XFormCageWidgetGroup *xgzgroup = MEM_mallocN(sizeof(struct XFormCageWidgetGroup), __func__); + const wmGizmoType *gzt_cage = WM_gizmotype_find("GIZMO_GT_cage_3d", true); + xgzgroup->gizmo = WM_gizmo_new_ptr(gzt_cage, gzgroup, NULL); + wmGizmo *gz = xgzgroup->gizmo; - RNA_enum_set(mpr->ptr, "transform", - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_SCALE | - ED_MANIPULATOR_CAGE2D_XFORM_FLAG_TRANSLATE); + RNA_enum_set(gz->ptr, "transform", + ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE | + ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE); - mpr->color[0] = 1; - mpr->color_hi[0] = 1; + gz->color[0] = 1; + gz->color_hi[0] = 1; - mgroup->customdata = xmgroup; + gzgroup->customdata = xgzgroup; { wmOperatorType *ot_resize = WM_operatortype_find("TRANSFORM_OT_resize", true); @@ -1661,12 +1668,12 @@ static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmManipulato PropertyRNA *prop_release_confirm = NULL; PropertyRNA *prop_constraint_axis = NULL; - int i = ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z; + int i = ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z; for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { for (int z = 0; z < 3; z++) { bool constraint[3] = {x != 1, y != 1, z != 1}; - ptr = WM_manipulator_operator_set(mpr, i, ot_resize, NULL); + ptr = WM_gizmo_operator_set(gz, i, ot_resize, NULL); if (prop_release_confirm == NULL) { prop_release_confirm = RNA_struct_find_property(ptr, "release_confirm"); prop_constraint_axis = RNA_struct_find_property(ptr, "constraint_axis"); @@ -1680,56 +1687,56 @@ static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmManipulato } } -static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmGizmoGroup *gzgroup) { ScrArea *sa = CTX_wm_area(C); View3D *v3d = sa->spacedata.first; ARegion *ar = CTX_wm_region(C); RegionView3D *rv3d = ar->regiondata; - struct XFormCageWidgetGroup *xmgroup = mgroup->customdata; - wmManipulator *mpr = xmgroup->manipulator; + struct XFormCageWidgetGroup *xgzgroup = gzgroup->customdata; + wmGizmo *gz = xgzgroup->gizmo; struct TransformBounds tbounds; - if ((ED_transform_calc_manipulator_stats( + if ((ED_transform_calc_gizmo_stats( C, &(struct TransformCalcParams) { .use_local_axis = true, }, &tbounds) == 0) || equals_v3v3(rv3d->tw_axis_min, rv3d->tw_axis_max)) { - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true); + WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, true); } else { - manipulator_prepare_mat(C, v3d, rv3d, &tbounds); + gizmo_prepare_mat(C, v3d, rv3d, &tbounds); - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false); - WM_manipulator_set_flag(mpr, WM_MANIPULATOR_GRAB_CURSOR, true); + WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false); + WM_gizmo_set_flag(gz, WM_GIZMO_GRAB_CURSOR, true); float dims[3]; sub_v3_v3v3(dims, rv3d->tw_axis_max, rv3d->tw_axis_min); - RNA_float_set_array(mpr->ptr, "dimensions", dims); + RNA_float_set_array(gz->ptr, "dimensions", dims); mul_v3_fl(dims, 0.5f); - copy_m4_m3(mpr->matrix_offset, rv3d->tw_axis_matrix); - mid_v3_v3v3(mpr->matrix_offset[3], rv3d->tw_axis_max, rv3d->tw_axis_min); - mul_m3_v3(rv3d->tw_axis_matrix, mpr->matrix_offset[3]); + copy_m4_m3(gz->matrix_offset, rv3d->tw_axis_matrix); + mid_v3_v3v3(gz->matrix_offset[3], rv3d->tw_axis_max, rv3d->tw_axis_min); + mul_m3_v3(rv3d->tw_axis_matrix, gz->matrix_offset[3]); PropertyRNA *prop_center_override = NULL; float center[3]; float center_global[3]; - int i = ED_MANIPULATOR_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z; + int i = ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z; for (int x = 0; x < 3; x++) { center[0] = (float)(1 - x) * dims[0]; for (int y = 0; y < 3; y++) { center[1] = (float)(1 - y) * dims[1]; for (int z = 0; z < 3; z++) { center[2] = (float)(1 - z) * dims[2]; - struct wmManipulatorOpElem *mpop = WM_manipulator_operator_get(mpr, i); + struct wmGizmoOpElem *mpop = WM_gizmo_operator_get(gz, i); if (prop_center_override == NULL) { prop_center_override = RNA_struct_find_property(&mpop->ptr, "center_override"); } - mul_v3_m4v3(center_global, mpr->matrix_offset, center); + mul_v3_m4v3(center_global, gz->matrix_offset, center); RNA_property_float_set_array(&mpop->ptr, prop_center_override, center_global); i++; } @@ -1739,45 +1746,45 @@ static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmManipulatorGroup } static void WIDGETGROUP_xform_cage_message_subscribe( - const bContext *C, wmManipulatorGroup *mgroup, struct wmMsgBus *mbus) + const bContext *C, wmGizmoGroup *gzgroup, struct wmMsgBus *mbus) { Scene *scene = CTX_data_scene(C); bScreen *screen = CTX_wm_screen(C); ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); - manipulator_xform_message_subscribe(mgroup, mbus, scene, screen, sa, ar, VIEW3D_WGT_xform_cage); + gizmo_xform_message_subscribe(gzgroup, mbus, scene, screen, sa, ar, VIEW3D_GGT_xform_cage); } -static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) +static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) { - struct XFormCageWidgetGroup *xmgroup = mgroup->customdata; - wmManipulator *mpr = xmgroup->manipulator; + struct XFormCageWidgetGroup *xgzgroup = gzgroup->customdata; + wmGizmo *gz = xgzgroup->gizmo; ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); if (ob && ob->mode & OB_MODE_EDIT) { - copy_m4_m4(mpr->matrix_space, ob->obmat); + copy_m4_m4(gz->matrix_space, ob->obmat); } else { - unit_m4(mpr->matrix_space); + unit_m4(gz->matrix_space); } } -void VIEW3D_WGT_xform_cage(wmManipulatorGroupType *wgt) +void VIEW3D_GGT_xform_cage(wmGizmoGroupType *gzgt) { - wgt->name = "Transform Cage"; - wgt->idname = "VIEW3D_WGT_xform_cage"; + gzgt->name = "Transform Cage"; + gzgt->idname = "VIEW3D_GGT_xform_cage"; - wgt->flag |= WM_MANIPULATORGROUPTYPE_3D; + gzgt->flag |= WM_GIZMOGROUPTYPE_3D; - wgt->mmap_params.spaceid = SPACE_VIEW3D; - wgt->mmap_params.regionid = RGN_TYPE_WINDOW; + gzgt->gzmap_params.spaceid = SPACE_VIEW3D; + gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW; - wgt->poll = WIDGETGROUP_xform_cage_poll; - wgt->setup = WIDGETGROUP_xform_cage_setup; - wgt->refresh = WIDGETGROUP_xform_cage_refresh; - wgt->message_subscribe = WIDGETGROUP_xform_cage_message_subscribe; - wgt->draw_prepare = WIDGETGROUP_xform_cage_draw_prepare; + gzgt->poll = WIDGETGROUP_xform_cage_poll; + gzgt->setup = WIDGETGROUP_xform_cage_setup; + gzgt->refresh = WIDGETGROUP_xform_cage_refresh; + gzgt->message_subscribe = WIDGETGROUP_xform_cage_message_subscribe; + gzgt->draw_prepare = WIDGETGROUP_xform_cage_draw_prepare; } /** \} */ diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index cfac908f976..9a9526537d1 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -496,7 +496,7 @@ static int transform_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* add temp handler */ WM_event_add_modal_handler(C, op); - op->flag |= OP_IS_MODAL_GRAB_CURSOR; // XXX maybe we want this with the manipulator only? + op->flag |= OP_IS_MODAL_GRAB_CURSOR; // XXX maybe we want this with the gizmo only? /* Use when modal input has some transformation to begin with. */ { @@ -588,7 +588,7 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) } if (flags & P_CENTER) { - /* For manipulators that define their own center. */ + /* For gizmos that define their own center. */ prop = RNA_def_property(ot->srna, "center_override", PROP_FLOAT, PROP_XYZ); RNA_def_property_array(prop, 3); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); @@ -1137,14 +1137,18 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac WM_keymap_add_item(keymap, "TRANSFORM_OT_select_orientation", SPACEKEY, KM_PRESS, KM_ALT, 0); +#ifdef USE_WM_KEYMAP_27X kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_create_orientation", SPACEKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); RNA_boolean_set(kmi->ptr, "use", true); +#endif WM_keymap_add_item(keymap, OP_MIRROR, MKEY, KM_PRESS, KM_CTRL, 0); kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_snap"); + WM_keymap_add_panel(keymap, "VIEW3D_PT_snapping", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); + /* Will fall-through to texture-space transform. */ kmi = WM_keymap_add_item(keymap, "OBJECT_OT_transform_axis_target", TKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 48ec664d634..b67fd22dbff 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -124,13 +124,13 @@ int BIF_snappingSupported(Object *obedit) } #endif -bool validSnap(TransInfo *t) +bool validSnap(const TransInfo *t) { return (t->tsnap.status & (POINT_INIT | TARGET_INIT)) == (POINT_INIT | TARGET_INIT) || (t->tsnap.status & (MULTI_POINTS | TARGET_INIT)) == (MULTI_POINTS | TARGET_INIT); } -bool activeSnap(TransInfo *t) +bool activeSnap(const TransInfo *t) { return ((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP) || ((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT); @@ -155,7 +155,6 @@ void drawSnapping(const struct bContext *C, TransInfo *t) if (t->spacetype == SPACE_VIEW3D) { if (validSnap(t)) { TransSnapPoint *p; - View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); float imat[4][4]; float size; @@ -166,7 +165,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) invert_m4_m4(imat, rv3d->viewmat); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); @@ -191,7 +190,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) if (usingSnappingNormal(t) && validSnappingNormal(t)) { immUniformColor4ubv(activeCol); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex3f(pos, t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], t->tsnap.snapPoint[2]); immVertex3f(pos, t->tsnap.snapPoint[0] + t->tsnap.snapNormal[0], t->tsnap.snapPoint[1] + t->tsnap.snapNormal[1], @@ -201,8 +200,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) immUnbindProgram(); - if (v3d->zbuf) - GPU_depth_test(true); + GPU_depth_test(true); } } else if (t->spacetype == SPACE_IMAGE) { @@ -221,7 +219,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) GPU_blend(true); - unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -453,12 +451,12 @@ void resetSnapping(TransInfo *t) t->tsnap.snapNodeBorder = 0; } -bool usingSnappingNormal(TransInfo *t) +bool usingSnappingNormal(const TransInfo *t) { return t->tsnap.align; } -bool validSnappingNormal(TransInfo *t) +bool validSnappingNormal(const TransInfo *t) { if (validSnap(t)) { if (!is_zero_v3(t->tsnap.snapNormal)) { @@ -791,7 +789,7 @@ void removeSnapPoint(TransInfo *t) } } -void getSnapPoint(TransInfo *t, float vec[3]) +void getSnapPoint(const TransInfo *t, float vec[3]) { if (t->tsnap.points.first) { TransSnapPoint *p; |