Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform.c
| Show First 20 Lines • Show All 772 Lines • ▼ Show 20 Lines | wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) | ||||
| wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Transform Modal Map"); | wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Transform Modal Map"); | ||||
| keymap = WM_modalkeymap_ensure(keyconf, "Transform Modal Map", modal_items); | keymap = WM_modalkeymap_ensure(keyconf, "Transform Modal Map", modal_items); | ||||
| keymap->poll_modal_item = transform_modal_item_poll; | keymap->poll_modal_item = transform_modal_item_poll; | ||||
| return keymap; | return keymap; | ||||
| } | } | ||||
| static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cmode, bool is_plane) | static void transform_event_xyz_constraint(TransInfo *t, short key_type, bool is_plane) | ||||
| { | { | ||||
| if (!(t->flag & T_NO_CONSTRAINT)) { | if (!(t->flag & T_NO_CONSTRAINT)) { | ||||
| char cmode = constraintModeToChar(t); | |||||
| int constraint_axis, constraint_plane; | int constraint_axis, constraint_plane; | ||||
| const bool edit_2d = (t->flag & T_2D_EDIT) != 0; | const bool edit_2d = (t->flag & T_2D_EDIT) != 0; | ||||
| const char *msg1 = "", *msg2 = "", *msg3 = ""; | const char *msg1 = "", *msg2 = "", *msg3 = ""; | ||||
| char axis; | char axis; | ||||
| /* Initialize */ | /* Initialize */ | ||||
| switch (key_type) { | switch (key_type) { | ||||
| case EVT_XKEY: | case EVT_XKEY: | ||||
| Show All 27 Lines | if (edit_2d && (key_type != EVT_ZKEY)) { | ||||
| if (cmode == axis) { | if (cmode == axis) { | ||||
| stopConstraint(t); | stopConstraint(t); | ||||
| } | } | ||||
| else { | else { | ||||
| setUserConstraint(t, V3D_ORIENT_GLOBAL, constraint_axis, msg1); | setUserConstraint(t, V3D_ORIENT_GLOBAL, constraint_axis, msg1); | ||||
| } | } | ||||
| } | } | ||||
| else if (!edit_2d) { | else if (!edit_2d) { | ||||
| if (cmode != axis) { | if (ELEM(cmode, '\0', axis)) { | ||||
| /* First press, constraint to an axis. */ | |||||
| t->orientation.index = 0; | |||||
| const short *orientation_ptr = t->orientation.types[t->orientation.index]; | |||||
| const short orientation = orientation_ptr ? *orientation_ptr : V3D_ORIENT_GLOBAL; | |||||
| if (is_plane == false) { | |||||
| setUserConstraint(t, orientation, constraint_axis, msg2); | |||||
| } | |||||
| else { | |||||
| setUserConstraint(t, orientation, constraint_plane, msg3); | |||||
| } | |||||
| } | |||||
| else { | |||||
| /* Successive presses on existing axis, cycle orientation modes. */ | /* Successive presses on existing axis, cycle orientation modes. */ | ||||
| t->orientation.index = (t->orientation.index + 1) % ARRAY_SIZE(t->orientation.types); | t->orientation.index = (t->orientation.index + 1) % ARRAY_SIZE(t->orientation.types); | ||||
| BLI_assert(t->orientation.types[0] != V3D_ORIENT_CUSTOM_MATRIX); | |||||
| initTransformOrientation(t->context, t, t->orientation.types[t->orientation.index]); | |||||
| } | |||||
| if (t->orientation.index == 0) { | if (t->orientation.index == 0) { | ||||
| stopConstraint(t); | stopConstraint(t); | ||||
| } | } | ||||
| else { | else { | ||||
| const short *orientation_ptr = t->orientation.types[t->orientation.index]; | const short orientation = t->orientation.types[t->orientation.index]; | ||||
| const short orientation = orientation_ptr ? *orientation_ptr : V3D_ORIENT_GLOBAL; | |||||
| if (is_plane == false) { | if (is_plane == false) { | ||||
| setUserConstraint(t, orientation, constraint_axis, msg2); | setUserConstraint(t, orientation, constraint_axis, msg2); | ||||
| } | } | ||||
| else { | else { | ||||
| setUserConstraint(t, orientation, constraint_plane, msg3); | setUserConstraint(t, orientation, constraint_plane, msg3); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| } | } | ||||
| } | } | ||||
| int transformEvent(TransInfo *t, const wmEvent *event) | int transformEvent(TransInfo *t, const wmEvent *event) | ||||
| { | { | ||||
| char cmode = constraintModeToChar(t); | |||||
| bool handled = false; | bool handled = false; | ||||
| const int modifiers_prev = t->modifiers; | const int modifiers_prev = t->modifiers; | ||||
| const int mode_prev = t->mode; | const int mode_prev = t->mode; | ||||
| t->redraw |= handleMouseInput(t, &t->mouse, event); | t->redraw |= handleMouseInput(t, &t->mouse, event); | ||||
| /* Handle modal numinput events first, if already activated. */ | /* Handle modal numinput events first, if already activated. */ | ||||
| if (((event->val == KM_PRESS) || (event->type == EVT_MODAL_MAP)) && hasNumInput(&t->num) && | if (((event->val == KM_PRESS) || (event->type == EVT_MODAL_MAP)) && hasNumInput(&t->num) && | ||||
| ▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | switch (event->val) { | ||||
| break; | break; | ||||
| case TFM_MODAL_SNAP_TOGGLE: | case TFM_MODAL_SNAP_TOGGLE: | ||||
| t->modifiers ^= MOD_SNAP; | t->modifiers ^= MOD_SNAP; | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| handled = true; | handled = true; | ||||
| break; | break; | ||||
| case TFM_MODAL_AXIS_X: | case TFM_MODAL_AXIS_X: | ||||
| if (!(t->flag & T_NO_CONSTRAINT)) { | if (!(t->flag & T_NO_CONSTRAINT)) { | ||||
| transform_event_xyz_constraint(t, EVT_XKEY, cmode, false); | transform_event_xyz_constraint(t, EVT_XKEY, false); | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| handled = true; | handled = true; | ||||
| } | } | ||||
| break; | break; | ||||
| case TFM_MODAL_AXIS_Y: | case TFM_MODAL_AXIS_Y: | ||||
| if ((t->flag & T_NO_CONSTRAINT) == 0) { | if ((t->flag & T_NO_CONSTRAINT) == 0) { | ||||
| transform_event_xyz_constraint(t, EVT_YKEY, cmode, false); | transform_event_xyz_constraint(t, EVT_YKEY, false); | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| handled = true; | handled = true; | ||||
| } | } | ||||
| break; | break; | ||||
| case TFM_MODAL_AXIS_Z: | case TFM_MODAL_AXIS_Z: | ||||
| if ((t->flag & (T_NO_CONSTRAINT)) == 0) { | if ((t->flag & (T_NO_CONSTRAINT)) == 0) { | ||||
| transform_event_xyz_constraint(t, EVT_ZKEY, cmode, false); | transform_event_xyz_constraint(t, EVT_ZKEY, false); | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| handled = true; | handled = true; | ||||
| } | } | ||||
| break; | break; | ||||
| case TFM_MODAL_PLANE_X: | case TFM_MODAL_PLANE_X: | ||||
| if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) { | if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) { | ||||
| transform_event_xyz_constraint(t, EVT_XKEY, cmode, true); | transform_event_xyz_constraint(t, EVT_XKEY, true); | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| handled = true; | handled = true; | ||||
| } | } | ||||
| break; | break; | ||||
| case TFM_MODAL_PLANE_Y: | case TFM_MODAL_PLANE_Y: | ||||
| if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) { | if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) { | ||||
| transform_event_xyz_constraint(t, EVT_YKEY, cmode, true); | transform_event_xyz_constraint(t, EVT_YKEY, true); | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| handled = true; | handled = true; | ||||
| } | } | ||||
| break; | break; | ||||
| case TFM_MODAL_PLANE_Z: | case TFM_MODAL_PLANE_Z: | ||||
| if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) { | if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) { | ||||
| transform_event_xyz_constraint(t, EVT_ZKEY, cmode, true); | transform_event_xyz_constraint(t, EVT_ZKEY, true); | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| handled = true; | handled = true; | ||||
| } | } | ||||
| break; | break; | ||||
| case TFM_MODAL_CONS_OFF: | case TFM_MODAL_CONS_OFF: | ||||
| if ((t->flag & T_NO_CONSTRAINT) == 0) { | if ((t->flag & T_NO_CONSTRAINT) == 0) { | ||||
| stopConstraint(t); | stopConstraint(t); | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| ▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | switch (event->type) { | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| t->modifiers |= MOD_CONSTRAINT_SELECT; | t->modifiers |= MOD_CONSTRAINT_SELECT; | ||||
| if (t->con.mode & CON_APPLY) { | if (t->con.mode & CON_APPLY) { | ||||
| stopConstraint(t); | stopConstraint(t); | ||||
| } | } | ||||
| else { | else { | ||||
| if (event->shift) { | initSelectConstraint(t, event->shift); | ||||
| /* bit hackish... but it prevents mmb select to print the | |||||
| * orientation from menu */ | |||||
| float mati[3][3]; | |||||
| strcpy(t->spacename, "global"); | |||||
| unit_m3(mati); | |||||
| initSelectConstraint(t, mati); | |||||
| } | |||||
| else { | |||||
| initSelectConstraint(t, t->spacemtx); | |||||
| } | |||||
| postSelectConstraint(t); | postSelectConstraint(t); | ||||
| } | } | ||||
| } | } | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| handled = true; | handled = true; | ||||
| } | } | ||||
| break; | break; | ||||
| case EVT_GKEY: | case EVT_GKEY: | ||||
| ▲ Show 20 Lines • Show All 444 Lines • ▼ Show 20 Lines | if (!(t->options & CTX_NO_PET)) { | ||||
| t->prop_size; | t->prop_size; | ||||
| } | } | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "proportional_edit_falloff")) && | if ((prop = RNA_struct_find_property(op->ptr, "proportional_edit_falloff")) && | ||||
| !RNA_property_is_set(op->ptr, prop)) { | !RNA_property_is_set(op->ptr, prop)) { | ||||
| ts->prop_mode = t->prop_mode; | ts->prop_mode = t->prop_mode; | ||||
| } | } | ||||
| } | } | ||||
| if (t->spacetype == SPACE_VIEW3D) { | |||||
| if ((prop = RNA_struct_find_property(op->ptr, "orient_type")) && | |||||
| !RNA_property_is_set(op->ptr, prop) && | |||||
| (t->orientation.user != V3D_ORIENT_CUSTOM_MATRIX)) { | |||||
| TransformOrientationSlot *orient_slot = &t->scene->orientation_slots[SCE_ORIENT_DEFAULT]; | |||||
| orient_slot->type = t->orientation.user; | |||||
| BLI_assert(((orient_slot->index_custom == -1) && (t->orientation.custom == NULL)) || | |||||
| (BKE_scene_transform_orientation_get_index(t->scene, t->orientation.custom) == | |||||
| orient_slot->index_custom)); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| if (t->flag & T_MODAL) { | if (t->flag & T_MODAL) { | ||||
| /* do we check for parameter? */ | /* do we check for parameter? */ | ||||
| if (transformModeUseSnap(t)) { | if (transformModeUseSnap(t)) { | ||||
| if (t->modifiers & MOD_SNAP) { | if (t->modifiers & MOD_SNAP) { | ||||
| ts->snap_flag |= SCE_SNAP; | ts->snap_flag |= SCE_SNAP; | ||||
| } | } | ||||
| Show All 10 Lines | if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) { | ||||
| RNA_enum_set(op->ptr, "proportional_edit_falloff", t->prop_mode); | RNA_enum_set(op->ptr, "proportional_edit_falloff", t->prop_mode); | ||||
| RNA_float_set(op->ptr, "proportional_size", t->prop_size); | RNA_float_set(op->ptr, "proportional_size", t->prop_size); | ||||
| } | } | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "mirror"))) { | if ((prop = RNA_struct_find_property(op->ptr, "mirror"))) { | ||||
| RNA_property_boolean_set(op->ptr, prop, (t->flag & T_NO_MIRROR) == 0); | RNA_property_boolean_set(op->ptr, prop, (t->flag & T_NO_MIRROR) == 0); | ||||
| } | } | ||||
| /* Orientation used for redo. */ | |||||
| const bool use_orient_axis = (t->orient_matrix_is_set && | |||||
| (RNA_struct_find_property(op->ptr, "orient_axis") != NULL)); | |||||
| short orientation; | |||||
| if (t->con.mode & CON_APPLY) { | |||||
| orientation = t->con.orientation; | |||||
| if (orientation == V3D_ORIENT_CUSTOM) { | |||||
| const int orientation_index_custom = BKE_scene_transform_orientation_get_index( | |||||
| t->scene, t->orientation.custom); | |||||
| /* Maybe we need a t->con.custom_orientation? | |||||
| * Seems like it would always match t->orientation.custom. */ | |||||
| orientation = V3D_ORIENT_CUSTOM + orientation_index_custom; | |||||
| BLI_assert(orientation >= V3D_ORIENT_CUSTOM); | |||||
| } | |||||
| } | |||||
| else if ((t->orientation.user == V3D_ORIENT_CUSTOM_MATRIX) && | |||||
| (prop = RNA_struct_find_property(op->ptr, "orient_matrix_type"))) { | |||||
| orientation = RNA_property_enum_get(op->ptr, prop); | |||||
| } | |||||
| else if (use_orient_axis) { | |||||
| /* We're not using an orientation, use the fallback. */ | |||||
| orientation = t->orientation.unset; | |||||
| } | |||||
| else { | |||||
| orientation = V3D_ORIENT_GLOBAL; | |||||
| unit_m3(t->spacemtx); | |||||
| } | |||||
| if ((prop = RNA_struct_find_property(op->ptr, "orient_axis"))) { | if ((prop = RNA_struct_find_property(op->ptr, "orient_axis"))) { | ||||
| if (t->flag & T_MODAL) { | if (t->flag & T_MODAL) { | ||||
| if (t->con.mode & CON_APPLY) { | if (t->con.mode & CON_APPLY) { | ||||
| int orient_axis = constraintModeToIndex(t); | int orient_axis = constraintModeToIndex(t); | ||||
| if (orient_axis != -1) { | if (orient_axis != -1) { | ||||
| RNA_property_enum_set(op->ptr, prop, orient_axis); | RNA_property_enum_set(op->ptr, prop, orient_axis); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| RNA_property_enum_set(op->ptr, prop, t->orient_axis); | RNA_property_enum_set(op->ptr, prop, t->orient_axis); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho"))) { | if ((prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho"))) { | ||||
| if (t->flag & T_MODAL) { | if (t->flag & T_MODAL) { | ||||
| RNA_property_enum_set(op->ptr, prop, t->orient_axis_ortho); | RNA_property_enum_set(op->ptr, prop, t->orient_axis_ortho); | ||||
| } | } | ||||
| } | } | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "orient_matrix"))) { | |||||
| if (t->flag & T_MODAL) { | |||||
| if (orientation != V3D_ORIENT_CUSTOM_MATRIX) { | |||||
| if (t->flag & T_MODAL) { | |||||
| RNA_enum_set(op->ptr, "orient_matrix_type", orientation); | |||||
| } | |||||
| } | |||||
| if (t->con.mode & CON_APPLY) { | |||||
| RNA_float_set_array(op->ptr, "orient_matrix", &t->con.mtx[0][0]); | |||||
| } | |||||
| else if (use_orient_axis) { | |||||
| RNA_float_set_array(op->ptr, "orient_matrix", &t->orient_matrix[0][0]); | |||||
| } | |||||
| else { | |||||
| RNA_float_set_array(op->ptr, "orient_matrix", &t->spacemtx[0][0]); | |||||
| } | |||||
| } | |||||
| } | |||||
| if ((prop = RNA_struct_find_property(op->ptr, "orient_type"))) { | if ((prop = RNA_struct_find_property(op->ptr, "orient_type"))) { | ||||
| /* constraint orientation can be global, even if user selects something else | short orient_set, orient_cur; | ||||
| * so use the orientation in the constraint if set */ | orient_set = RNA_property_is_set(op->ptr, prop) ? RNA_property_enum_get(op->ptr, prop) : -1; | ||||
| orient_cur = t->orientation.types[t->orientation.index]; | |||||
| if (!ELEM(orient_cur, orient_set, V3D_ORIENT_CUSTOM_MATRIX)) { | |||||
| RNA_property_enum_set(op->ptr, prop, orient_cur); | |||||
| orient_set = orient_cur; | |||||
| } | |||||
| if (((prop = RNA_struct_find_property(op->ptr, "orient_matrix_type")) && | |||||
| !RNA_property_is_set(op->ptr, prop))) { | |||||
| /* Set the first time to register on redo. */ | |||||
| RNA_property_enum_set(op->ptr, prop, orient_set); | |||||
| /* Use 'orient_matrix' instead. */ | if (((prop = RNA_struct_find_property(op->ptr, "orient_matrix")) && | ||||
| if (t->flag & T_MODAL) { | !RNA_property_is_set(op->ptr, prop))) { | ||||
| if (orientation != V3D_ORIENT_CUSTOM_MATRIX) { | RNA_float_set_array(op->ptr, "orient_matrix", &t->spacemtx[0][0]); | ||||
| RNA_property_enum_set(op->ptr, prop, orientation); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis"))) { | if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis"))) { | ||||
| if (t->con.mode & CON_APPLY) { | |||||
| bool constraint_axis[3] = {false, false, false}; | bool constraint_axis[3] = {false, false, false}; | ||||
| if (t->flag & T_MODAL) { | if (t->idx_max == 0) { | ||||
| /* Only set if needed, so we can hide in the UI when nothing is set. | /* Only set if needed, so we can hide in the UI when nothing is set. | ||||
| * See 'transform_poll_property'. */ | * See 'transform_poll_property'. */ | ||||
| if (t->con.mode & CON_APPLY) { | |||||
| if (t->con.mode & CON_AXIS0) { | if (t->con.mode & CON_AXIS0) { | ||||
| constraint_axis[0] = true; | constraint_axis[0] = true; | ||||
| } | } | ||||
| if (t->con.mode & CON_AXIS1) { | if (t->con.mode & CON_AXIS1) { | ||||
| constraint_axis[1] = true; | constraint_axis[1] = true; | ||||
| } | } | ||||
| if (t->con.mode & CON_AXIS2) { | if (t->con.mode & CON_AXIS2) { | ||||
| constraint_axis[2] = true; | constraint_axis[2] = true; | ||||
| } | } | ||||
| } | } | ||||
| if (ELEM(true, UNPACK3(constraint_axis))) { | else { | ||||
| constraint_axis[0] = true; | |||||
| constraint_axis[1] = true; | |||||
| constraint_axis[2] = true; | |||||
| } | |||||
| RNA_property_boolean_set_array(op->ptr, prop, constraint_axis); | RNA_property_boolean_set_array(op->ptr, prop, constraint_axis); | ||||
| } | } | ||||
| else { | |||||
| RNA_property_unset(op->ptr, prop); | |||||
| } | } | ||||
| } | } | ||||
| { | { | ||||
| const char *prop_id = NULL; | const char *prop_id = NULL; | ||||
| bool prop_state = true; | bool prop_state = true; | ||||
| if (t->mode == TFM_SHRINKFATTEN) { | if (t->mode == TFM_SHRINKFATTEN) { | ||||
| prop_id = "use_even_offset"; | prop_id = "use_even_offset"; | ||||
| ▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event, int mode) | ||||
| /* For gizmo only, so assume LEFTMOUSE. */ | /* For gizmo only, so assume LEFTMOUSE. */ | ||||
| if (t->launch_event == 0) { | if (t->launch_event == 0) { | ||||
| t->launch_event = LEFTMOUSE; | t->launch_event = LEFTMOUSE; | ||||
| } | } | ||||
| unit_m3(t->spacemtx); | unit_m3(t->spacemtx); | ||||
| initTransInfo(C, t, op, event); | initTransInfo(C, t, op, event); | ||||
| initTransformOrientation(C, t); | |||||
| /* Although `t->orientation.index` can be different from 0, always init the | |||||
| * default orientation so that in redo the contraint uses the `orient_matrix` */ | |||||
| initTransformOrientation(C, t, t->orientation.types[0]); | |||||
| if (t->spacetype == SPACE_VIEW3D) { | if (t->spacetype == SPACE_VIEW3D) { | ||||
| t->draw_handle_apply = ED_region_draw_cb_activate( | t->draw_handle_apply = ED_region_draw_cb_activate( | ||||
| t->region->type, drawTransformApply, t, REGION_DRAW_PRE_VIEW); | t->region->type, drawTransformApply, t, REGION_DRAW_PRE_VIEW); | ||||
| t->draw_handle_view = ED_region_draw_cb_activate( | t->draw_handle_view = ED_region_draw_cb_activate( | ||||
| t->region->type, drawTransformView, t, REGION_DRAW_POST_VIEW); | t->region->type, drawTransformView, t, REGION_DRAW_POST_VIEW); | ||||
| t->draw_handle_pixel = ED_region_draw_cb_activate( | t->draw_handle_pixel = ED_region_draw_cb_activate( | ||||
| t->region->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL); | t->region->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL); | ||||
| ▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | if ((prop = RNA_struct_find_property(op->ptr, "orient_axis")) && | ||||
| t->orient_axis = RNA_property_enum_get(op->ptr, prop); | t->orient_axis = RNA_property_enum_get(op->ptr, prop); | ||||
| } | } | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho")) && | if ((prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho")) && | ||||
| RNA_property_is_set(op->ptr, prop)) { | RNA_property_is_set(op->ptr, prop)) { | ||||
| t->orient_axis_ortho = RNA_property_enum_get(op->ptr, prop); | t->orient_axis_ortho = RNA_property_enum_get(op->ptr, prop); | ||||
| } | } | ||||
| /* Constraint init from operator */ | /* Constraint init from operator */ | ||||
| if ((t->flag & T_MODAL) || | if (t->con.mode & CON_APPLY) { | ||||
| /* For mirror operator the constraint axes are effectively the values. */ | setUserConstraint(t, t->orientation.types[t->orientation.index], t->con.mode, "%s"); | ||||
| (RNA_struct_find_property(op->ptr, "value") == NULL)) { | |||||
| if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis")) && | |||||
| RNA_property_is_set(op->ptr, prop)) { | |||||
| bool constraint_axis[3]; | |||||
| RNA_property_boolean_get_array(op->ptr, prop, constraint_axis); | |||||
| if (constraint_axis[0] || constraint_axis[1] || constraint_axis[2]) { | |||||
| t->con.mode |= CON_APPLY; | |||||
| if (constraint_axis[0]) { | |||||
| t->con.mode |= CON_AXIS0; | |||||
| } | |||||
| if (constraint_axis[1]) { | |||||
| t->con.mode |= CON_AXIS1; | |||||
| } | |||||
| if (constraint_axis[2]) { | |||||
| t->con.mode |= CON_AXIS2; | |||||
| } | |||||
| setUserConstraint(t, t->orientation.user, t->con.mode, "%s"); | |||||
| } | |||||
| } | |||||
| } | |||||
| else { | |||||
| /* So we can adjust in non global orientation. */ | |||||
| if (t->orientation.user != V3D_ORIENT_GLOBAL) { | |||||
| t->con.mode |= CON_APPLY | CON_AXIS0 | CON_AXIS1 | CON_AXIS2; | |||||
| setUserConstraint(t, t->orientation.user, t->con.mode, "%s"); | |||||
| } | |||||
| } | } | ||||
| /* Don't write into the values when non-modal because they are already set from operator redo | /* Don't write into the values when non-modal because they are already set from operator redo | ||||
| * values. */ | * values. */ | ||||
| if (t->flag & T_MODAL) { | if (t->flag & T_MODAL) { | ||||
| /* Setup the mouse input with initial values. */ | /* Setup the mouse input with initial values. */ | ||||
| applyMouseInput(t, &t->mouse, t->mouse.imval, t->values); | applyMouseInput(t, &t->mouse, t->mouse.imval, t->values); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 136 Lines • Show Last 20 Lines | |||||