Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform.c
| Show First 20 Lines • Show All 630 Lines • ▼ Show 20 Lines | switch (value) { | ||||
| } | } | ||||
| case TFM_MODAL_AUTOIK_LEN_INC: | case TFM_MODAL_AUTOIK_LEN_INC: | ||||
| case TFM_MODAL_AUTOIK_LEN_DEC: { | case TFM_MODAL_AUTOIK_LEN_DEC: { | ||||
| if ((t->flag & T_AUTOIK) == 0) { | if ((t->flag & T_AUTOIK) == 0) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| case TFM_MODAL_EDIT_SNAPWITH: { | |||||
| if (t->spacetype != SPACE_VIEW3D) { | |||||
| return false; | |||||
| } | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| /* called in transform_ops.c, on each regeneration of keymaps */ | /* called in transform_ops.c, on each regeneration of keymaps */ | ||||
| wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) | wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) | ||||
| { | { | ||||
| static const EnumPropertyItem modal_items[] = { | static const EnumPropertyItem modal_items[] = { | ||||
| Show All 33 Lines | static const EnumPropertyItem modal_items[] = { | ||||
| 0, | 0, | ||||
| "Toggle Direction for Node Auto-Offset", | "Toggle Direction for Node Auto-Offset", | ||||
| ""}, | ""}, | ||||
| {TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Move", ""}, | {TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Move", ""}, | ||||
| {TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""}, | {TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""}, | ||||
| {TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""}, | {TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""}, | ||||
| {TFM_MODAL_AUTOCONSTRAINT, "AUTOCONSTRAIN", 0, "Automatic Constraint", ""}, | {TFM_MODAL_AUTOCONSTRAINT, "AUTOCONSTRAIN", 0, "Automatic Constraint", ""}, | ||||
| {TFM_MODAL_AUTOCONSTRAINTPLANE, "AUTOCONSTRAINPLANE", 0, "Automatic Constraint Plane", ""}, | {TFM_MODAL_AUTOCONSTRAINTPLANE, "AUTOCONSTRAINPLANE", 0, "Automatic Constraint Plane", ""}, | ||||
| {TFM_MODAL_EDIT_SNAPWITH, "EDIT_SNAPWITH", 0, "Edit snap with", ""}, | |||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
| }; | }; | ||||
| 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; | ||||
| ▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | else if (event->type == MOUSEMOVE) { | ||||
| /* Use this for soft redraw. Might cause flicker in object mode */ | /* Use this for soft redraw. Might cause flicker in object mode */ | ||||
| // t->redraw |= TREDRAW_SOFT; | // t->redraw |= TREDRAW_SOFT; | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| if (t->state == TRANS_STARTING) { | if (t->state == TRANS_STARTING) { | ||||
| t->state = TRANS_RUNNING; | t->state = TRANS_RUNNING; | ||||
| } | } | ||||
| if (!(t->modifiers & MOD_EDIT_BASEPOINT)) { | |||||
| applyMouseInput(t, &t->mouse, t->mval, t->values); | applyMouseInput(t, &t->mouse, t->mval, t->values); | ||||
| } | |||||
| /* Snapping mouse move events. */ | /* Snapping mouse move events. */ | ||||
| t->redraw |= handleSnapping(t, event); | t->redraw |= handleSnapping(t, event); | ||||
| handled = true; | handled = true; | ||||
| } | } | ||||
| /* handle modal keymap first */ | /* handle modal keymap first */ | ||||
| /* enforce redraw of transform when modifiers are used */ | /* enforce redraw of transform when modifiers are used */ | ||||
| else if (event->type == EVT_MODAL_MAP) { | else if (event->type == EVT_MODAL_MAP) { | ||||
| switch (event->val) { | switch (event->val) { | ||||
| case TFM_MODAL_CANCEL: | case TFM_MODAL_CANCEL: | ||||
| t->state = TRANS_CANCEL; | t->state = TRANS_CANCEL; | ||||
| handled = true; | handled = true; | ||||
| break; | break; | ||||
| case TFM_MODAL_CONFIRM: | case TFM_MODAL_CONFIRM: | ||||
| if (t->modifiers & MOD_EDIT_BASEPOINT) { | |||||
| tranform_snap_editbasepoint_confirm(t); | |||||
| } | |||||
| else { | |||||
| t->state = TRANS_CONFIRM; | t->state = TRANS_CONFIRM; | ||||
| } | |||||
| handled = true; | handled = true; | ||||
| break; | break; | ||||
| case TFM_MODAL_TRANSLATE: | case TFM_MODAL_TRANSLATE: | ||||
| /* only switch when... */ | /* only switch when... */ | ||||
| if (t->mode == TFM_TRANSLATION) { | if (t->mode == TFM_TRANSLATION) { | ||||
| if ((t->obedit_type == OB_MESH) && (t->spacetype == SPACE_VIEW3D)) { | if ((t->obedit_type == OB_MESH) && (t->spacetype == SPACE_VIEW3D)) { | ||||
| restoreTransObjects(t); | restoreTransObjects(t); | ||||
| resetTransModal(t); | resetTransModal(t); | ||||
| ▲ Show 20 Lines • Show All 264 Lines • ▼ Show 20 Lines | switch (event->val) { | ||||
| initSelectConstraint(t); | initSelectConstraint(t); | ||||
| postSelectConstraint(t); | postSelectConstraint(t); | ||||
| } | } | ||||
| } | } | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| handled = true; | handled = true; | ||||
| } | } | ||||
| break; | break; | ||||
| case TFM_MODAL_EDIT_SNAPWITH: | |||||
| tranform_snap_editbasepoint_toggle(t); | |||||
| break; | |||||
| /* Those two are only handled in transform's own handler, see T44634! */ | /* Those two are only handled in transform's own handler, see T44634! */ | ||||
| case TFM_MODAL_EDGESLIDE_UP: | case TFM_MODAL_EDGESLIDE_UP: | ||||
| case TFM_MODAL_EDGESLIDE_DOWN: | case TFM_MODAL_EDGESLIDE_DOWN: | ||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| /* Else do non-mapped events. */ | /* Else do non-mapped events. */ | ||||
| ▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | switch (event->type) { | ||||
| t->flag &= ~T_ALT_TRANSFORM; | t->flag &= ~T_ALT_TRANSFORM; | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| handled = true; | handled = true; | ||||
| } | } | ||||
| break; | break; | ||||
| default: { | default: { | ||||
| /* Disable modifiers. */ | /* Disable modifiers. */ | ||||
| int modifiers = t->modifiers; | int modifiers = t->modifiers; | ||||
| modifiers &= ~MOD_CONSTRAINT_SELECT; | modifiers &= ~(MOD_CONSTRAINT_SELECT | MOD_CONSTRAINT_PLANE); | ||||
| modifiers &= ~MOD_CONSTRAINT_PLANE; | |||||
| if (modifiers != t->modifiers) { | if (modifiers != t->modifiers) { | ||||
| if (t->modifiers & (MOD_CONSTRAINT_SELECT | MOD_CONSTRAINT_PLANE)) { | |||||
| postSelectConstraint(t); | postSelectConstraint(t); | ||||
| } | |||||
| t->modifiers = modifiers; | t->modifiers = modifiers; | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| handled = true; | handled = true; | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 292 Lines • ▼ Show 20 Lines | if (!(t->options & CTX_NO_PET)) { | ||||
| 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; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| #ifdef USE_SAVE_SCE_SNAP | |||||
| 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) != !(ts->snap_flag & SCE_SNAP)) { | if (!(t->modifiers & MOD_SNAP) != !(ts->snap_flag & SCE_SNAP)) { | ||||
| if (t->modifiers & MOD_SNAP) { | if (t->modifiers & MOD_SNAP) { | ||||
| ts->snap_flag |= SCE_SNAP; | ts->snap_flag |= SCE_SNAP; | ||||
| } | } | ||||
| else { | else { | ||||
| ts->snap_flag &= ~SCE_SNAP; | ts->snap_flag &= ~SCE_SNAP; | ||||
| } | } | ||||
| WM_msg_publish_rna_prop(t->mbus, &t->scene->id, ts, ToolSettings, use_snap); | WM_msg_publish_rna_prop(t->mbus, &t->scene->id, ts, ToolSettings, use_snap); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| #endif | |||||
| if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) { | if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) { | ||||
| RNA_property_boolean_set(op->ptr, prop, use_prop_edit); | RNA_property_boolean_set(op->ptr, prop, use_prop_edit); | ||||
| RNA_boolean_set(op->ptr, "use_proportional_connected", prop_edit_flag & PROP_EDIT_CONNECTED); | RNA_boolean_set(op->ptr, "use_proportional_connected", prop_edit_flag & PROP_EDIT_CONNECTED); | ||||
| RNA_boolean_set(op->ptr, "use_proportional_projected", prop_edit_flag & PROP_EDIT_PROJECTED); | RNA_boolean_set(op->ptr, "use_proportional_projected", prop_edit_flag & PROP_EDIT_PROJECTED); | ||||
| 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); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 363 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| void transformApply(bContext *C, TransInfo *t) | void transformApply(bContext *C, TransInfo *t) | ||||
| { | { | ||||
| t->context = C; | t->context = C; | ||||
| if ((t->redraw & TREDRAW_HARD) || (t->draw_handle_apply == NULL && (t->redraw & TREDRAW_SOFT))) { | if ((t->redraw & TREDRAW_HARD) || (t->draw_handle_apply == NULL && (t->redraw & TREDRAW_SOFT))) { | ||||
| selectConstraint(t); | selectConstraint(t); | ||||
| if (t->transform) { | if (t->modifiers & MOD_EDIT_BASEPOINT) { | ||||
| tranform_snap_editbasepoint_update(t); | |||||
| } | |||||
| else if (t->transform) { | |||||
| t->transform(t, t->mval); /* calls recalcData() */ | t->transform(t, t->mval); /* calls recalcData() */ | ||||
| viewRedrawForce(C, t); | t->redraw |= TREDRAW_SOFT; | ||||
| } | } | ||||
| t->redraw = TREDRAW_NOTHING; | |||||
| } | } | ||||
| else if (t->redraw & TREDRAW_SOFT) { | |||||
| if (t->redraw & TREDRAW_SOFT) { | |||||
| viewRedrawForce(C, t); | viewRedrawForce(C, t); | ||||
| t->redraw = TREDRAW_NOTHING; | |||||
| } | } | ||||
| /* If auto confirm is on, break after one pass */ | /* If auto confirm is on, break after one pass */ | ||||
| if (t->options & CTX_AUTOCONFIRM) { | if (t->options & CTX_AUTOCONFIRM) { | ||||
| t->state = TRANS_CONFIRM; | t->state = TRANS_CONFIRM; | ||||
| } | } | ||||
| t->context = NULL; | t->context = NULL; | ||||
| ▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines | |||||