Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform.c
| Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | |||||
| #include "transform.h" | #include "transform.h" | ||||
| #include "transform_constraints.h" | #include "transform_constraints.h" | ||||
| #include "transform_convert.h" | #include "transform_convert.h" | ||||
| #include "transform_draw_cursors.h" | #include "transform_draw_cursors.h" | ||||
| #include "transform_mode.h" | #include "transform_mode.h" | ||||
| #include "transform_snap.h" | #include "transform_snap.h" | ||||
| #define TRANSFORM_DEBUG_TIME | |||||
| #ifdef TRANSFORM_DEBUG_TIME | |||||
| # include "PIL_time.h" | |||||
| static struct { | |||||
| double convertion; | |||||
| double mode; | |||||
| int mode_samples; | |||||
| } g_time = {0.0, 0.0, 0}; | |||||
| #endif | |||||
| /* Disabling, since when you type you know what you are doing, | /* Disabling, since when you type you know what you are doing, | ||||
| * and being able to set it to zero is handy. */ | * and being able to set it to zero is handy. */ | ||||
| // #define USE_NUM_NO_ZERO | // #define USE_NUM_NO_ZERO | ||||
| static void drawTransformApply(const struct bContext *C, ARegion *region, void *arg); | static void drawTransformApply(const struct bContext *C, ARegion *region, void *arg); | ||||
| static void initSnapSpatial(TransInfo *t, float r_snap[3]); | static void initSnapSpatial(TransInfo *t, float r_snap[3]); | ||||
| ▲ Show 20 Lines • Show All 1,737 Lines • ▼ Show 20 Lines | |||||
| /** | /** | ||||
| * \note caller needs to free 't' on a 0 return | * \note caller needs to free 't' on a 0 return | ||||
| * \warning \a event might be NULL (when tweaking from redo panel) | * \warning \a event might be NULL (when tweaking from redo panel) | ||||
| * \see #saveTransform which writes these values back. | * \see #saveTransform which writes these values back. | ||||
| */ | */ | ||||
| bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event, int mode) | bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event, int mode) | ||||
| { | { | ||||
| #ifdef TRANSFORM_DEBUG_TIME | |||||
| double time = PIL_check_seconds_timer(); | |||||
| #endif | |||||
| int options = 0; | int options = 0; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| t->context = C; | t->context = C; | ||||
| /* added initialize, for external calls to set stuff in TransInfo, like undo string */ | /* added initialize, for external calls to set stuff in TransInfo, like undo string */ | ||||
| t->state = TRANS_STARTING; | t->state = TRANS_STARTING; | ||||
| ▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | #endif | ||||
| createTransData(C, t); // make TransData structs from selection | createTransData(C, t); // make TransData structs from selection | ||||
| if ((t->options & CTX_SCULPT) && !(t->options & CTX_PAINT_CURVE)) { | if ((t->options & CTX_SCULPT) && !(t->options & CTX_PAINT_CURVE)) { | ||||
| ED_sculpt_init_transform(C); | ED_sculpt_init_transform(C); | ||||
| } | } | ||||
| if (t->data_len_all == 0) { | if (t->data_len_all == 0) { | ||||
| #ifdef TRANSFORM_DEBUG_TIME | |||||
| g_time.convertion = PIL_check_seconds_timer() - time; | |||||
| #endif | |||||
| postTrans(C, t); | postTrans(C, t); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| if (event) { | if (event) { | ||||
| /* keymap for shortcut header prints */ | /* keymap for shortcut header prints */ | ||||
| t->keymap = WM_keymap_active(CTX_wm_manager(C), op->type->modalkeymap); | t->keymap = WM_keymap_active(CTX_wm_manager(C), op->type->modalkeymap); | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | if ((prop = RNA_struct_find_property(op->ptr, "use_accurate")) && | ||||
| } | } | ||||
| } | } | ||||
| initMouseInput(t, &t->mouse, t->center2d, event->mval, use_accurate); | initMouseInput(t, &t->mouse, t->center2d, event->mval, use_accurate); | ||||
| } | } | ||||
| transform_mode_init(t, op, mode); | transform_mode_init(t, op, mode); | ||||
| if (t->state == TRANS_CANCEL) { | if (t->state == TRANS_CANCEL) { | ||||
| #ifdef TRANSFORM_DEBUG_TIME | |||||
| g_time.convertion = PIL_check_seconds_timer() - time; | |||||
| #endif | |||||
| postTrans(C, t); | postTrans(C, t); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| /* Transformation axis from operator */ | /* Transformation axis from operator */ | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "orient_axis")) && | if ((prop = RNA_struct_find_property(op->ptr, "orient_axis")) && | ||||
| RNA_property_is_set(op->ptr, prop)) { | RNA_property_is_set(op->ptr, prop)) { | ||||
| t->orient_axis = RNA_property_enum_get(op->ptr, prop); | t->orient_axis = RNA_property_enum_get(op->ptr, prop); | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | if ((t->flag & T_EDIT) && t->obedit_type == OB_MESH) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| t->context = NULL; | t->context = NULL; | ||||
| #ifdef TRANSFORM_DEBUG_TIME | |||||
| g_time.convertion = PIL_check_seconds_timer() - time; | |||||
| #endif | |||||
| return 1; | return 1; | ||||
| } | } | ||||
| void transformApply(bContext *C, TransInfo *t) | void transformApply(bContext *C, TransInfo *t) | ||||
| { | { | ||||
| #ifdef TRANSFORM_DEBUG_TIME | |||||
| double time = PIL_check_seconds_timer(); | |||||
| #endif | |||||
| 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->transform) { | ||||
| t->transform(t, t->mval); // calls recalcData() | t->transform(t, t->mval); // calls recalcData() | ||||
| viewRedrawForce(C, t); | viewRedrawForce(C, t); | ||||
| } | } | ||||
| t->redraw = TREDRAW_NOTHING; | t->redraw = TREDRAW_NOTHING; | ||||
| } | } | ||||
| else if (t->redraw & TREDRAW_SOFT) { | else if (t->redraw & TREDRAW_SOFT) { | ||||
| viewRedrawForce(C, t); | viewRedrawForce(C, t); | ||||
| } | } | ||||
| /* 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; | ||||
| #ifdef TRANSFORM_DEBUG_TIME | |||||
| g_time.mode += PIL_check_seconds_timer() - time; | |||||
| g_time.mode_samples++; | |||||
| #endif | |||||
| } | } | ||||
| static void drawTransformApply(const bContext *C, ARegion *UNUSED(region), void *arg) | static void drawTransformApply(const bContext *C, ARegion *UNUSED(region), void *arg) | ||||
| { | { | ||||
| TransInfo *t = arg; | TransInfo *t = arg; | ||||
| if (t->redraw & TREDRAW_SOFT) { | if (t->redraw & TREDRAW_SOFT) { | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| transformApply((bContext *)C, t); | transformApply((bContext *)C, t); | ||||
| } | } | ||||
| } | } | ||||
| int transformEnd(bContext *C, TransInfo *t) | int transformEnd(bContext *C, TransInfo *t) | ||||
| { | { | ||||
| #ifdef TRANSFORM_DEBUG_TIME | |||||
| double time = PIL_check_seconds_timer(); | |||||
| #endif | |||||
| int exit_code = OPERATOR_RUNNING_MODAL; | int exit_code = OPERATOR_RUNNING_MODAL; | ||||
| t->context = C; | t->context = C; | ||||
| if (t->state != TRANS_STARTING && t->state != TRANS_RUNNING) { | if (t->state != TRANS_STARTING && t->state != TRANS_RUNNING) { | ||||
| /* handle restoring objects */ | /* handle restoring objects */ | ||||
| if (t->state == TRANS_CANCEL) { | if (t->state == TRANS_CANCEL) { | ||||
| /* exception, edge slide transformed UVs too */ | /* exception, edge slide transformed UVs too */ | ||||
| Show All 22 Lines | if (t->state != TRANS_STARTING && t->state != TRANS_RUNNING) { | ||||
| /* Free data, also handles overlap [in freeTransCustomData()]. */ | /* Free data, also handles overlap [in freeTransCustomData()]. */ | ||||
| postTrans(C, t); | postTrans(C, t); | ||||
| /* send events out for redraws */ | /* send events out for redraws */ | ||||
| viewRedrawPost(C, t); | viewRedrawPost(C, t); | ||||
| viewRedrawForce(C, t); | viewRedrawForce(C, t); | ||||
| } | |||||
| #ifdef TRANSFORM_DEBUG_TIME | |||||
| printf("TIME CONVERT: %lf\n", g_time.convertion); | |||||
| printf("TIME MODE (AVERAGE): %lf\n", g_time.mode / g_time.mode_samples); | |||||
| printf("TIME END: %lf\n", PIL_check_seconds_timer() - time); | |||||
| g_time.convertion = 0.0; | |||||
| g_time.mode = 0.0; | |||||
| g_time.mode_samples = 0; | |||||
| #endif | |||||
| } | |||||
| t->context = NULL; | t->context = NULL; | ||||
| return exit_code; | return exit_code; | ||||
| } | } | ||||
| /* TODO, move to: transform_query.c */ | /* TODO, move to: transform_query.c */ | ||||
| bool checkUseAxisMatrix(TransInfo *t) | bool checkUseAxisMatrix(TransInfo *t) | ||||
| { | { | ||||
| Show All 11 Lines | |||||