Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform.c
| Show First 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | |||||
| static void drawTransformApply(const struct bContext *C, ARegion *ar, void *arg); | static void drawTransformApply(const struct bContext *C, ARegion *ar, void *arg); | ||||
| static void doEdgeSlide(TransInfo *t, float perc); | static void doEdgeSlide(TransInfo *t, float perc); | ||||
| static void doVertSlide(TransInfo *t, float perc); | static void doVertSlide(TransInfo *t, float perc); | ||||
| static void drawEdgeSlide(TransInfo *t); | static void drawEdgeSlide(TransInfo *t); | ||||
| static void drawVertSlide(TransInfo *t); | static void drawVertSlide(TransInfo *t); | ||||
| static void postInputRotation(TransInfo *t, float values[3]); | static void postInputRotation(TransInfo *t, float values[3]); | ||||
| static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], const short around); | static void ElementRotation(TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3], const short around); | ||||
| static void initSnapSpatial(TransInfo *t, float r_snap[3]); | static void initSnapSpatial(TransInfo *t, float r_snap[3]); | ||||
| /* Transform Callbacks */ | /* Transform Callbacks */ | ||||
| static void initBend(TransInfo *t); | static void initBend(TransInfo *t); | ||||
| static eRedrawFlag handleEventBend(TransInfo *t, const struct wmEvent *event); | static eRedrawFlag handleEventBend(TransInfo *t, const struct wmEvent *event); | ||||
| static void Bend(TransInfo *t, const int mval[2]); | static void Bend(TransInfo *t, const int mval[2]); | ||||
| ▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
| static void applySeqSlide(TransInfo *t, const int mval[2]); | static void applySeqSlide(TransInfo *t, const int mval[2]); | ||||
| /* end transform callbacks */ | /* end transform callbacks */ | ||||
| static bool transdata_check_local_center(TransInfo *t, short around) | static bool transdata_check_local_center(TransInfo *t, short around) | ||||
| { | { | ||||
| return ((around == V3D_AROUND_LOCAL_ORIGINS) && ( | return ((around == V3D_AROUND_LOCAL_ORIGINS) && ( | ||||
| (t->flag & (T_OBJECT | T_POSE)) || | (t->flag & (T_OBJECT | T_POSE)) || | ||||
| (t->obedit && ELEM(t->obedit->type, OB_MESH, OB_CURVE, OB_MBALL, OB_ARMATURE)) || | ((t->flag & T_EDIT) && ELEM(t->obedit_type, OB_MESH, OB_CURVE, OB_MBALL, OB_ARMATURE)) || | ||||
| (t->spacetype == SPACE_IPO) || | (t->spacetype == SPACE_IPO) || | ||||
| (t->options & (CTX_MOVIECLIP | CTX_MASK | CTX_PAINT_CURVE))) | (t->options & (CTX_MOVIECLIP | CTX_MASK | CTX_PAINT_CURVE))) | ||||
| ); | ); | ||||
| } | } | ||||
| bool transdata_check_local_islands(TransInfo *t, short around) | bool transdata_check_local_islands(TransInfo *t, short around) | ||||
| { | { | ||||
| return ((around == V3D_AROUND_LOCAL_ORIGINS) && ( | return ((around == V3D_AROUND_LOCAL_ORIGINS) && ( | ||||
| (t->obedit && ELEM(t->obedit->type, OB_MESH)))); | ((t->flag & T_EDIT) && ELEM(t->obedit_type, OB_MESH)))); | ||||
| } | } | ||||
| /* ************************** SPACE DEPENDANT CODE **************************** */ | /* ************************** SPACE DEPENDANT CODE **************************** */ | ||||
| void setTransformViewMatrices(TransInfo *t) | void setTransformViewMatrices(TransInfo *t) | ||||
| { | { | ||||
| if (t->spacetype == SPACE_VIEW3D && t->ar && t->ar->regiontype == RGN_TYPE_WINDOW) { | if (t->spacetype == SPACE_VIEW3D && t->ar && t->ar->regiontype == RGN_TYPE_WINDOW) { | ||||
| RegionView3D *rv3d = t->ar->regiondata; | RegionView3D *rv3d = t->ar->regiondata; | ||||
| copy_m4_m4(t->viewmat, rv3d->viewmat); | copy_m4_m4(t->viewmat, rv3d->viewmat); | ||||
| copy_m4_m4(t->viewinv, rv3d->viewinv); | copy_m4_m4(t->viewinv, rv3d->viewinv); | ||||
| copy_m4_m4(t->persmat, rv3d->persmat); | copy_m4_m4(t->persmat, rv3d->persmat); | ||||
| copy_m4_m4(t->persinv, rv3d->persinv); | copy_m4_m4(t->persinv, rv3d->persinv); | ||||
| t->persp = rv3d->persp; | t->persp = rv3d->persp; | ||||
| } | } | ||||
| else { | else { | ||||
| unit_m4(t->viewmat); | unit_m4(t->viewmat); | ||||
| unit_m4(t->viewinv); | unit_m4(t->viewinv); | ||||
| unit_m4(t->persmat); | unit_m4(t->persmat); | ||||
| unit_m4(t->persinv); | unit_m4(t->persinv); | ||||
| t->persp = RV3D_ORTHO; | t->persp = RV3D_ORTHO; | ||||
| } | } | ||||
| calculateCenter2D(t); | calculateCenter2D(t); | ||||
| calculateCenterLocal(t, t->center_global); | |||||
| } | } | ||||
| void setTransformViewAspect(TransInfo *t, float r_aspect[3]) | void setTransformViewAspect(TransInfo *t, float r_aspect[3]) | ||||
| { | { | ||||
| copy_v3_fl(r_aspect, 1.0f); | copy_v3_fl(r_aspect, 1.0f); | ||||
| if (t->spacetype == SPACE_IMAGE) { | if (t->spacetype == SPACE_IMAGE) { | ||||
| SpaceImage *sima = t->sa->spacedata.first; | SpaceImage *sima = t->sa->spacedata.first; | ||||
| ▲ Show 20 Lines • Show All 358 Lines • ▼ Show 20 Lines | else if (t->spacetype == SPACE_IMAGE) { | ||||
| } | } | ||||
| else if (t->options & CTX_PAINT_CURVE) { | else if (t->options & CTX_PAINT_CURVE) { | ||||
| wmWindow *window = CTX_wm_window(C); | wmWindow *window = CTX_wm_window(C); | ||||
| WM_paint_cursor_tag_redraw(window, t->ar); | WM_paint_cursor_tag_redraw(window, t->ar); | ||||
| } | } | ||||
| else { | else { | ||||
| // XXX how to deal with lock? | // XXX how to deal with lock? | ||||
| SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first; | SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first; | ||||
| if (sima->lock) WM_event_add_notifier(C, NC_GEOM | ND_DATA, t->obedit->data); | if (sima->lock) { | ||||
| else ED_area_tag_redraw(t->sa); | WM_event_add_notifier(C, NC_GEOM | ND_DATA, OBEDIT_FROM_VIEW_LAYER(t->view_layer)->data); | ||||
| } | |||||
| else { | |||||
| ED_area_tag_redraw(t->sa); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| else if (t->spacetype == SPACE_CLIP) { | else if (t->spacetype == SPACE_CLIP) { | ||||
| SpaceClip *sc = (SpaceClip *)t->sa->spacedata.first; | SpaceClip *sc = (SpaceClip *)t->sa->spacedata.first; | ||||
| if (ED_space_clip_check_show_trackedit(sc)) { | if (ED_space_clip_check_show_trackedit(sc)) { | ||||
| MovieClip *clip = ED_space_clip_get_clip(sc); | MovieClip *clip = ED_space_clip_get_clip(sc); | ||||
| ▲ Show 20 Lines • Show All 387 Lines • ▼ Show 20 Lines | switch (event->val) { | ||||
| handled = true; | handled = true; | ||||
| } | } | ||||
| else if (t->mode == TFM_SEQ_SLIDE) { | else if (t->mode == TFM_SEQ_SLIDE) { | ||||
| t->flag ^= T_ALT_TRANSFORM; | t->flag ^= T_ALT_TRANSFORM; | ||||
| t->redraw |= TREDRAW_HARD; | t->redraw |= TREDRAW_HARD; | ||||
| handled = true; | handled = true; | ||||
| } | } | ||||
| else { | else { | ||||
| if (t->obedit && t->obedit->type == OB_MESH) { | if (t->obedit_type == OB_MESH) { | ||||
| if ((t->mode == TFM_TRANSLATION) && (t->spacetype == SPACE_VIEW3D)) { | if ((t->mode == TFM_TRANSLATION) && (t->spacetype == SPACE_VIEW3D)) { | ||||
| restoreTransObjects(t); | restoreTransObjects(t); | ||||
| resetTransModal(t); | resetTransModal(t); | ||||
| resetTransRestrictions(t); | resetTransRestrictions(t); | ||||
| /* first try edge slide */ | /* first try edge slide */ | ||||
| initEdgeSlide(t); | initEdgeSlide(t); | ||||
| /* if that fails, do vertex slide */ | /* if that fails, do vertex slide */ | ||||
| ▲ Show 20 Lines • Show All 529 Lines • ▼ Show 20 Lines | bool calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], float cent2d[2]) | ||||
| /* avoid doing connectivity lookups (when V3D_AROUND_LOCAL_ORIGINS is set) */ | /* avoid doing connectivity lookups (when V3D_AROUND_LOCAL_ORIGINS is set) */ | ||||
| t->around = V3D_AROUND_CENTER_BOUNDS; | t->around = V3D_AROUND_CENTER_BOUNDS; | ||||
| createTransData(C, t); // make TransData structs from selection | createTransData(C, t); // make TransData structs from selection | ||||
| t->around = centerMode; // override userdefined mode | t->around = centerMode; // override userdefined mode | ||||
| if (t->total == 0) { | if (t->data_len_all == 0) { | ||||
| success = false; | success = false; | ||||
| } | } | ||||
| else { | else { | ||||
| success = true; | success = true; | ||||
| calculateCenter(t); | calculateCenter(t); | ||||
| if (cent2d) { | if (cent2d) { | ||||
| ▲ Show 20 Lines • Show All 384 Lines • ▼ Show 20 Lines | if ((t->flag & T_MODAL) || (op->flag & OP_IS_REPEAT)) { | ||||
| if (!(t->options & CTX_NO_PET)) { | if (!(t->options & CTX_NO_PET)) { | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "proportional")) && | if ((prop = RNA_struct_find_property(op->ptr, "proportional")) && | ||||
| !RNA_property_is_set(op->ptr, prop)) | !RNA_property_is_set(op->ptr, prop)) | ||||
| { | { | ||||
| if (t->spacetype == SPACE_IPO) | if (t->spacetype == SPACE_IPO) | ||||
| ts->proportional_fcurve = proportional; | ts->proportional_fcurve = proportional; | ||||
| else if (t->spacetype == SPACE_ACTION) | else if (t->spacetype == SPACE_ACTION) | ||||
| ts->proportional_action = proportional; | ts->proportional_action = proportional; | ||||
| else if (t->obedit) | else if (t->flag & T_EDIT) | ||||
| ts->proportional = proportional; | ts->proportional = proportional; | ||||
| else if (t->options & CTX_MASK) | else if (t->options & CTX_MASK) | ||||
| ts->proportional_mask = (proportional != PROP_EDIT_OFF); | ts->proportional_mask = (proportional != PROP_EDIT_OFF); | ||||
| else | else | ||||
| ts->proportional_objects = (proportional != PROP_EDIT_OFF); | ts->proportional_objects = (proportional != PROP_EDIT_OFF); | ||||
| } | } | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "proportional_size"))) { | if ((prop = RNA_struct_find_property(op->ptr, "proportional_size"))) { | ||||
| ▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event, int mode) | ||||
| else if (t->spacetype == SPACE_ACTION) { | else if (t->spacetype == SPACE_ACTION) { | ||||
| t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); | t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); | ||||
| //t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL); | //t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL); | ||||
| t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t); | t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t); | ||||
| } | } | ||||
| createTransData(C, t); // make TransData structs from selection | createTransData(C, t); // make TransData structs from selection | ||||
| if (t->total == 0) { | if (t->data_len_all == 0) { | ||||
| 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 87 Lines • ▼ Show 20 Lines | switch (mode) { | ||||
| case TFM_PUSHPULL: | case TFM_PUSHPULL: | ||||
| initPushPull(t); | initPushPull(t); | ||||
| break; | break; | ||||
| case TFM_CREASE: | case TFM_CREASE: | ||||
| initCrease(t); | initCrease(t); | ||||
| break; | break; | ||||
| case TFM_BONESIZE: | case TFM_BONESIZE: | ||||
| { /* used for both B-Bone width (bonesize) as for deform-dist (envelope) */ | { /* used for both B-Bone width (bonesize) as for deform-dist (envelope) */ | ||||
| bArmature *arm = t->poseobj->data; | /* Note: we have to pick one, use the active object. */ | ||||
| TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_OK(t); | |||||
| bArmature *arm = tc->poseobj->data; | |||||
| if (arm->drawtype == ARM_ENVELOPE) { | if (arm->drawtype == ARM_ENVELOPE) { | ||||
| initBoneEnvelope(t); | initBoneEnvelope(t); | ||||
| t->mode = TFM_BONE_ENVELOPE_DIST; | t->mode = TFM_BONE_ENVELOPE_DIST; | ||||
| } | } | ||||
| else { | else { | ||||
| initBoneSize(t); | initBoneSize(t); | ||||
| } | } | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 628 Lines • ▼ Show 20 Lines | static void initBend(TransInfo *t) | ||||
| t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS); | t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS); | ||||
| t->num.unit_type[0] = B_UNIT_ROTATION; | t->num.unit_type[0] = B_UNIT_ROTATION; | ||||
| t->num.unit_type[1] = B_UNIT_LENGTH; | t->num.unit_type[1] = B_UNIT_LENGTH; | ||||
| t->flag |= T_NO_CONSTRAINT; | t->flag |= T_NO_CONSTRAINT; | ||||
| //copy_v3_v3(t->center, ED_view3d_cursor3d_get(t->scene, t->view)); | //copy_v3_v3(t->center, ED_view3d_cursor3d_get(t->scene, t->view)); | ||||
| if ((t->flag & T_OVERRIDE_CENTER) == 0) { | if ((t->flag & T_OVERRIDE_CENTER) == 0) { | ||||
| calculateCenterCursor(t, t->center); | calculateCenterCursor(t, t->center_global); | ||||
| } | } | ||||
| calculateCenterGlobal(t, t->center, t->center_global); | calculateCenterLocal(t, t->center_global); | ||||
| t->val = 0.0f; | t->val = 0.0f; | ||||
| data = MEM_callocN(sizeof(*data), __func__); | data = MEM_callocN(sizeof(*data), __func__); | ||||
| curs = ED_view3d_cursor3d_get(t->scene, t->view); | curs = ED_view3d_cursor3d_get(t->scene, t->view); | ||||
| copy_v3_v3(data->warp_sta, curs); | copy_v3_v3(data->warp_sta, curs); | ||||
| ED_view3d_win_to_3d(t->sa->spacedata.first, t->ar, curs, mval_fl, data->warp_end); | ED_view3d_win_to_3d(t->sa->spacedata.first, t->ar, curs, mval_fl, data->warp_end); | ||||
| copy_v3_v3(data->warp_nor, t->viewinv[2]); | copy_v3_v3(data->warp_nor, t->viewinv[2]); | ||||
| if (t->flag & T_EDIT) { | |||||
| sub_v3_v3(data->warp_sta, t->obedit->obmat[3]); | |||||
| sub_v3_v3(data->warp_end, t->obedit->obmat[3]); | |||||
| } | |||||
| normalize_v3(data->warp_nor); | normalize_v3(data->warp_nor); | ||||
| /* tangent */ | /* tangent */ | ||||
| sub_v3_v3v3(tvec, data->warp_end, data->warp_sta); | sub_v3_v3v3(tvec, data->warp_end, data->warp_sta); | ||||
| cross_v3_v3v3(data->warp_tan, tvec, data->warp_nor); | cross_v3_v3v3(data->warp_tan, tvec, data->warp_nor); | ||||
| normalize_v3(data->warp_tan); | normalize_v3(data->warp_tan); | ||||
| data->warp_init_dist = len_v3v3(data->warp_end, data->warp_sta); | data->warp_init_dist = len_v3v3(data->warp_end, data->warp_sta); | ||||
| Show All 10 Lines | if (event->type == MIDDLEMOUSE && event->val == KM_PRESS) { | ||||
| status = TREDRAW_HARD; | status = TREDRAW_HARD; | ||||
| } | } | ||||
| return status; | return status; | ||||
| } | } | ||||
| static void Bend(TransInfo *t, const int UNUSED(mval[2])) | static void Bend(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| TransData *td = t->data; | |||||
| float vec[3]; | float vec[3]; | ||||
| float pivot[3]; | float pivot[3]; | ||||
| float warp_end_radius[3]; | float warp_end_radius[3]; | ||||
| int i; | int i; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| const struct BendCustomData *data = t->custom.mode.data; | const struct BendCustomData *data = t->custom.mode.data; | ||||
| const bool is_clamp = (t->flag & T_ALT_TRANSFORM) == 0; | const bool is_clamp = (t->flag & T_ALT_TRANSFORM) == 0; | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | #endif | ||||
| copy_v3_v3(pivot, data->warp_sta); | copy_v3_v3(pivot, data->warp_sta); | ||||
| if (values.angle > 0.0f) { | if (values.angle > 0.0f) { | ||||
| madd_v3_v3fl(pivot, data->warp_tan, -values.scale * shell_angle_to_dist((float)M_PI_2 - values.angle)); | madd_v3_v3fl(pivot, data->warp_tan, -values.scale * shell_angle_to_dist((float)M_PI_2 - values.angle)); | ||||
| } | } | ||||
| else { | else { | ||||
| madd_v3_v3fl(pivot, data->warp_tan, +values.scale * shell_angle_to_dist((float)M_PI_2 + values.angle)); | madd_v3_v3fl(pivot, data->warp_tan, +values.scale * shell_angle_to_dist((float)M_PI_2 + values.angle)); | ||||
| } | } | ||||
| for (i = 0; i < t->total; i++, td++) { | /* TODO(campbell): xform, compensate object center. */ | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | |||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| float mat[3][3]; | float mat[3][3]; | ||||
| float delta[3]; | float delta[3]; | ||||
| float fac, fac_scaled; | float fac, fac_scaled; | ||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| Show All 23 Lines | for (i = 0; i < tc->data_len; i++, td++) { | ||||
| sub_v3_v3(vec, pivot); | sub_v3_v3(vec, pivot); | ||||
| mul_m3_v3(mat, vec); | mul_m3_v3(mat, vec); | ||||
| add_v3_v3(vec, pivot); | add_v3_v3(vec, pivot); | ||||
| mul_m3_v3(td->smtx, vec); | mul_m3_v3(td->smtx, vec); | ||||
| /* rotation */ | /* rotation */ | ||||
| if ((t->flag & T_POINTS) == 0) { | if ((t->flag & T_POINTS) == 0) { | ||||
| ElementRotation(t, td, mat, V3D_AROUND_LOCAL_ORIGINS); | ElementRotation(t, tc, td, mat, V3D_AROUND_LOCAL_ORIGINS); | ||||
| } | } | ||||
| /* location */ | /* location */ | ||||
| copy_v3_v3(td->loc, vec); | copy_v3_v3(td->loc, vec); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_headerprint(t->sa, str); | ED_area_headerprint(t->sa, str); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| Show All 21 Lines | static void initShear(TransInfo *t) | ||||
| t->num.unit_type[0] = B_UNIT_NONE; /* Don't think we have any unit here? */ | t->num.unit_type[0] = B_UNIT_NONE; /* Don't think we have any unit here? */ | ||||
| t->flag |= T_NO_CONSTRAINT; | t->flag |= T_NO_CONSTRAINT; | ||||
| } | } | ||||
| static eRedrawFlag handleEventShear(TransInfo *t, const wmEvent *event) | static eRedrawFlag handleEventShear(TransInfo *t, const wmEvent *event) | ||||
| { | { | ||||
| eRedrawFlag status = TREDRAW_NOTHING; | eRedrawFlag status = TREDRAW_NOTHING; | ||||
| if (event->type == MIDDLEMOUSE && event->val == KM_PRESS) { | if (event->type == MIDDLEMOUSE && event->val == KM_PRESS) { | ||||
| /* Use custom.mode.data pointer to signal Shear direction */ | /* Use custom.mode.data pointer to signal Shear direction */ | ||||
| if (t->custom.mode.data == NULL) { | if (t->custom.mode.data == NULL) { | ||||
| initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_RATIO); | initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_RATIO); | ||||
| t->custom.mode.data = (void *)1; | t->custom.mode.data = (void *)1; | ||||
| } | } | ||||
| else { | else { | ||||
| initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO); | initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO); | ||||
| t->custom.mode.data = NULL; | t->custom.mode.data = NULL; | ||||
| } | } | ||||
| status = TREDRAW_HARD; | status = TREDRAW_HARD; | ||||
| } | } | ||||
| else if (event->type == XKEY && event->val == KM_PRESS) { | else if (event->type == XKEY && event->val == KM_PRESS) { | ||||
| initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO); | initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO); | ||||
| t->custom.mode.data = NULL; | t->custom.mode.data = NULL; | ||||
| status = TREDRAW_HARD; | status = TREDRAW_HARD; | ||||
| } | } | ||||
| else if (event->type == YKEY && event->val == KM_PRESS) { | else if (event->type == YKEY && event->val == KM_PRESS) { | ||||
| initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_RATIO); | initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_RATIO); | ||||
| t->custom.mode.data = (void *)1; | t->custom.mode.data = (void *)1; | ||||
| status = TREDRAW_HARD; | status = TREDRAW_HARD; | ||||
| } | } | ||||
| return status; | return status; | ||||
| } | } | ||||
| static void applyShear(TransInfo *t, const int UNUSED(mval[2])) | static void applyShear(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| TransData *td = t->data; | |||||
| float vec[3]; | float vec[3]; | ||||
| float smat[3][3], tmat[3][3], totmat[3][3], persmat[3][3], persinv[3][3]; | float smat[3][3], tmat[3][3], totmat[3][3], persmat[3][3], persinv[3][3]; | ||||
| float value; | float value; | ||||
| int i; | int i; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| const bool is_local_center = transdata_check_local_center(t, t->around); | const bool is_local_center = transdata_check_local_center(t, t->around); | ||||
| copy_m3_m4(persmat, t->viewmat); | copy_m3_m4(persmat, t->viewmat); | ||||
| Show All 26 Lines | static void applyShear(TransInfo *t, const int UNUSED(mval[2])) | ||||
| if (t->custom.mode.data == NULL) | if (t->custom.mode.data == NULL) | ||||
| smat[1][0] = value; | smat[1][0] = value; | ||||
| else | else | ||||
| smat[0][1] = value; | smat[0][1] = value; | ||||
| mul_m3_m3m3(tmat, smat, persmat); | mul_m3_m3m3(tmat, smat, persmat); | ||||
| mul_m3_m3m3(totmat, persinv, tmat); | mul_m3_m3m3(totmat, persinv, tmat); | ||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| const float *center, *co; | const float *center, *co; | ||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| if (t->obedit) { | if (t->flag & T_EDIT) { | ||||
| float mat3[3][3]; | float mat3[3][3]; | ||||
| mul_m3_m3m3(mat3, totmat, td->mtx); | mul_m3_m3m3(mat3, totmat, td->mtx); | ||||
| mul_m3_m3m3(tmat, td->smtx, mat3); | mul_m3_m3m3(tmat, td->smtx, mat3); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_m3_m3(tmat, totmat); | copy_m3_m3(tmat, totmat); | ||||
| } | } | ||||
| if (is_local_center) { | if (is_local_center) { | ||||
| center = td->center; | center = td->center; | ||||
| co = td->loc; | co = td->loc; | ||||
| } | } | ||||
| else { | else { | ||||
| center = t->center; | center = tc->center_local; | ||||
| co = td->center; | co = td->center; | ||||
| } | } | ||||
| sub_v3_v3v3(vec, co, center); | sub_v3_v3v3(vec, co, center); | ||||
| mul_m3_v3(tmat, vec); | mul_m3_v3(tmat, vec); | ||||
| add_v3_v3(vec, center); | add_v3_v3(vec, center); | ||||
| sub_v3_v3(vec, co); | sub_v3_v3(vec, co); | ||||
| mul_v3_fl(vec, td->factor); | mul_v3_fl(vec, td->factor); | ||||
| add_v3_v3v3(td->loc, td->iloc, vec); | add_v3_v3v3(td->loc, td->iloc, vec); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_headerprint(t->sa, str); | ED_area_headerprint(t->sa, str); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| Show All 9 Lines | static void initResize(TransInfo *t) | ||||
| initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP); | initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP); | ||||
| t->flag |= T_NULL_ONE; | t->flag |= T_NULL_ONE; | ||||
| t->num.val_flag[0] |= NUM_NULL_ONE; | t->num.val_flag[0] |= NUM_NULL_ONE; | ||||
| t->num.val_flag[1] |= NUM_NULL_ONE; | t->num.val_flag[1] |= NUM_NULL_ONE; | ||||
| t->num.val_flag[2] |= NUM_NULL_ONE; | t->num.val_flag[2] |= NUM_NULL_ONE; | ||||
| t->num.flag |= NUM_AFFECT_ALL; | t->num.flag |= NUM_AFFECT_ALL; | ||||
| if (!t->obedit) { | if (t->flag & T_EDIT) { | ||||
| t->flag |= T_NO_ZERO; | t->flag |= T_NO_ZERO; | ||||
| #ifdef USE_NUM_NO_ZERO | #ifdef USE_NUM_NO_ZERO | ||||
| t->num.val_flag[0] |= NUM_NO_ZERO; | t->num.val_flag[0] |= NUM_NO_ZERO; | ||||
| t->num.val_flag[1] |= NUM_NO_ZERO; | t->num.val_flag[1] |= NUM_NO_ZERO; | ||||
| t->num.val_flag[2] |= NUM_NO_ZERO; | t->num.val_flag[2] |= NUM_NO_ZERO; | ||||
| #endif | #endif | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | static void TransMat3ToSize(float mat[3][3], float smat[3][3], float size[3]) | ||||
| mat3_to_rot_size(rmat, size, mat); | mat3_to_rot_size(rmat, size, mat); | ||||
| /* first tried with dotproduct... but the sign flip is crucial */ | /* first tried with dotproduct... but the sign flip is crucial */ | ||||
| if (dot_v3v3(rmat[0], smat[0]) < 0.0f) size[0] = -size[0]; | if (dot_v3v3(rmat[0], smat[0]) < 0.0f) size[0] = -size[0]; | ||||
| if (dot_v3v3(rmat[1], smat[1]) < 0.0f) size[1] = -size[1]; | if (dot_v3v3(rmat[1], smat[1]) < 0.0f) size[1] = -size[1]; | ||||
| if (dot_v3v3(rmat[2], smat[2]) < 0.0f) size[2] = -size[2]; | if (dot_v3v3(rmat[2], smat[2]) < 0.0f) size[2] = -size[2]; | ||||
| } | } | ||||
| static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) | static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3]) | ||||
| { | { | ||||
| float tmat[3][3], smat[3][3], center[3]; | float tmat[3][3], smat[3][3], center[3]; | ||||
| float vec[3]; | float vec[3]; | ||||
| if (t->flag & T_EDIT) { | if (t->flag & T_EDIT) { | ||||
| mul_m3_m3m3(smat, mat, td->mtx); | mul_m3_m3m3(smat, mat, td->mtx); | ||||
| mul_m3_m3m3(tmat, td->smtx, smat); | mul_m3_m3m3(tmat, td->smtx, smat); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_m3_m3(tmat, mat); | copy_m3_m3(tmat, mat); | ||||
| } | } | ||||
| if (t->con.applySize) { | if (t->con.applySize) { | ||||
| t->con.applySize(t, td, tmat); | t->con.applySize(t, tc, td, tmat); | ||||
| } | } | ||||
| /* local constraint shouldn't alter center */ | /* local constraint shouldn't alter center */ | ||||
| if (transdata_check_local_center(t, t->around)) { | if (transdata_check_local_center(t, t->around)) { | ||||
| copy_v3_v3(center, td->center); | copy_v3_v3(center, td->center); | ||||
| } | } | ||||
| else if (t->options & CTX_MOVIECLIP) { | else if (t->options & CTX_MOVIECLIP) { | ||||
| if (td->flag & TD_INDIVIDUAL_SCALE) { | if (td->flag & TD_INDIVIDUAL_SCALE) { | ||||
| copy_v3_v3(center, td->center); | copy_v3_v3(center, td->center); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v3_v3(center, t->center); | copy_v3_v3(center, tc->center_local); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v3_v3(center, t->center); | copy_v3_v3(center, tc->center_local); | ||||
| } | } | ||||
| if (td->ext) { | if (td->ext) { | ||||
| float fsize[3]; | float fsize[3]; | ||||
| if (t->flag & (T_OBJECT | T_TEXTURE | T_POSE)) { | if (t->flag & (T_OBJECT | T_TEXTURE | T_POSE)) { | ||||
| float obsizemat[3][3]; | float obsizemat[3][3]; | ||||
| /* Reorient the size mat to fit the oriented object. */ | /* Reorient the size mat to fit the oriented object. */ | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | if (td->loc) { | ||||
| add_v3_v3v3(td->loc, td->iloc, vec); | add_v3_v3v3(td->loc, td->iloc, vec); | ||||
| } | } | ||||
| constraintTransLim(t, td); | constraintTransLim(t, td); | ||||
| } | } | ||||
| static void applyResize(TransInfo *t, const int UNUSED(mval[2])) | static void applyResize(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| TransData *td; | |||||
| float mat[3][3]; | float mat[3][3]; | ||||
| int i; | int i; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| if (t->flag & T_AUTOVALUES) { | if (t->flag & T_AUTOVALUES) { | ||||
| copy_v3_v3(t->values, t->auto_values); | copy_v3_v3(t->values, t->auto_values); | ||||
| } | } | ||||
| else { | else { | ||||
| float ratio = t->values[0]; | float ratio = t->values[0]; | ||||
| copy_v3_fl(t->values, ratio); | copy_v3_fl(t->values, ratio); | ||||
| snapGridIncrement(t, t->values); | snapGridIncrement(t, t->values); | ||||
| if (applyNumInput(&t->num, t->values)) { | if (applyNumInput(&t->num, t->values)) { | ||||
| constraintNumInput(t, t->values); | constraintNumInput(t, t->values); | ||||
| } | } | ||||
| applySnapping(t, t->values); | applySnapping(t, t->values); | ||||
| } | } | ||||
| size_to_mat3(mat, t->values); | size_to_mat3(mat, t->values); | ||||
| if (t->con.applySize) { | if (t->con.applySize) { | ||||
| t->con.applySize(t, NULL, mat); | t->con.applySize(t, NULL, NULL, mat); | ||||
| } | } | ||||
| copy_m3_m3(t->mat, mat); // used in manipulator | copy_m3_m3(t->mat, mat); // used in manipulator | ||||
| headerResize(t, t->values, str); | headerResize(t, t->values, str); | ||||
| for (i = 0, td = t->data; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| ElementResize(t, td, mat); | ElementResize(t, tc, td, mat); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| /* evil hack - redo resize if cliping needed */ | /* evil hack - redo resize if cliping needed */ | ||||
| if (t->flag & T_CLIP_UV && clipUVTransform(t, t->values, 1)) { | if (t->flag & T_CLIP_UV && clipUVTransform(t, t->values, 1)) { | ||||
| size_to_mat3(mat, t->values); | size_to_mat3(mat, t->values); | ||||
| if (t->con.applySize) | if (t->con.applySize) | ||||
| t->con.applySize(t, NULL, mat); | t->con.applySize(t, NULL, NULL, mat); | ||||
| for (i = 0, td = t->data; i < t->total; i++, td++) | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| ElementResize(t, td, mat); | TransData *td = tc->data; | ||||
| for (i = 0; i < tc->data_len; i++, td++) | |||||
| ElementResize(t, tc, td, mat); | |||||
| /* In proportional edit it can happen that */ | /* In proportional edit it can happen that */ | ||||
| /* vertices in the radius of the brush end */ | /* vertices in the radius of the brush end */ | ||||
| /* outside the clipping area */ | /* outside the clipping area */ | ||||
| /* XXX HACK - dg */ | /* XXX HACK - dg */ | ||||
| if (t->flag & T_PROP_EDIT_ALL) { | if (t->flag & T_PROP_EDIT_ALL) { | ||||
| clipUVData(t); | clipUVData(t); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_headerprint(t->sa, str); | ED_area_headerprint(t->sa, str); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| Show All 11 Lines | static void initSkinResize(TransInfo *t) | ||||
| initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP); | initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP); | ||||
| t->flag |= T_NULL_ONE; | t->flag |= T_NULL_ONE; | ||||
| t->num.val_flag[0] |= NUM_NULL_ONE; | t->num.val_flag[0] |= NUM_NULL_ONE; | ||||
| t->num.val_flag[1] |= NUM_NULL_ONE; | t->num.val_flag[1] |= NUM_NULL_ONE; | ||||
| t->num.val_flag[2] |= NUM_NULL_ONE; | t->num.val_flag[2] |= NUM_NULL_ONE; | ||||
| t->num.flag |= NUM_AFFECT_ALL; | t->num.flag |= NUM_AFFECT_ALL; | ||||
| if (!t->obedit) { | if ((t->flag & T_EDIT) == 0) { | ||||
| t->flag |= T_NO_ZERO; | t->flag |= T_NO_ZERO; | ||||
| #ifdef USE_NUM_NO_ZERO | #ifdef USE_NUM_NO_ZERO | ||||
| t->num.val_flag[0] |= NUM_NO_ZERO; | t->num.val_flag[0] |= NUM_NO_ZERO; | ||||
| t->num.val_flag[1] |= NUM_NO_ZERO; | t->num.val_flag[1] |= NUM_NO_ZERO; | ||||
| t->num.val_flag[2] |= NUM_NO_ZERO; | t->num.val_flag[2] |= NUM_NO_ZERO; | ||||
| #endif | #endif | ||||
| } | } | ||||
| t->idx_max = 2; | t->idx_max = 2; | ||||
| t->num.idx_max = 2; | t->num.idx_max = 2; | ||||
| t->snap[0] = 0.0f; | t->snap[0] = 0.0f; | ||||
| t->snap[1] = 0.1f; | t->snap[1] = 0.1f; | ||||
| t->snap[2] = t->snap[1] * 0.1f; | t->snap[2] = t->snap[1] * 0.1f; | ||||
| copy_v3_fl(t->num.val_inc, t->snap[1]); | copy_v3_fl(t->num.val_inc, t->snap[1]); | ||||
| t->num.unit_sys = t->scene->unit.system; | t->num.unit_sys = t->scene->unit.system; | ||||
| t->num.unit_type[0] = B_UNIT_NONE; | t->num.unit_type[0] = B_UNIT_NONE; | ||||
| t->num.unit_type[1] = B_UNIT_NONE; | t->num.unit_type[1] = B_UNIT_NONE; | ||||
| t->num.unit_type[2] = B_UNIT_NONE; | t->num.unit_type[2] = B_UNIT_NONE; | ||||
| } | } | ||||
| static void applySkinResize(TransInfo *t, const int UNUSED(mval[2])) | static void applySkinResize(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| TransData *td; | |||||
| float size[3], mat[3][3]; | float size[3], mat[3][3]; | ||||
| int i; | int i; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| copy_v3_fl(size, t->values[0]); | copy_v3_fl(size, t->values[0]); | ||||
| snapGridIncrement(t, size); | snapGridIncrement(t, size); | ||||
| if (applyNumInput(&t->num, size)) { | if (applyNumInput(&t->num, size)) { | ||||
| constraintNumInput(t, size); | constraintNumInput(t, size); | ||||
| } | } | ||||
| applySnapping(t, size); | applySnapping(t, size); | ||||
| if (t->flag & T_AUTOVALUES) { | if (t->flag & T_AUTOVALUES) { | ||||
| copy_v3_v3(size, t->auto_values); | copy_v3_v3(size, t->auto_values); | ||||
| } | } | ||||
| copy_v3_v3(t->values, size); | copy_v3_v3(t->values, size); | ||||
| size_to_mat3(mat, size); | size_to_mat3(mat, size); | ||||
| headerResize(t, size, str); | headerResize(t, size, str); | ||||
| for (i = 0, td = t->data; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| float tmat[3][3], smat[3][3]; | float tmat[3][3], smat[3][3]; | ||||
| float fsize[3]; | float fsize[3]; | ||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| if (t->flag & T_EDIT) { | if (t->flag & T_EDIT) { | ||||
| mul_m3_m3m3(smat, mat, td->mtx); | mul_m3_m3m3(smat, mat, td->mtx); | ||||
| mul_m3_m3m3(tmat, td->smtx, smat); | mul_m3_m3m3(tmat, td->smtx, smat); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_m3_m3(tmat, mat); | copy_m3_m3(tmat, mat); | ||||
| } | } | ||||
| if (t->con.applySize) { | if (t->con.applySize) { | ||||
| t->con.applySize(t, NULL, tmat); | t->con.applySize(t, NULL, NULL, tmat); | ||||
| } | } | ||||
| mat3_to_size(fsize, tmat); | mat3_to_size(fsize, tmat); | ||||
| td->val[0] = td->ext->isize[0] * (1 + (fsize[0] - 1) * td->factor); | td->val[0] = td->ext->isize[0] * (1 + (fsize[0] - 1) * td->factor); | ||||
| td->val[1] = td->ext->isize[1] * (1 + (fsize[1] - 1) * td->factor); | td->val[1] = td->ext->isize[1] * (1 + (fsize[1] - 1) * td->factor); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_headerprint(t->sa, str); | ED_area_headerprint(t->sa, str); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /* Transform (ToSphere) */ | /* Transform (ToSphere) */ | ||||
| /** \name Transform ToSphere | /** \name Transform ToSphere | ||||
| * \{ */ | * \{ */ | ||||
| static void initToSphere(TransInfo *t) | static void initToSphere(TransInfo *t) | ||||
| { | { | ||||
| TransData *td = t->data; | |||||
| int i; | int i; | ||||
| t->mode = TFM_TOSPHERE; | t->mode = TFM_TOSPHERE; | ||||
| t->transform = applyToSphere; | t->transform = applyToSphere; | ||||
| initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO); | initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO); | ||||
| t->idx_max = 0; | t->idx_max = 0; | ||||
| t->num.idx_max = 0; | t->num.idx_max = 0; | ||||
| t->snap[0] = 0.0f; | t->snap[0] = 0.0f; | ||||
| t->snap[1] = 0.1f; | t->snap[1] = 0.1f; | ||||
| t->snap[2] = t->snap[1] * 0.1f; | t->snap[2] = t->snap[1] * 0.1f; | ||||
| copy_v3_fl(t->num.val_inc, t->snap[1]); | copy_v3_fl(t->num.val_inc, t->snap[1]); | ||||
| t->num.unit_sys = t->scene->unit.system; | t->num.unit_sys = t->scene->unit.system; | ||||
| t->num.unit_type[0] = B_UNIT_NONE; | t->num.unit_type[0] = B_UNIT_NONE; | ||||
| t->num.val_flag[0] |= NUM_NULL_ONE | NUM_NO_NEGATIVE; | t->num.val_flag[0] |= NUM_NULL_ONE | NUM_NO_NEGATIVE; | ||||
| t->flag |= T_NO_CONSTRAINT; | t->flag |= T_NO_CONSTRAINT; | ||||
| // Calculate average radius | // Calculate average radius | ||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| t->val += len_v3v3(t->center, td->iloc); | TransData *td = tc->data; | ||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| t->val += len_v3v3(tc->center_local, td->iloc); | |||||
| } | } | ||||
| } // FIXME(indent) | |||||
| t->val /= (float)t->total; | t->val /= (float)t->data_len_all; | ||||
| } | } | ||||
| static void applyToSphere(TransInfo *t, const int UNUSED(mval[2])) | static void applyToSphere(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| float vec[3]; | float vec[3]; | ||||
| float ratio, radius; | float ratio, radius; | ||||
| int i; | int i; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| TransData *td = t->data; | |||||
| ratio = t->values[0]; | ratio = t->values[0]; | ||||
| snapGridIncrement(t, &ratio); | snapGridIncrement(t, &ratio); | ||||
| applyNumInput(&t->num, &ratio); | applyNumInput(&t->num, &ratio); | ||||
| CLAMP(ratio, 0.0f, 1.0f); | CLAMP(ratio, 0.0f, 1.0f); | ||||
| t->values[0] = ratio; | t->values[0] = ratio; | ||||
| /* header print for NumInput */ | /* header print for NumInput */ | ||||
| if (hasNumInput(&t->num)) { | if (hasNumInput(&t->num)) { | ||||
| char c[NUM_STR_REP_LEN]; | char c[NUM_STR_REP_LEN]; | ||||
| outputNumInput(&(t->num), c, &t->scene->unit); | outputNumInput(&(t->num), c, &t->scene->unit); | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("To Sphere: %s %s"), c, t->proptext); | BLI_snprintf(str, sizeof(str), IFACE_("To Sphere: %s %s"), c, t->proptext); | ||||
| } | } | ||||
| else { | else { | ||||
| /* default header print */ | /* default header print */ | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("To Sphere: %.4f %s"), ratio, t->proptext); | BLI_snprintf(str, sizeof(str), IFACE_("To Sphere: %.4f %s"), ratio, t->proptext); | ||||
| } | } | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | |||||
| for (i = 0; i < t->total; i++, td++) { | TransData *td = tc->data; | ||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| float tratio; | float tratio; | ||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| sub_v3_v3v3(vec, td->iloc, t->center); | sub_v3_v3v3(vec, td->iloc, tc->center_local); | ||||
| radius = normalize_v3(vec); | radius = normalize_v3(vec); | ||||
| tratio = ratio * td->factor; | tratio = ratio * td->factor; | ||||
| mul_v3_fl(vec, radius * (1.0f - tratio) + t->val * tratio); | mul_v3_fl(vec, radius * (1.0f - tratio) + t->val * tratio); | ||||
| add_v3_v3v3(td->loc, t->center, vec); | add_v3_v3v3(td->loc, tc->center_local, vec); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_headerprint(t->sa, str); | ED_area_headerprint(t->sa, str); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /* Transform (Rotation) */ | /* Transform (Rotation) */ | ||||
| /** \name Transform Rotation | /** \name Transform Rotation | ||||
| * \{ */ | * \{ */ | ||||
| static void postInputRotation(TransInfo *t, float values[3]) | static void postInputRotation(TransInfo *t, float values[3]) | ||||
| { | { | ||||
| if ((t->con.mode & CON_APPLY) && t->con.applyRot) { | if ((t->con.mode & CON_APPLY) && t->con.applyRot) { | ||||
| t->con.applyRot(t, NULL, t->axis, values); | t->con.applyRot(t, NULL, NULL, t->axis, values); | ||||
| } | } | ||||
| } | } | ||||
| static void initRotation(TransInfo *t) | static void initRotation(TransInfo *t) | ||||
| { | { | ||||
| t->mode = TFM_ROTATION; | t->mode = TFM_ROTATION; | ||||
| t->transform = applyRotation; | t->transform = applyRotation; | ||||
| Show All 28 Lines | |||||
| } | } | ||||
| /** | /** | ||||
| * Applies values of rotation to `td->loc` and `td->ext->quat` | * Applies values of rotation to `td->loc` and `td->ext->quat` | ||||
| * based on a rotation matrix (mat) and a pivot (center). | * based on a rotation matrix (mat) and a pivot (center). | ||||
| * | * | ||||
| * Protected axis and other transform settings are taken into account. | * Protected axis and other transform settings are taken into account. | ||||
| */ | */ | ||||
| static void ElementRotation_ex(TransInfo *t, TransData *td, float mat[3][3], const float *center) | static void ElementRotation_ex(TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3], const float *center) | ||||
| { | { | ||||
| float vec[3], totmat[3][3], smat[3][3]; | float vec[3], totmat[3][3], smat[3][3]; | ||||
| float eul[3], fmat[3][3], quat[4]; | float eul[3], fmat[3][3], quat[4]; | ||||
| if (t->flag & T_POINTS) { | if (t->flag & T_POINTS) { | ||||
| mul_m3_m3m3(totmat, mat, td->mtx); | mul_m3_m3m3(totmat, mat, td->mtx); | ||||
| mul_m3_m3m3(smat, td->smtx, totmat); | mul_m3_m3m3(smat, td->smtx, totmat); | ||||
| Show All 30 Lines | static void ElementRotation_ex(TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3], const float *center) | ||||
| * the translation component, we only need the actual armature object's | * the translation component, we only need the actual armature object's | ||||
| * matrix (and inverse). That is not all though. Once the proper translation | * matrix (and inverse). That is not all though. Once the proper translation | ||||
| * has been computed, it has to be converted back into the bone's space. | * has been computed, it has to be converted back into the bone's space. | ||||
| */ | */ | ||||
| else if (t->flag & T_POSE) { | else if (t->flag & T_POSE) { | ||||
| float pmtx[3][3], imtx[3][3]; | float pmtx[3][3], imtx[3][3]; | ||||
| // Extract and invert armature object matrix | // Extract and invert armature object matrix | ||||
| copy_m3_m4(pmtx, t->poseobj->obmat); | copy_m3_m4(pmtx, tc->poseobj->obmat); | ||||
| invert_m3_m3(imtx, pmtx); | invert_m3_m3(imtx, pmtx); | ||||
| if ((td->flag & TD_NO_LOC) == 0) { | if ((td->flag & TD_NO_LOC) == 0) { | ||||
| sub_v3_v3v3(vec, td->center, center); | sub_v3_v3v3(vec, td->center, center); | ||||
| mul_m3_v3(pmtx, vec); // To Global space | mul_m3_v3(pmtx, vec); // To Global space | ||||
| mul_m3_v3(mat, vec); // Applying rotation | mul_m3_v3(mat, vec); // Applying rotation | ||||
| mul_m3_v3(imtx, vec); // To Local space | mul_m3_v3(imtx, vec); // To Local space | ||||
| ▲ Show 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | if ((t->flag & T_V3D_ALIGN) == 0) { // align mode doesn't rotate objects itself | ||||
| copy_v3_v3(td->ext->rot, eul); | copy_v3_v3(td->ext->rot, eul); | ||||
| } | } | ||||
| constraintRotLim(t, td); | constraintRotLim(t, td); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], const short around) | static void ElementRotation(TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3], const short around) | ||||
| { | { | ||||
| const float *center; | const float *center; | ||||
| /* local constraint shouldn't alter center */ | /* local constraint shouldn't alter center */ | ||||
| if (transdata_check_local_center(t, around)) { | if (transdata_check_local_center(t, around)) { | ||||
| center = td->center; | center = td->center; | ||||
| } | } | ||||
| else { | else { | ||||
| center = t->center; | center = tc->center_local; | ||||
| } | } | ||||
| ElementRotation_ex(t, td, mat, center); | ElementRotation_ex(t, tc, td, mat, center); | ||||
| } | } | ||||
| static void applyRotationValue(TransInfo *t, float angle, float axis[3]) | static void applyRotationValue(TransInfo *t, float angle, float axis[3]) | ||||
| { | { | ||||
| TransData *td = t->data; | |||||
| float mat[3][3]; | float mat[3][3]; | ||||
| int i; | int i; | ||||
| axis_angle_normalized_to_mat3(mat, axis, angle); | axis_angle_normalized_to_mat3(mat, axis, angle); | ||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| if (t->con.applyRot) { | if (t->con.applyRot) { | ||||
| t->con.applyRot(t, td, axis, NULL); | t->con.applyRot(t, tc, td, axis, NULL); | ||||
| axis_angle_normalized_to_mat3(mat, axis, angle * td->factor); | axis_angle_normalized_to_mat3(mat, axis, angle * td->factor); | ||||
| } | } | ||||
| else if (t->flag & T_PROP_EDIT) { | else if (t->flag & T_PROP_EDIT) { | ||||
| axis_angle_normalized_to_mat3(mat, axis, angle * td->factor); | axis_angle_normalized_to_mat3(mat, axis, angle * td->factor); | ||||
| } | } | ||||
| ElementRotation(t, td, mat, t->around); | ElementRotation(t, tc, td, mat, t->around); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| static void applyRotation(TransInfo *t, const int UNUSED(mval[2])) | static void applyRotation(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| size_t ofs = 0; | size_t ofs = 0; | ||||
| float final; | float final; | ||||
| final = t->values[0]; | final = t->values[0]; | ||||
| snapGridIncrement(t, &final); | snapGridIncrement(t, &final); | ||||
| if ((t->con.mode & CON_APPLY) && t->con.applyRot) { | if ((t->con.mode & CON_APPLY) && t->con.applyRot) { | ||||
| t->con.applyRot(t, NULL, t->axis, NULL); | t->con.applyRot(t, NULL, NULL, t->axis, NULL); | ||||
| } | } | ||||
| else { | else { | ||||
| /* reset axis if constraint is not set */ | /* reset axis if constraint is not set */ | ||||
| copy_v3_v3(t->axis, t->axis_orig); | copy_v3_v3(t->axis, t->axis_orig); | ||||
| } | } | ||||
| applySnapping(t, &final); | applySnapping(t, &final); | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | static void initTrackball(TransInfo *t) | ||||
| t->num.unit_type[0] = B_UNIT_ROTATION; | t->num.unit_type[0] = B_UNIT_ROTATION; | ||||
| t->num.unit_type[1] = B_UNIT_ROTATION; | t->num.unit_type[1] = B_UNIT_ROTATION; | ||||
| t->flag |= T_NO_CONSTRAINT; | t->flag |= T_NO_CONSTRAINT; | ||||
| } | } | ||||
| static void applyTrackballValue(TransInfo *t, const float axis1[3], const float axis2[3], float angles[2]) | static void applyTrackballValue(TransInfo *t, const float axis1[3], const float axis2[3], float angles[2]) | ||||
| { | { | ||||
| TransData *td = t->data; | |||||
| float mat[3][3]; | float mat[3][3]; | ||||
| float axis[3]; | float axis[3]; | ||||
| float angle; | float angle; | ||||
| int i; | int i; | ||||
| mul_v3_v3fl(axis, axis1, angles[0]); | mul_v3_v3fl(axis, axis1, angles[0]); | ||||
| madd_v3_v3fl(axis, axis2, angles[1]); | madd_v3_v3fl(axis, axis2, angles[1]); | ||||
| angle = normalize_v3(axis); | angle = normalize_v3(axis); | ||||
| axis_angle_normalized_to_mat3(mat, axis, angle); | axis_angle_normalized_to_mat3(mat, axis, angle); | ||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| if (t->flag & T_PROP_EDIT) { | if (t->flag & T_PROP_EDIT) { | ||||
| axis_angle_normalized_to_mat3(mat, axis, td->factor * angle); | axis_angle_normalized_to_mat3(mat, axis, td->factor * angle); | ||||
| } | } | ||||
| ElementRotation(t, td, mat, t->around); | ElementRotation(t, tc, td, mat, t->around); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| static void applyTrackball(TransInfo *t, const int UNUSED(mval[2])) | static void applyTrackball(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| size_t ofs = 0; | size_t ofs = 0; | ||||
| float axis1[3], axis2[3]; | float axis1[3], axis2[3]; | ||||
| #if 0 /* UNUSED */ | #if 0 /* UNUSED */ | ||||
| ▲ Show 20 Lines • Show All 237 Lines • ▼ Show 20 Lines | if ((snode->flag & SNODE_SKIP_INSOFFSET) == 0) { | ||||
| MEM_freeN((void *)str_old); | MEM_freeN((void *)str_old); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void applyTranslationValue(TransInfo *t, const float vec[3]) | static void applyTranslationValue(TransInfo *t, const float vec[3]) | ||||
| { | { | ||||
| TransData *td = t->data; | const bool apply_snap_align_rotation = usingSnappingNormal(t);// && (t->tsnap.status & POINT_INIT); | ||||
| float tvec[3]; | float tvec[3]; | ||||
| /* The ideal would be "apply_snap_align_rotation" only when a snap point is found | /* The ideal would be "apply_snap_align_rotation" only when a snap point is found | ||||
| * so, maybe inside this function is not the best place to apply this rotation. | * so, maybe inside this function is not the best place to apply this rotation. | ||||
| * but you need "handle snapping rotation before doing the translation" (really?) */ | * but you need "handle snapping rotation before doing the translation" (really?) */ | ||||
| const bool apply_snap_align_rotation = usingSnappingNormal(t);// && (t->tsnap.status & POINT_INIT); | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| float pivot[3]; | float pivot[3]; | ||||
| if (apply_snap_align_rotation) { | if (apply_snap_align_rotation) { | ||||
| copy_v3_v3(pivot, t->tsnap.snapTarget); | copy_v3_v3(pivot, t->tsnap.snapTarget); | ||||
| /* The pivot has to be in local-space (see T49494) */ | /* The pivot has to be in local-space (see T49494) */ | ||||
| if (t->flag & (T_EDIT | T_POSE)) { | if (t->flag & (T_EDIT | T_POSE)) { | ||||
| Object *ob = t->obedit ? t->obedit : t->poseobj; | Object *ob = tc->obedit ? tc->obedit : tc->poseobj; | ||||
| mul_m4_v3(ob->imat, pivot); | mul_m4_v3(ob->imat, pivot); | ||||
| } | } | ||||
| } | } | ||||
| for (int i = 0; i < t->total; i++, td++) { | TransData *td = tc->data; | ||||
| for (int i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| float rotate_offset[3] = {0}; | float rotate_offset[3] = {0}; | ||||
| bool use_rotate_offset = false; | bool use_rotate_offset = false; | ||||
| Show All 12 Lines | if (apply_snap_align_rotation) { | ||||
| original_normal = td->axismtx[2]; | original_normal = td->axismtx[2]; | ||||
| rotation_between_vecs_to_mat3(mat, original_normal, t->tsnap.snapNormal); | rotation_between_vecs_to_mat3(mat, original_normal, t->tsnap.snapNormal); | ||||
| } | } | ||||
| else { | else { | ||||
| unit_m3(mat); | unit_m3(mat); | ||||
| } | } | ||||
| ElementRotation_ex(t, td, mat, pivot); | ElementRotation_ex(t, tc, td, mat, pivot); | ||||
| if (td->loc) { | if (td->loc) { | ||||
| use_rotate_offset = true; | use_rotate_offset = true; | ||||
| sub_v3_v3v3(rotate_offset, td->loc, td->iloc); | sub_v3_v3v3(rotate_offset, td->loc, td->iloc); | ||||
| } | } | ||||
| } | } | ||||
| if (t->con.applyVec) { | if (t->con.applyVec) { | ||||
| float pvec[3]; | float pvec[3]; | ||||
| t->con.applyVec(t, td, vec, tvec, pvec); | t->con.applyVec(t, tc, td, vec, tvec, pvec); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v3_v3(tvec, vec); | copy_v3_v3(tvec, vec); | ||||
| } | } | ||||
| if (use_rotate_offset) { | if (use_rotate_offset) { | ||||
| add_v3_v3(tvec, rotate_offset); | add_v3_v3(tvec, rotate_offset); | ||||
| } | } | ||||
| mul_m3_v3(td->smtx, tvec); | mul_m3_v3(td->smtx, tvec); | ||||
| mul_v3_fl(tvec, td->factor); | mul_v3_fl(tvec, td->factor); | ||||
| protectedTransBits(td->protectflag, tvec); | protectedTransBits(td->protectflag, tvec); | ||||
| if (td->loc) | if (td->loc) | ||||
| add_v3_v3v3(td->loc, td->iloc, tvec); | add_v3_v3v3(td->loc, td->iloc, tvec); | ||||
| constraintTransLim(t, td); | constraintTransLim(t, td); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| static void applyTranslation(TransInfo *t, const int UNUSED(mval[2])) | static void applyTranslation(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| float value_final[3]; | float value_final[3]; | ||||
| if (t->flag & T_AUTOVALUES) { | if (t->flag & T_AUTOVALUES) { | ||||
| copy_v3_v3(t->values, t->auto_values); | copy_v3_v3(t->values, t->auto_values); | ||||
| } | } | ||||
| else { | else { | ||||
| if ((t->con.mode & CON_APPLY) == 0) { | if ((t->con.mode & CON_APPLY) == 0) { | ||||
| snapGridIncrement(t, t->values); | snapGridIncrement(t, t->values); | ||||
| } | } | ||||
| if (applyNumInput(&t->num, t->values)) { | if (applyNumInput(&t->num, t->values)) { | ||||
| removeAspectRatio(t, t->values); | removeAspectRatio(t, t->values); | ||||
| } | } | ||||
| applySnapping(t, t->values); | applySnapping(t, t->values); | ||||
| } | } | ||||
| if (t->con.mode & CON_APPLY) { | if (t->con.mode & CON_APPLY) { | ||||
| float pvec[3] = {0.0f, 0.0f, 0.0f}; | float pvec[3] = {0.0f, 0.0f, 0.0f}; | ||||
| t->con.applyVec(t, NULL, t->values, value_final, pvec); | t->con.applyVec(t, NULL, NULL, t->values, value_final, pvec); | ||||
| headerTranslation(t, pvec, str); | headerTranslation(t, pvec, str); | ||||
| /* only so we have re-usable value with redo, see T46741. */ | /* only so we have re-usable value with redo, see T46741. */ | ||||
| mul_v3_m3v3(t->values, t->con.imtx, value_final); | mul_v3_m3v3(t->values, t->con.imtx, value_final); | ||||
| } | } | ||||
| else { | else { | ||||
| headerTranslation(t, t->values, str); | headerTranslation(t, t->values, str); | ||||
| copy_v3_v3(value_final, t->values); | copy_v3_v3(value_final, t->values); | ||||
| Show All 27 Lines | |||||
| /* Transform (Shrink-Fatten) */ | /* Transform (Shrink-Fatten) */ | ||||
| /** \name Transform Shrink-Fatten | /** \name Transform Shrink-Fatten | ||||
| * \{ */ | * \{ */ | ||||
| static void initShrinkFatten(TransInfo *t) | static void initShrinkFatten(TransInfo *t) | ||||
| { | { | ||||
| // If not in mesh edit mode, fallback to Resize | // If not in mesh edit mode, fallback to Resize | ||||
| if (t->obedit == NULL || t->obedit->type != OB_MESH) { | if ((t->flag & T_EDIT) == 0 || (t->obedit_type != OB_MESH)) { | ||||
| initResize(t); | initResize(t); | ||||
| } | } | ||||
| else { | else { | ||||
| t->mode = TFM_SHRINKFATTEN; | t->mode = TFM_SHRINKFATTEN; | ||||
| t->transform = applyShrinkFatten; | t->transform = applyShrinkFatten; | ||||
| initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE); | initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE); | ||||
| Show All 13 Lines | |||||
| static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) | static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| float distance; | float distance; | ||||
| int i; | int i; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| size_t ofs = 0; | size_t ofs = 0; | ||||
| TransData *td = t->data; | |||||
| distance = -t->values[0]; | distance = -t->values[0]; | ||||
| snapGridIncrement(t, &distance); | snapGridIncrement(t, &distance); | ||||
| applyNumInput(&t->num, &distance); | applyNumInput(&t->num, &distance); | ||||
| t->values[0] = -distance; | t->values[0] = -distance; | ||||
| Show All 20 Lines | if (t->keymap) { | ||||
| if (kmi) { | if (kmi) { | ||||
| ofs += WM_keymap_item_to_string(kmi, false, str + ofs, sizeof(str) - ofs); | ofs += WM_keymap_item_to_string(kmi, false, str + ofs, sizeof(str) - ofs); | ||||
| } | } | ||||
| } | } | ||||
| BLI_snprintf(str + ofs, sizeof(str) - ofs, IFACE_(" or Alt) Even Thickness %s"), | BLI_snprintf(str + ofs, sizeof(str) - ofs, IFACE_(" or Alt) Even Thickness %s"), | ||||
| WM_bool_as_string((t->flag & T_ALT_TRANSFORM) != 0)); | WM_bool_as_string((t->flag & T_ALT_TRANSFORM) != 0)); | ||||
| /* done with header string */ | /* done with header string */ | ||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| float tdistance; /* temp dist */ | float tdistance; /* temp dist */ | ||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| /* get the final offset */ | /* get the final offset */ | ||||
| tdistance = distance * td->factor; | tdistance = distance * td->factor; | ||||
| if (td->ext && (t->flag & T_ALT_TRANSFORM)) { | if (td->ext && (t->flag & T_ALT_TRANSFORM)) { | ||||
| tdistance *= td->ext->isize[0]; /* shell factor */ | tdistance *= td->ext->isize[0]; /* shell factor */ | ||||
| } | } | ||||
| madd_v3_v3v3fl(td->loc, td->iloc, td->axismtx[2], tdistance); | madd_v3_v3v3fl(td->loc, td->iloc, td->axismtx[2], tdistance); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_headerprint(t->sa, str); | ED_area_headerprint(t->sa, str); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| Show All 22 Lines | static void initTilt(TransInfo *t) | ||||
| t->num.unit_type[0] = B_UNIT_ROTATION; | t->num.unit_type[0] = B_UNIT_ROTATION; | ||||
| t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT; | t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT; | ||||
| } | } | ||||
| static void applyTilt(TransInfo *t, const int UNUSED(mval[2])) | static void applyTilt(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| TransData *td = t->data; | |||||
| int i; | int i; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| float final; | float final; | ||||
| final = t->values[0]; | final = t->values[0]; | ||||
| snapGridIncrement(t, &final); | snapGridIncrement(t, &final); | ||||
| Show All 11 Lines | if (hasNumInput(&t->num)) { | ||||
| /* XXX For some reason, this seems needed for this op, else RNA prop is not updated... :/ */ | /* XXX For some reason, this seems needed for this op, else RNA prop is not updated... :/ */ | ||||
| t->values[0] = final; | t->values[0] = final; | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Tilt: %.2f° %s"), RAD2DEGF(final), t->proptext); | BLI_snprintf(str, sizeof(str), IFACE_("Tilt: %.2f° %s"), RAD2DEGF(final), t->proptext); | ||||
| } | } | ||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| if (td->val) { | if (td->val) { | ||||
| *td->val = td->ival + final * td->factor; | *td->val = td->ival + final * td->factor; | ||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_headerprint(t->sa, str); | ED_area_headerprint(t->sa, str); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| Show All 25 Lines | #ifdef USE_NUM_NO_ZERO | ||||
| t->num.val_flag[0] |= NUM_NO_ZERO; | t->num.val_flag[0] |= NUM_NO_ZERO; | ||||
| #endif | #endif | ||||
| t->flag |= T_NO_CONSTRAINT; | t->flag |= T_NO_CONSTRAINT; | ||||
| } | } | ||||
| static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) | static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| TransData *td = t->data; | |||||
| float ratio; | float ratio; | ||||
| int i; | int i; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| ratio = t->values[0]; | ratio = t->values[0]; | ||||
| snapGridIncrement(t, &ratio); | snapGridIncrement(t, &ratio); | ||||
| applyNumInput(&t->num, &ratio); | applyNumInput(&t->num, &ratio); | ||||
| t->values[0] = ratio; | t->values[0] = ratio; | ||||
| /* header print for NumInput */ | /* header print for NumInput */ | ||||
| if (hasNumInput(&t->num)) { | if (hasNumInput(&t->num)) { | ||||
| char c[NUM_STR_REP_LEN]; | char c[NUM_STR_REP_LEN]; | ||||
| outputNumInput(&(t->num), c, &t->scene->unit); | outputNumInput(&(t->num), c, &t->scene->unit); | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Shrink/Fatten: %s"), c); | BLI_snprintf(str, sizeof(str), IFACE_("Shrink/Fatten: %s"), c); | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Shrink/Fatten: %3f"), ratio); | BLI_snprintf(str, sizeof(str), IFACE_("Shrink/Fatten: %3f"), ratio); | ||||
| } | } | ||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| if (td->val) { | if (td->val) { | ||||
| *td->val = td->ival * ratio; | *td->val = td->ival * ratio; | ||||
| /* apply PET */ | /* apply PET */ | ||||
| *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival); | *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival); | ||||
| if (*td->val <= 0.0f) *td->val = 0.001f; | if (*td->val <= 0.0f) *td->val = 0.001f; | ||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_headerprint(t->sa, str); | ED_area_headerprint(t->sa, str); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| Show All 25 Lines | #ifdef USE_NUM_NO_ZERO | ||||
| t->num.val_flag[0] |= NUM_NO_ZERO; | t->num.val_flag[0] |= NUM_NO_ZERO; | ||||
| #endif | #endif | ||||
| t->flag |= T_NO_CONSTRAINT; | t->flag |= T_NO_CONSTRAINT; | ||||
| } | } | ||||
| static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) | static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| TransData *td; | |||||
| float ratio; | float ratio; | ||||
| int i; | int i; | ||||
| bool initial_feather = false; | bool initial_feather = false; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| ratio = t->values[0]; | ratio = t->values[0]; | ||||
| snapGridIncrement(t, &ratio); | snapGridIncrement(t, &ratio); | ||||
| Show All 12 Lines | static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) | ||||
| else { | else { | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Feather Shrink/Fatten: %3f"), ratio); | BLI_snprintf(str, sizeof(str), IFACE_("Feather Shrink/Fatten: %3f"), ratio); | ||||
| } | } | ||||
| /* detect if no points have feather yet */ | /* detect if no points have feather yet */ | ||||
| if (ratio > 1.0f) { | if (ratio > 1.0f) { | ||||
| initial_feather = true; | initial_feather = true; | ||||
| for (td = t->data, i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| if (td->ival >= 0.001f) | if (td->ival >= 0.001f) | ||||
| initial_feather = false; | initial_feather = false; | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| /* apply shrink/fatten */ | /* apply shrink/fatten */ | ||||
| for (td = t->data, i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (td = tc->data, i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| if (td->val) { | if (td->val) { | ||||
| if (initial_feather) | if (initial_feather) | ||||
| *td->val = td->ival + (ratio - 1.0f) * 0.01f; | *td->val = td->ival + (ratio - 1.0f) * 0.01f; | ||||
| else | else | ||||
| *td->val = td->ival * ratio; | *td->val = td->ival * ratio; | ||||
| /* apply PET */ | /* apply PET */ | ||||
| *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival); | *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival); | ||||
| if (*td->val <= 0.0f) *td->val = 0.001f; | if (*td->val <= 0.0f) *td->val = 0.001f; | ||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_headerprint(t->sa, str); | ED_area_headerprint(t->sa, str); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| Show All 25 Lines | #ifdef USE_NUM_NO_ZERO | ||||
| t->num.val_flag[0] |= NUM_NO_ZERO; | t->num.val_flag[0] |= NUM_NO_ZERO; | ||||
| #endif | #endif | ||||
| t->flag |= T_NO_CONSTRAINT; | t->flag |= T_NO_CONSTRAINT; | ||||
| } | } | ||||
| static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) | static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| TransData *td = t->data; | |||||
| float ratio; | float ratio; | ||||
| int i; | int i; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| ratio = t->values[0]; | ratio = t->values[0]; | ||||
| snapGridIncrement(t, &ratio); | snapGridIncrement(t, &ratio); | ||||
| applyNumInput(&t->num, &ratio); | applyNumInput(&t->num, &ratio); | ||||
| t->values[0] = ratio; | t->values[0] = ratio; | ||||
| /* header print for NumInput */ | /* header print for NumInput */ | ||||
| if (hasNumInput(&t->num)) { | if (hasNumInput(&t->num)) { | ||||
| char c[NUM_STR_REP_LEN]; | char c[NUM_STR_REP_LEN]; | ||||
| outputNumInput(&(t->num), c, &t->scene->unit); | outputNumInput(&(t->num), c, &t->scene->unit); | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Shrink/Fatten: %s"), c); | BLI_snprintf(str, sizeof(str), IFACE_("Shrink/Fatten: %s"), c); | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Shrink/Fatten: %3f"), ratio); | BLI_snprintf(str, sizeof(str), IFACE_("Shrink/Fatten: %3f"), ratio); | ||||
| } | } | ||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| if (td->val) { | if (td->val) { | ||||
| *td->val = td->ival * ratio; | *td->val = td->ival * ratio; | ||||
| /* apply PET */ | /* apply PET */ | ||||
| *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival); | *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival); | ||||
| if (*td->val <= 0.0f) *td->val = 0.001f; | if (*td->val <= 0.0f) *td->val = 0.001f; | ||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_headerprint(t->sa, str); | ED_area_headerprint(t->sa, str); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| Show All 23 Lines | |||||
| static void applyPushPull(TransInfo *t, const int UNUSED(mval[2])) | static void applyPushPull(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| float vec[3], axis_global[3]; | float vec[3], axis_global[3]; | ||||
| float distance; | float distance; | ||||
| int i; | int i; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| TransData *td = t->data; | |||||
| distance = t->values[0]; | distance = t->values[0]; | ||||
| snapGridIncrement(t, &distance); | snapGridIncrement(t, &distance); | ||||
| applyNumInput(&t->num, &distance); | applyNumInput(&t->num, &distance); | ||||
| t->values[0] = distance; | t->values[0] = distance; | ||||
| /* header print for NumInput */ | /* header print for NumInput */ | ||||
| if (hasNumInput(&t->num)) { | if (hasNumInput(&t->num)) { | ||||
| char c[NUM_STR_REP_LEN]; | char c[NUM_STR_REP_LEN]; | ||||
| outputNumInput(&(t->num), c, &t->scene->unit); | outputNumInput(&(t->num), c, &t->scene->unit); | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Push/Pull: %s%s %s"), c, t->con.text, t->proptext); | BLI_snprintf(str, sizeof(str), IFACE_("Push/Pull: %s%s %s"), c, t->con.text, t->proptext); | ||||
| } | } | ||||
| else { | else { | ||||
| /* default header print */ | /* default header print */ | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Push/Pull: %.4f%s %s"), distance, t->con.text, t->proptext); | BLI_snprintf(str, sizeof(str), IFACE_("Push/Pull: %.4f%s %s"), distance, t->con.text, t->proptext); | ||||
| } | } | ||||
| if (t->con.applyRot && t->con.mode & CON_APPLY) { | if (t->con.applyRot && t->con.mode & CON_APPLY) { | ||||
| t->con.applyRot(t, NULL, axis_global, NULL); | t->con.applyRot(t, NULL, NULL, axis_global, NULL); | ||||
| } | } | ||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| sub_v3_v3v3(vec, t->center, td->center); | sub_v3_v3v3(vec, tc->center_local, td->center); | ||||
| if (t->con.applyRot && t->con.mode & CON_APPLY) { | if (t->con.applyRot && t->con.mode & CON_APPLY) { | ||||
| float axis[3]; | float axis[3]; | ||||
| copy_v3_v3(axis, axis_global); | copy_v3_v3(axis, axis_global); | ||||
| t->con.applyRot(t, td, axis, NULL); | t->con.applyRot(t, tc, td, axis, NULL); | ||||
| mul_m3_v3(td->smtx, axis); | mul_m3_v3(td->smtx, axis); | ||||
| if (isLockConstraint(t)) { | if (isLockConstraint(t)) { | ||||
| float dvec[3]; | float dvec[3]; | ||||
| project_v3_v3v3(dvec, vec, axis); | project_v3_v3v3(dvec, vec, axis); | ||||
| sub_v3_v3(vec, dvec); | sub_v3_v3(vec, dvec); | ||||
| } | } | ||||
| else { | else { | ||||
| project_v3_v3v3(vec, vec, axis); | project_v3_v3v3(vec, vec, axis); | ||||
| } | } | ||||
| } | } | ||||
| normalize_v3_length(vec, distance * td->factor); | normalize_v3_length(vec, distance * td->factor); | ||||
| add_v3_v3v3(td->loc, td->iloc, vec); | add_v3_v3v3(td->loc, td->iloc, vec); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_headerprint(t->sa, str); | ED_area_headerprint(t->sa, str); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| Show All 20 Lines | static void initBevelWeight(TransInfo *t) | ||||
| t->num.unit_sys = t->scene->unit.system; | t->num.unit_sys = t->scene->unit.system; | ||||
| t->num.unit_type[0] = B_UNIT_NONE; | t->num.unit_type[0] = B_UNIT_NONE; | ||||
| t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT; | t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT; | ||||
| } | } | ||||
| static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2])) | static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| TransData *td = t->data; | |||||
| float weight; | float weight; | ||||
| int i; | int i; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| weight = t->values[0]; | weight = t->values[0]; | ||||
| CLAMP_MAX(weight, 1.0f); | CLAMP_MAX(weight, 1.0f); | ||||
| Show All 17 Lines | static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2])) | ||||
| else { | else { | ||||
| /* default header print */ | /* default header print */ | ||||
| if (weight >= 0.0f) | if (weight >= 0.0f) | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Bevel Weight: +%.3f %s"), weight, t->proptext); | BLI_snprintf(str, sizeof(str), IFACE_("Bevel Weight: +%.3f %s"), weight, t->proptext); | ||||
| else | else | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Bevel Weight: %.3f %s"), weight, t->proptext); | BLI_snprintf(str, sizeof(str), IFACE_("Bevel Weight: %.3f %s"), weight, t->proptext); | ||||
| } | } | ||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->val) { | if (td->val) { | ||||
| *td->val = td->ival + weight * td->factor; | *td->val = td->ival + weight * td->factor; | ||||
| if (*td->val < 0.0f) *td->val = 0.0f; | if (*td->val < 0.0f) *td->val = 0.0f; | ||||
| if (*td->val > 1.0f) *td->val = 1.0f; | if (*td->val > 1.0f) *td->val = 1.0f; | ||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_headerprint(t->sa, str); | ED_area_headerprint(t->sa, str); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| Show All 20 Lines | static void initCrease(TransInfo *t) | ||||
| t->num.unit_sys = t->scene->unit.system; | t->num.unit_sys = t->scene->unit.system; | ||||
| t->num.unit_type[0] = B_UNIT_NONE; | t->num.unit_type[0] = B_UNIT_NONE; | ||||
| t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT; | t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT; | ||||
| } | } | ||||
| static void applyCrease(TransInfo *t, const int UNUSED(mval[2])) | static void applyCrease(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| TransData *td = t->data; | |||||
| float crease; | float crease; | ||||
| int i; | int i; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| crease = t->values[0]; | crease = t->values[0]; | ||||
| CLAMP_MAX(crease, 1.0f); | CLAMP_MAX(crease, 1.0f); | ||||
| Show All 17 Lines | static void applyCrease(TransInfo *t, const int UNUSED(mval[2])) | ||||
| else { | else { | ||||
| /* default header print */ | /* default header print */ | ||||
| if (crease >= 0.0f) | if (crease >= 0.0f) | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Crease: +%.3f %s"), crease, t->proptext); | BLI_snprintf(str, sizeof(str), IFACE_("Crease: +%.3f %s"), crease, t->proptext); | ||||
| else | else | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Crease: %.3f %s"), crease, t->proptext); | BLI_snprintf(str, sizeof(str), IFACE_("Crease: %.3f %s"), crease, t->proptext); | ||||
| } | } | ||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| if (td->val) { | if (td->val) { | ||||
| *td->val = td->ival + crease * td->factor; | *td->val = td->ival + crease * td->factor; | ||||
| if (*td->val < 0.0f) *td->val = 0.0f; | if (*td->val < 0.0f) *td->val = 0.0f; | ||||
| if (*td->val > 1.0f) *td->val = 1.0f; | if (*td->val > 1.0f) *td->val = 1.0f; | ||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_headerprint(t->sa, str); | ED_area_headerprint(t->sa, str); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| ▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | else | ||||
| &tvec[0], &tvec[NUM_STR_REP_LEN], &tvec[NUM_STR_REP_LEN * 2], t->con.text, t->proptext); | &tvec[0], &tvec[NUM_STR_REP_LEN], &tvec[NUM_STR_REP_LEN * 2], t->con.text, t->proptext); | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_snprintf(str, UI_MAX_DRAW_STR, IFACE_("ScaleB X: %s Y: %s Z: %s%s %s"), | BLI_snprintf(str, UI_MAX_DRAW_STR, IFACE_("ScaleB X: %s Y: %s Z: %s%s %s"), | ||||
| &tvec[0], &tvec[NUM_STR_REP_LEN], &tvec[NUM_STR_REP_LEN * 2], t->con.text, t->proptext); | &tvec[0], &tvec[NUM_STR_REP_LEN], &tvec[NUM_STR_REP_LEN * 2], t->con.text, t->proptext); | ||||
| } | } | ||||
| } | } | ||||
| static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3]) | static void ElementBoneSize(TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3]) | ||||
| { | { | ||||
| float tmat[3][3], smat[3][3], oldy; | float tmat[3][3], smat[3][3], oldy; | ||||
| float sizemat[3][3]; | float sizemat[3][3]; | ||||
| mul_m3_m3m3(smat, mat, td->mtx); | mul_m3_m3m3(smat, mat, td->mtx); | ||||
| mul_m3_m3m3(tmat, td->smtx, smat); | mul_m3_m3m3(tmat, td->smtx, smat); | ||||
| if (t->con.applySize) { | if (t->con.applySize) { | ||||
| t->con.applySize(t, td, tmat); | t->con.applySize(t, tc, td, tmat); | ||||
| } | } | ||||
| /* we've tucked the scale in loc */ | /* we've tucked the scale in loc */ | ||||
| oldy = td->iloc[1]; | oldy = td->iloc[1]; | ||||
| size_to_mat3(sizemat, td->iloc); | size_to_mat3(sizemat, td->iloc); | ||||
| mul_m3_m3m3(tmat, tmat, sizemat); | mul_m3_m3m3(tmat, tmat, sizemat); | ||||
| mat3_to_size(td->loc, tmat); | mat3_to_size(td->loc, tmat); | ||||
| td->loc[1] = oldy; | td->loc[1] = oldy; | ||||
| } | } | ||||
| static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2])) | static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| TransData *td = t->data; | |||||
| float size[3], mat[3][3]; | float size[3], mat[3][3]; | ||||
| float ratio = t->values[0]; | float ratio = t->values[0]; | ||||
| int i; | int i; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| copy_v3_fl(size, ratio); | copy_v3_fl(size, ratio); | ||||
| snapGridIncrement(t, size); | snapGridIncrement(t, size); | ||||
| if (applyNumInput(&t->num, size)) { | if (applyNumInput(&t->num, size)) { | ||||
| constraintNumInput(t, size); | constraintNumInput(t, size); | ||||
| } | } | ||||
| copy_v3_v3(t->values, size); | copy_v3_v3(t->values, size); | ||||
| size_to_mat3(mat, size); | size_to_mat3(mat, size); | ||||
| if (t->con.applySize) { | if (t->con.applySize) { | ||||
| t->con.applySize(t, NULL, mat); | t->con.applySize(t, NULL, NULL, mat); | ||||
| } | } | ||||
| copy_m3_m3(t->mat, mat); // used in manipulator | copy_m3_m3(t->mat, mat); // used in manipulator | ||||
| headerBoneSize(t, size, str); | headerBoneSize(t, size, str); | ||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| ElementBoneSize(t, td, mat); | ElementBoneSize(t, tc, td, mat); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_headerprint(t->sa, str); | ED_area_headerprint(t->sa, str); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| Show All 19 Lines | static void initBoneEnvelope(TransInfo *t) | ||||
| t->num.unit_sys = t->scene->unit.system; | t->num.unit_sys = t->scene->unit.system; | ||||
| t->num.unit_type[0] = B_UNIT_NONE; | t->num.unit_type[0] = B_UNIT_NONE; | ||||
| t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT; | t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT; | ||||
| } | } | ||||
| static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2])) | static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| TransData *td = t->data; | |||||
| float ratio; | float ratio; | ||||
| int i; | int i; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| ratio = t->values[0]; | ratio = t->values[0]; | ||||
| snapGridIncrement(t, &ratio); | snapGridIncrement(t, &ratio); | ||||
| applyNumInput(&t->num, &ratio); | applyNumInput(&t->num, &ratio); | ||||
| t->values[0] = ratio; | t->values[0] = ratio; | ||||
| /* header print for NumInput */ | /* header print for NumInput */ | ||||
| if (hasNumInput(&t->num)) { | if (hasNumInput(&t->num)) { | ||||
| char c[NUM_STR_REP_LEN]; | char c[NUM_STR_REP_LEN]; | ||||
| outputNumInput(&(t->num), c, &t->scene->unit); | outputNumInput(&(t->num), c, &t->scene->unit); | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Envelope: %s"), c); | BLI_snprintf(str, sizeof(str), IFACE_("Envelope: %s"), c); | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Envelope: %3f"), ratio); | BLI_snprintf(str, sizeof(str), IFACE_("Envelope: %3f"), ratio); | ||||
| } | } | ||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| if (td->val) { | if (td->val) { | ||||
| /* if the old/original value was 0.0f, then just use ratio */ | /* if the old/original value was 0.0f, then just use ratio */ | ||||
| if (td->ival) | if (td->ival) | ||||
| *td->val = td->ival * ratio; | *td->val = td->ival * ratio; | ||||
| else | else | ||||
| *td->val = ratio; | *td->val = ratio; | ||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_headerprint(t->sa, str); | ED_area_headerprint(t->sa, str); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /* Original Data Store */ | /* Original Data Store */ | ||||
| /** \name Orig-Data Store Utility Functions | /** \name Orig-Data Store Utility Functions | ||||
| * \{ */ | * \{ */ | ||||
| static void slide_origdata_init_flag( | static void slide_origdata_init_flag( | ||||
| TransInfo *t, SlideOrigData *sod) | TransInfo *t, TransDataContainer *tc, SlideOrigData *sod) | ||||
| { | { | ||||
| BMEditMesh *em = BKE_editmesh_from_object(t->obedit); | BMEditMesh *em = BKE_editmesh_from_object(tc->obedit); | ||||
| BMesh *bm = em->bm; | BMesh *bm = em->bm; | ||||
| const bool has_layer_math = CustomData_has_math(&bm->ldata); | const bool has_layer_math = CustomData_has_math(&bm->ldata); | ||||
| const int cd_loop_mdisp_offset = CustomData_get_offset(&bm->ldata, CD_MDISPS); | const int cd_loop_mdisp_offset = CustomData_get_offset(&bm->ldata, CD_MDISPS); | ||||
| if ((t->settings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) && | if ((t->settings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) && | ||||
| /* don't do this at all for non-basis shape keys, too easy to | /* don't do this at all for non-basis shape keys, too easy to | ||||
| * accidentally break uv maps or vertex colors then */ | * accidentally break uv maps or vertex colors then */ | ||||
| (bm->shapenr <= 1) && | (bm->shapenr <= 1) && | ||||
| (has_layer_math || (cd_loop_mdisp_offset != -1))) | (has_layer_math || (cd_loop_mdisp_offset != -1))) | ||||
| { | { | ||||
| sod->use_origfaces = true; | sod->use_origfaces = true; | ||||
| sod->cd_loop_mdisp_offset = cd_loop_mdisp_offset; | sod->cd_loop_mdisp_offset = cd_loop_mdisp_offset; | ||||
| } | } | ||||
| else { | else { | ||||
| sod->use_origfaces = false; | sod->use_origfaces = false; | ||||
| sod->cd_loop_mdisp_offset = -1; | sod->cd_loop_mdisp_offset = -1; | ||||
| } | } | ||||
| } | } | ||||
| static void slide_origdata_init_data( | static void slide_origdata_init_data( | ||||
| TransInfo *t, SlideOrigData *sod) | TransDataContainer *tc, SlideOrigData *sod) | ||||
| { | { | ||||
| if (sod->use_origfaces) { | if (sod->use_origfaces) { | ||||
| BMEditMesh *em = BKE_editmesh_from_object(t->obedit); | BMEditMesh *em = BKE_editmesh_from_object(tc->obedit); | ||||
| BMesh *bm = em->bm; | BMesh *bm = em->bm; | ||||
| sod->origfaces = BLI_ghash_ptr_new(__func__); | sod->origfaces = BLI_ghash_ptr_new(__func__); | ||||
| sod->bm_origfaces = BM_mesh_create( | sod->bm_origfaces = BM_mesh_create( | ||||
| &bm_mesh_allocsize_default, | &bm_mesh_allocsize_default, | ||||
| &((struct BMeshCreateParams){.use_toolflags = false,})); | &((struct BMeshCreateParams){.use_toolflags = false,})); | ||||
| /* we need to have matching customdata */ | /* we need to have matching customdata */ | ||||
| BM_mesh_copy_init_customdata(sod->bm_origfaces, bm, NULL); | BM_mesh_copy_init_customdata(sod->bm_origfaces, bm, NULL); | ||||
| ▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | static void slide_origdata_create_data_vert( | ||||
| else { | else { | ||||
| sv->cd_loop_groups = NULL; | sv->cd_loop_groups = NULL; | ||||
| } | } | ||||
| BLI_ghash_insert(sod->origverts, sv->v, sv); | BLI_ghash_insert(sod->origverts, sv->v, sv); | ||||
| } | } | ||||
| static void slide_origdata_create_data( | static void slide_origdata_create_data( | ||||
| TransInfo *t, SlideOrigData *sod, | TransInfo *t, TransDataContainer *tc, SlideOrigData *sod, | ||||
| TransDataGenericSlideVert *sv_array, unsigned int v_stride, unsigned int v_num) | TransDataGenericSlideVert *sv_array, unsigned int v_stride, unsigned int v_num) | ||||
| { | { | ||||
| if (sod->use_origfaces) { | if (sod->use_origfaces) { | ||||
| BMEditMesh *em = BKE_editmesh_from_object(t->obedit); | BMEditMesh *em = BKE_editmesh_from_object(tc->obedit); | ||||
| BMesh *bm = em->bm; | BMesh *bm = em->bm; | ||||
| unsigned int i; | unsigned int i; | ||||
| TransDataGenericSlideVert *sv; | TransDataGenericSlideVert *sv; | ||||
| int layer_index_dst; | int layer_index_dst; | ||||
| int j; | int j; | ||||
| layer_index_dst = 0; | layer_index_dst = 0; | ||||
| Show All 15 Lines | if (sod->use_origfaces) { | ||||
| sod->origverts = BLI_ghash_ptr_new_ex(__func__, v_num); | sod->origverts = BLI_ghash_ptr_new_ex(__func__, v_num); | ||||
| for (i = 0, sv = sv_array; i < v_num; i++, sv = POINTER_OFFSET(sv, v_stride)) { | for (i = 0, sv = sv_array; i < v_num; i++, sv = POINTER_OFFSET(sv, v_stride)) { | ||||
| slide_origdata_create_data_vert(bm, sod, sv); | slide_origdata_create_data_vert(bm, sod, sv); | ||||
| } | } | ||||
| if (t->flag & T_MIRROR) { | if (t->flag & T_MIRROR) { | ||||
| TransData *td = t->data; | TransData *td = tc->data; | ||||
| TransDataGenericSlideVert *sv_mirror; | TransDataGenericSlideVert *sv_mirror; | ||||
| sod->sv_mirror = MEM_callocN(sizeof(*sv_mirror) * t->total, __func__); | sod->sv_mirror = MEM_callocN(sizeof(*sv_mirror) * tc->data_len, __func__); | ||||
| sod->totsv_mirror = t->total; | sod->totsv_mirror = tc->data_len; | ||||
| sv_mirror = sod->sv_mirror; | sv_mirror = sod->sv_mirror; | ||||
| for (i = 0; i < t->total; i++, td++) { | for (i = 0; i < tc->data_len; i++, td++) { | ||||
| BMVert *eve = td->extra; | BMVert *eve = td->extra; | ||||
| if (eve) { | if (eve) { | ||||
| sv_mirror->v = eve; | sv_mirror->v = eve; | ||||
| copy_v3_v3(sv_mirror->co_orig_3d, eve->co); | copy_v3_v3(sv_mirror->co_orig_3d, eve->co); | ||||
| slide_origdata_create_data_vert(bm, sod, sv_mirror); | slide_origdata_create_data_vert(bm, sod, sv_mirror); | ||||
| sv_mirror++; | sv_mirror++; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | BM_ITER_ELEM_INDEX (l, &liter, sv->v, BM_LOOPS_OF_VERT, j) { | ||||
| bm, l_other->f, f_copy, | bm, l_other->f, f_copy, | ||||
| faces_center[j_other], f_copy_center, sod->cd_loop_mdisp_offset); | faces_center[j_other], f_copy_center, sod->cd_loop_mdisp_offset); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void slide_origdata_interp_data( | static void slide_origdata_interp_data( | ||||
| TransInfo *t, SlideOrigData *sod, | Object *obedit, SlideOrigData *sod, | ||||
| TransDataGenericSlideVert *sv, unsigned int v_stride, unsigned int v_num, | TransDataGenericSlideVert *sv, unsigned int v_stride, unsigned int v_num, | ||||
| bool is_final) | bool is_final) | ||||
| { | { | ||||
| if (sod->use_origfaces) { | if (sod->use_origfaces) { | ||||
| BMEditMesh *em = BKE_editmesh_from_object(t->obedit); | BMEditMesh *em = BKE_editmesh_from_object(obedit); | ||||
| BMesh *bm = em->bm; | BMesh *bm = em->bm; | ||||
| unsigned int i; | unsigned int i; | ||||
| const bool has_mdisps = (sod->cd_loop_mdisp_offset != -1); | const bool has_mdisps = (sod->cd_loop_mdisp_offset != -1); | ||||
| for (i = 0; i < v_num; i++, sv = POINTER_OFFSET(sv, v_stride)) { | for (i = 0; i < v_num; i++, sv = POINTER_OFFSET(sv, v_stride)) { | ||||
| if (sv->cd_loop_groups || has_mdisps) { | if (sv->cd_loop_groups || has_mdisps) { | ||||
| slide_origdata_interp_data_vert(sod, bm, is_final, sv); | slide_origdata_interp_data_vert(sod, bm, is_final, sv); | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /* Transform (Edge Slide) */ | /* Transform (Edge Slide) */ | ||||
| /** \name Transform Edge Slide | /** \name Transform Edge Slide | ||||
| * \{ */ | * \{ */ | ||||
| static void calcEdgeSlideCustomPoints(struct TransInfo *t) | static void calcEdgeSlideCustomPoints(struct TransInfo *t) | ||||
| { | { | ||||
| EdgeSlideData *sld = t->custom.mode.data; | EdgeSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom_.mode.data; | ||||
| setCustomPoints(t, &t->mouse, sld->mval_end, sld->mval_start); | setCustomPoints(t, &t->mouse, sld->mval_end, sld->mval_start); | ||||
| /* setCustomPoints isn't normally changing as the mouse moves, | /* setCustomPoints isn't normally changing as the mouse moves, | ||||
| * in this case apply mouse input immediatly so we don't refresh | * in this case apply mouse input immediatly so we don't refresh | ||||
| * with the value from the previous points */ | * with the value from the previous points */ | ||||
| applyMouseInput(t, &t->mouse, t->mval, t->values); | applyMouseInput(t, &t->mouse, t->mval, t->values); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 180 Lines • ▼ Show 20 Lines | #endif | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /** | /** | ||||
| * Calculate screenspace `mval_start` / `mval_end`, optionally slide direction. | * Calculate screenspace `mval_start` / `mval_end`, optionally slide direction. | ||||
| */ | */ | ||||
| static void calcEdgeSlide_mval_range( | static void calcEdgeSlide_mval_range( | ||||
| TransInfo *t, EdgeSlideData *sld, const int *sv_table, const int loop_nr, | TransInfo *t, TransDataContainer *tc, EdgeSlideData *sld, const int *sv_table, const int loop_nr, | ||||
| const float mval[2], const bool use_occlude_geometry, const bool use_calc_direction) | const float mval[2], const bool use_occlude_geometry, const bool use_calc_direction) | ||||
| { | { | ||||
| TransDataEdgeSlideVert *sv_array = sld->sv; | TransDataEdgeSlideVert *sv_array = sld->sv; | ||||
| BMEditMesh *em = BKE_editmesh_from_object(t->obedit); | BMEditMesh *em = BKE_editmesh_from_object(tc->obedit); | ||||
| BMesh *bm = em->bm; | BMesh *bm = em->bm; | ||||
| ARegion *ar = t->ar; | ARegion *ar = t->ar; | ||||
| View3D *v3d = NULL; | View3D *v3d = NULL; | ||||
| RegionView3D *rv3d = NULL; | RegionView3D *rv3d = NULL; | ||||
| float projectMat[4][4]; | float projectMat[4][4]; | ||||
| BMBVHTree *bmbvh; | BMBVHTree *bmbvh; | ||||
| /* only for use_calc_direction */ | /* only for use_calc_direction */ | ||||
| Show All 10 Lines | if (t->spacetype == SPACE_VIEW3D) { | ||||
| rv3d = t->ar ? t->ar->regiondata : NULL; | rv3d = t->ar ? t->ar->regiondata : NULL; | ||||
| } | } | ||||
| if (!rv3d) { | if (!rv3d) { | ||||
| /* ok, let's try to survive this */ | /* ok, let's try to survive this */ | ||||
| unit_m4(projectMat); | unit_m4(projectMat); | ||||
| } | } | ||||
| else { | else { | ||||
| ED_view3d_ob_project_mat_get(rv3d, t->obedit, projectMat); | ED_view3d_ob_project_mat_get(rv3d, tc->obedit, projectMat); | ||||
| } | } | ||||
| if (use_occlude_geometry) { | if (use_occlude_geometry) { | ||||
| bmbvh = BKE_bmbvh_new_from_editmesh(em, BMBVH_RESPECT_HIDDEN, NULL, false); | bmbvh = BKE_bmbvh_new_from_editmesh(em, BMBVH_RESPECT_HIDDEN, NULL, false); | ||||
| } | } | ||||
| else { | else { | ||||
| bmbvh = NULL; | bmbvh = NULL; | ||||
| } | } | ||||
| Show All 26 Lines | if (BM_elem_flag_test(e, BM_ELEM_SELECT)) { | ||||
| float dist_sq; | float dist_sq; | ||||
| int j, l_nr; | int j, l_nr; | ||||
| if (BM_elem_flag_test(e_other, BM_ELEM_SELECT)) | if (BM_elem_flag_test(e_other, BM_ELEM_SELECT)) | ||||
| continue; | continue; | ||||
| /* This test is only relevant if object is not wire-drawn! See [#32068]. */ | /* This test is only relevant if object is not wire-drawn! See [#32068]. */ | ||||
| if (use_occlude_geometry && | if (use_occlude_geometry && | ||||
| !BMBVH_EdgeVisible(bmbvh, e_other, t->depsgraph, ar, v3d, t->obedit)) | !BMBVH_EdgeVisible(bmbvh, e_other, t->depsgraph, ar, v3d, tc->obedit)) | ||||
| { | { | ||||
| continue; | continue; | ||||
| } | } | ||||
| BLI_assert(sv_table[BM_elem_index_get(v)] != -1); | BLI_assert(sv_table[BM_elem_index_get(v)] != -1); | ||||
| j = sv_table[BM_elem_index_get(v)]; | j = sv_table[BM_elem_index_get(v)]; | ||||
| if (sv_array[j].v_side[1]) { | if (sv_array[j].v_side[1]) { | ||||
| ▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | static void calcEdgeSlide_mval_range( | ||||
| sld->mval_end[1] = t->mval[1] + mval_end[1]; | sld->mval_end[1] = t->mval[1] + mval_end[1]; | ||||
| if (bmbvh) { | if (bmbvh) { | ||||
| BKE_bmbvh_free(bmbvh); | BKE_bmbvh_free(bmbvh); | ||||
| } | } | ||||
| } | } | ||||
| static void calcEdgeSlide_even( | static void calcEdgeSlide_even( | ||||
| TransInfo *t, EdgeSlideData *sld, const float mval[2]) | TransInfo *t, TransDataContainer *tc, EdgeSlideData *sld, const float mval[2]) | ||||
| { | { | ||||
| TransDataEdgeSlideVert *sv = sld->sv; | TransDataEdgeSlideVert *sv = sld->sv; | ||||
| if (sld->totsv > 0) { | if (sld->totsv > 0) { | ||||
| ARegion *ar = t->ar; | ARegion *ar = t->ar; | ||||
| RegionView3D *rv3d = NULL; | RegionView3D *rv3d = NULL; | ||||
| float projectMat[4][4]; | float projectMat[4][4]; | ||||
| int i = 0; | int i = 0; | ||||
| float v_proj[2]; | float v_proj[2]; | ||||
| float dist_sq = 0; | float dist_sq = 0; | ||||
| float dist_min_sq = FLT_MAX; | float dist_min_sq = FLT_MAX; | ||||
| if (t->spacetype == SPACE_VIEW3D) { | if (t->spacetype == SPACE_VIEW3D) { | ||||
| /* background mode support */ | /* background mode support */ | ||||
| rv3d = t->ar ? t->ar->regiondata : NULL; | rv3d = t->ar ? t->ar->regiondata : NULL; | ||||
| } | } | ||||
| if (!rv3d) { | if (!rv3d) { | ||||
| /* ok, let's try to survive this */ | /* ok, let's try to survive this */ | ||||
| unit_m4(projectMat); | unit_m4(projectMat); | ||||
| } | } | ||||
| else { | else { | ||||
| ED_view3d_ob_project_mat_get(rv3d, t->obedit, projectMat); | ED_view3d_ob_project_mat_get(rv3d, tc->obedit, projectMat); | ||||
| } | } | ||||
| for (i = 0; i < sld->totsv; i++, sv++) { | for (i = 0; i < sld->totsv; i++, sv++) { | ||||
| /* Set length */ | /* Set length */ | ||||
| sv->edge_len = len_v3v3(sv->dir_side[0], sv->dir_side[1]); | sv->edge_len = len_v3v3(sv->dir_side[0], sv->dir_side[1]); | ||||
| ED_view3d_project_float_v2_m4(ar, sv->v->co, v_proj, projectMat); | ED_view3d_project_float_v2_m4(ar, sv->v->co, v_proj, projectMat); | ||||
| dist_sq = len_squared_v2v2(mval, v_proj); | dist_sq = len_squared_v2v2(mval, v_proj); | ||||
| if (dist_sq < dist_min_sq) { | if (dist_sq < dist_min_sq) { | ||||
| dist_min_sq = dist_sq; | dist_min_sq = dist_sq; | ||||
| sld->curr_sv_index = i; | sld->curr_sv_index = i; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| sld->curr_sv_index = 0; | sld->curr_sv_index = 0; | ||||
| } | } | ||||
| } | } | ||||
| static bool createEdgeSlideVerts_double_side(TransInfo *t, bool use_even, bool flipped, bool use_clamp) | static bool createEdgeSlideVerts_double_side(TransInfo *t, TransDataContainer *tc) | ||||
| { | { | ||||
| BMEditMesh *em = BKE_editmesh_from_object(t->obedit); | BMEditMesh *em = BKE_editmesh_from_object(tc->obedit); | ||||
| BMesh *bm = em->bm; | BMesh *bm = em->bm; | ||||
| BMIter iter; | BMIter iter; | ||||
| BMEdge *e; | BMEdge *e; | ||||
| BMVert *v; | BMVert *v; | ||||
| TransDataEdgeSlideVert *sv_array; | TransDataEdgeSlideVert *sv_array; | ||||
| int sv_tot; | int sv_tot; | ||||
| int *sv_table; /* BMVert -> sv_array index */ | int *sv_table; /* BMVert -> sv_array index */ | ||||
| EdgeSlideData *sld = MEM_callocN(sizeof(*sld), "sld"); | EdgeSlideData *sld = MEM_callocN(sizeof(*sld), "sld"); | ||||
| float mval[2] = {(float)t->mval[0], (float)t->mval[1]}; | float mval[2] = {(float)t->mval[0], (float)t->mval[1]}; | ||||
| int numsel, i, loop_nr; | int numsel, i, loop_nr; | ||||
| bool use_occlude_geometry = false; | bool use_occlude_geometry = false; | ||||
| View3D *v3d = NULL; | View3D *v3d = NULL; | ||||
| RegionView3D *rv3d = NULL; | RegionView3D *rv3d = NULL; | ||||
| slide_origdata_init_flag(t, &sld->orig_data); | slide_origdata_init_flag(t, tc, &sld->orig_data); | ||||
| sld->use_even = use_even; | |||||
| sld->curr_sv_index = 0; | sld->curr_sv_index = 0; | ||||
| sld->flipped = flipped; | |||||
| if (!use_clamp) | |||||
| t->flag |= T_ALT_TRANSFORM; | |||||
| /*ensure valid selection*/ | /*ensure valid selection*/ | ||||
| BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { | BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { | ||||
| if (BM_elem_flag_test(v, BM_ELEM_SELECT)) { | if (BM_elem_flag_test(v, BM_ELEM_SELECT)) { | ||||
| BMIter iter2; | BMIter iter2; | ||||
| numsel = 0; | numsel = 0; | ||||
| BM_ITER_ELEM (e, &iter2, v, BM_EDGES_OF_VERT) { | BM_ITER_ELEM (e, &iter2, v, BM_EDGES_OF_VERT) { | ||||
| if (BM_elem_flag_test(e, BM_ELEM_SELECT)) { | if (BM_elem_flag_test(e, BM_ELEM_SELECT)) { | ||||
| ▲ Show 20 Lines • Show All 299 Lines • ▼ Show 20 Lines | #undef EDGESLIDE_VERT_IS_INNER | ||||
| sld->sv = sv_array; | sld->sv = sv_array; | ||||
| sld->totsv = sv_tot; | sld->totsv = sv_tot; | ||||
| /* use for visibility checks */ | /* use for visibility checks */ | ||||
| if (t->spacetype == SPACE_VIEW3D) { | if (t->spacetype == SPACE_VIEW3D) { | ||||
| v3d = t->sa ? t->sa->spacedata.first : NULL; | v3d = t->sa ? t->sa->spacedata.first : NULL; | ||||
| rv3d = t->ar ? t->ar->regiondata : NULL; | rv3d = t->ar ? t->ar->regiondata : NULL; | ||||
| use_occlude_geometry = (v3d && t->obedit->dt > OB_WIRE && v3d->drawtype > OB_WIRE); | use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE && v3d->drawtype > OB_WIRE); | ||||
| } | } | ||||
| calcEdgeSlide_mval_range(t, sld, sv_table, loop_nr, mval, use_occlude_geometry, true); | calcEdgeSlide_mval_range(t, tc, sld, sv_table, loop_nr, mval, use_occlude_geometry, true); | ||||
| /* create copies of faces for customdata projection */ | /* create copies of faces for customdata projection */ | ||||
| bmesh_edit_begin(bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES); | bmesh_edit_begin(bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES); | ||||
| slide_origdata_init_data(t, &sld->orig_data); | slide_origdata_init_data(tc, &sld->orig_data); | ||||
| slide_origdata_create_data(t, &sld->orig_data, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv); | slide_origdata_create_data(t, tc, &sld->orig_data, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv); | ||||
| if (rv3d) { | if (rv3d) { | ||||
| calcEdgeSlide_even(t, sld, mval); | calcEdgeSlide_even(t, tc, sld, mval); | ||||
| } | } | ||||
| sld->em = em; | sld->em = em; | ||||
| sld->perc = 0.0f; | tc->custom_.mode.data = sld; | ||||
| t->custom.mode.data = sld; | |||||
| MEM_freeN(sv_table); | MEM_freeN(sv_table); | ||||
| return true; | return true; | ||||
| } | } | ||||
| /** | /** | ||||
| * A simple version of #createEdgeSlideVerts_double_side | * A simple version of #createEdgeSlideVerts_double_side | ||||
| * Which assumes the longest unselected. | * Which assumes the longest unselected. | ||||
| */ | */ | ||||
| static bool createEdgeSlideVerts_single_side(TransInfo *t, bool use_even, bool flipped, bool use_clamp) | static bool createEdgeSlideVerts_single_side(TransInfo *t, TransDataContainer *tc) | ||||
| { | { | ||||
| BMEditMesh *em = BKE_editmesh_from_object(t->obedit); | BMEditMesh *em = BKE_editmesh_from_object(tc->obedit); | ||||
| BMesh *bm = em->bm; | BMesh *bm = em->bm; | ||||
| BMIter iter; | BMIter iter; | ||||
| BMEdge *e; | BMEdge *e; | ||||
| TransDataEdgeSlideVert *sv_array; | TransDataEdgeSlideVert *sv_array; | ||||
| int sv_tot; | int sv_tot; | ||||
| int *sv_table; /* BMVert -> sv_array index */ | int *sv_table; /* BMVert -> sv_array index */ | ||||
| EdgeSlideData *sld = MEM_callocN(sizeof(*sld), "sld"); | EdgeSlideData *sld = MEM_callocN(sizeof(*sld), "sld"); | ||||
| float mval[2] = {(float)t->mval[0], (float)t->mval[1]}; | float mval[2] = {(float)t->mval[0], (float)t->mval[1]}; | ||||
| int loop_nr; | int loop_nr; | ||||
| bool use_occlude_geometry = false; | bool use_occlude_geometry = false; | ||||
| View3D *v3d = NULL; | View3D *v3d = NULL; | ||||
| RegionView3D *rv3d = NULL; | RegionView3D *rv3d = NULL; | ||||
| if (t->spacetype == SPACE_VIEW3D) { | if (t->spacetype == SPACE_VIEW3D) { | ||||
| /* background mode support */ | /* background mode support */ | ||||
| v3d = t->sa ? t->sa->spacedata.first : NULL; | v3d = t->sa ? t->sa->spacedata.first : NULL; | ||||
| rv3d = t->ar ? t->ar->regiondata : NULL; | rv3d = t->ar ? t->ar->regiondata : NULL; | ||||
| } | } | ||||
| slide_origdata_init_flag(t, &sld->orig_data); | slide_origdata_init_flag(t, tc, &sld->orig_data); | ||||
| sld->use_even = use_even; | |||||
| sld->curr_sv_index = 0; | sld->curr_sv_index = 0; | ||||
| /* happens to be best for single-sided */ | |||||
| sld->flipped = !flipped; | |||||
| if (!use_clamp) | |||||
| t->flag |= T_ALT_TRANSFORM; | |||||
| /* ensure valid selection */ | /* ensure valid selection */ | ||||
| { | { | ||||
| int i = 0, j = 0; | int i = 0, j = 0; | ||||
| BMVert *v; | BMVert *v; | ||||
| BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) { | BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) { | ||||
| if (BM_elem_flag_test(v, BM_ELEM_SELECT)) { | if (BM_elem_flag_test(v, BM_ELEM_SELECT)) { | ||||
| float len_sq_max = -1.0f; | float len_sq_max = -1.0f; | ||||
| ▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | static bool createEdgeSlideVerts_single_side(TransInfo *t, TransDataContainer *tc) | ||||
| sld->sv = sv_array; | sld->sv = sv_array; | ||||
| sld->totsv = sv_tot; | sld->totsv = sv_tot; | ||||
| /* use for visibility checks */ | /* use for visibility checks */ | ||||
| if (t->spacetype == SPACE_VIEW3D) { | if (t->spacetype == SPACE_VIEW3D) { | ||||
| v3d = t->sa ? t->sa->spacedata.first : NULL; | v3d = t->sa ? t->sa->spacedata.first : NULL; | ||||
| rv3d = t->ar ? t->ar->regiondata : NULL; | rv3d = t->ar ? t->ar->regiondata : NULL; | ||||
| use_occlude_geometry = (v3d && t->obedit->dt > OB_WIRE && v3d->drawtype > OB_WIRE); | use_occlude_geometry = (v3d && TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->dt > OB_WIRE && v3d->drawtype > OB_WIRE); | ||||
| } | } | ||||
| calcEdgeSlide_mval_range(t, sld, sv_table, loop_nr, mval, use_occlude_geometry, false); | calcEdgeSlide_mval_range(t, tc, sld, sv_table, loop_nr, mval, use_occlude_geometry, false); | ||||
| /* create copies of faces for customdata projection */ | /* create copies of faces for customdata projection */ | ||||
| bmesh_edit_begin(bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES); | bmesh_edit_begin(bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES); | ||||
| slide_origdata_init_data(t, &sld->orig_data); | slide_origdata_init_data(tc, &sld->orig_data); | ||||
| slide_origdata_create_data(t, &sld->orig_data, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv); | slide_origdata_create_data(t, tc, &sld->orig_data, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv); | ||||
| if (rv3d) { | if (rv3d) { | ||||
| calcEdgeSlide_even(t, sld, mval); | calcEdgeSlide_even(t, tc, sld, mval); | ||||
| } | } | ||||
| sld->em = em; | sld->em = em; | ||||
| sld->perc = 0.0f; | tc->custom_.mode.data = sld; | ||||
| t->custom.mode.data = sld; | |||||
| MEM_freeN(sv_table); | MEM_freeN(sv_table); | ||||
| return true; | return true; | ||||
| } | } | ||||
| void projectEdgeSlideData(TransInfo *t, bool is_final) | void projectEdgeSlideData(TransInfo *t, bool is_final) | ||||
| { | { | ||||
| EdgeSlideData *sld = t->custom.mode.data; | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| EdgeSlideData *sld = tc->custom_.mode.data; | |||||
| SlideOrigData *sod = &sld->orig_data; | SlideOrigData *sod = &sld->orig_data; | ||||
| if (sod->use_origfaces == false) { | if (sod->use_origfaces == false) { | ||||
| return; | return; | ||||
| } | } | ||||
| slide_origdata_interp_data(t, sod, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv, is_final); | slide_origdata_interp_data(tc->obedit, sod, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv, is_final); | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| void freeEdgeSlideTempFaces(EdgeSlideData *sld) | void freeEdgeSlideTempFaces(EdgeSlideData *sld) | ||||
| { | { | ||||
| slide_origdata_free_date(&sld->orig_data); | slide_origdata_free_date(&sld->orig_data); | ||||
| } | } | ||||
| void freeEdgeSlideVerts(TransInfo *UNUSED(t), TransCustomData *custom_data) | void freeEdgeSlideVerts(TransInfo *UNUSED(t), TransDataContainer *UNUSED(tc), TransCustomData *custom_data) | ||||
| { | { | ||||
| EdgeSlideData *sld = custom_data->data; | EdgeSlideData *sld = custom_data->data; | ||||
| if (!sld) | if (!sld) | ||||
| return; | return; | ||||
| freeEdgeSlideTempFaces(sld); | freeEdgeSlideTempFaces(sld); | ||||
| bmesh_edit_end(sld->em->bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES); | bmesh_edit_end(sld->em->bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES); | ||||
| MEM_freeN(sld->sv); | MEM_freeN(sld->sv); | ||||
| MEM_freeN(sld); | MEM_freeN(sld); | ||||
| custom_data->data = NULL; | custom_data->data = NULL; | ||||
| } | } | ||||
| static void initEdgeSlide_ex(TransInfo *t, bool use_double_side, bool use_even, bool flipped, bool use_clamp) | static void initEdgeSlide_ex(TransInfo *t, bool use_double_side, bool use_even, bool flipped, bool use_clamp) | ||||
| { | { | ||||
| EdgeSlideData *sld; | EdgeSlideData *sld; | ||||
| bool ok; | bool ok = false; | ||||
| t->mode = TFM_EDGE_SLIDE; | t->mode = TFM_EDGE_SLIDE; | ||||
| t->transform = applyEdgeSlide; | t->transform = applyEdgeSlide; | ||||
| t->handleEvent = handleEventEdgeSlide; | t->handleEvent = handleEventEdgeSlide; | ||||
| { | |||||
| EdgeSlideParams *slp = MEM_callocN(sizeof(*slp), __func__); | |||||
| slp->use_even = use_even; | |||||
| slp->flipped = flipped; | |||||
| /* happens to be best for single-sided */ | |||||
| if (use_double_side == false) { | |||||
| slp->flipped = !flipped; | |||||
| } | |||||
| slp->perc = 0.0f; | |||||
| if (!use_clamp) { | |||||
| t->flag |= T_ALT_TRANSFORM; | |||||
| } | |||||
| t->custom.mode.data = slp; | |||||
| t->custom.mode.use_free = true; | |||||
| } | |||||
| if (use_double_side) { | if (use_double_side) { | ||||
| ok = createEdgeSlideVerts_double_side(t, use_even, flipped, use_clamp); | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| ok |= createEdgeSlideVerts_double_side(t, tc); | |||||
| } | |||||
| } | } | ||||
| else { | else { | ||||
| ok = createEdgeSlideVerts_single_side(t, use_even, flipped, use_clamp); | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| ok |= createEdgeSlideVerts_single_side(t, tc); | |||||
| } | |||||
| } | } | ||||
| if (!ok) { | if (!ok) { | ||||
| t->state = TRANS_CANCEL; | t->state = TRANS_CANCEL; | ||||
| return; | return; | ||||
| } | } | ||||
| sld = t->custom.mode.data; | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| sld = tc->custom_.mode.data; | |||||
| if (!sld) | if (!sld) { | ||||
| return; | continue; | ||||
| } | |||||
| t->custom.mode.free_cb = freeEdgeSlideVerts; | tc->custom_.mode.free_cb = freeEdgeSlideVerts; | ||||
| } | |||||
| /* set custom point first if you want value to be initialized by init */ | /* set custom point first if you want value to be initialized by init */ | ||||
| calcEdgeSlideCustomPoints(t); | calcEdgeSlideCustomPoints(t); | ||||
| initMouseInputMode(t, &t->mouse, INPUT_CUSTOM_RATIO_FLIP); | initMouseInputMode(t, &t->mouse, INPUT_CUSTOM_RATIO_FLIP); | ||||
| t->idx_max = 0; | t->idx_max = 0; | ||||
| t->num.idx_max = 0; | t->num.idx_max = 0; | ||||
| t->snap[0] = 0.0f; | t->snap[0] = 0.0f; | ||||
| Show All 10 Lines | |||||
| static void initEdgeSlide(TransInfo *t) | static void initEdgeSlide(TransInfo *t) | ||||
| { | { | ||||
| initEdgeSlide_ex(t, true, false, false, true); | initEdgeSlide_ex(t, true, false, false, true); | ||||
| } | } | ||||
| static eRedrawFlag handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event) | static eRedrawFlag handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event) | ||||
| { | { | ||||
| if (t->mode == TFM_EDGE_SLIDE) { | if (t->mode == TFM_EDGE_SLIDE) { | ||||
| EdgeSlideData *sld = t->custom.mode.data; | EdgeSlideParams *slp = t->custom.mode.data; | ||||
| if (sld) { | if (slp) { | ||||
| switch (event->type) { | switch (event->type) { | ||||
| case EKEY: | case EKEY: | ||||
| if (event->val == KM_PRESS) { | if (event->val == KM_PRESS) { | ||||
| sld->use_even = !sld->use_even; | slp->use_even = !slp->use_even; | ||||
| calcEdgeSlideCustomPoints(t); | calcEdgeSlideCustomPoints(t); | ||||
| return TREDRAW_HARD; | return TREDRAW_HARD; | ||||
| } | } | ||||
| break; | break; | ||||
| case FKEY: | case FKEY: | ||||
| if (event->val == KM_PRESS) { | if (event->val == KM_PRESS) { | ||||
| sld->flipped = !sld->flipped; | slp->flipped = !slp->flipped; | ||||
| calcEdgeSlideCustomPoints(t); | calcEdgeSlideCustomPoints(t); | ||||
| return TREDRAW_HARD; | return TREDRAW_HARD; | ||||
| } | } | ||||
| break; | break; | ||||
| case CKEY: | case CKEY: | ||||
| /* use like a modifier key */ | /* use like a modifier key */ | ||||
| if (event->val == KM_PRESS) { | if (event->val == KM_PRESS) { | ||||
| t->flag ^= T_ALT_TRANSFORM; | t->flag ^= T_ALT_TRANSFORM; | ||||
| calcEdgeSlideCustomPoints(t); | calcEdgeSlideCustomPoints(t); | ||||
| return TREDRAW_HARD; | return TREDRAW_HARD; | ||||
| } | } | ||||
| break; | break; | ||||
| case EVT_MODAL_MAP: | case EVT_MODAL_MAP: | ||||
| #if 0 | |||||
| switch (event->val) { | switch (event->val) { | ||||
| case TFM_MODAL_EDGESLIDE_DOWN: | case TFM_MODAL_EDGESLIDE_DOWN: | ||||
| sld->curr_sv_index = ((sld->curr_sv_index - 1) + sld->totsv) % sld->totsv; | sld->curr_sv_index = ((sld->curr_sv_index - 1) + sld->totsv) % sld->totsv; | ||||
| return TREDRAW_HARD; | return TREDRAW_HARD; | ||||
| case TFM_MODAL_EDGESLIDE_UP: | case TFM_MODAL_EDGESLIDE_UP: | ||||
| sld->curr_sv_index = (sld->curr_sv_index + 1) % sld->totsv; | sld->curr_sv_index = (sld->curr_sv_index + 1) % sld->totsv; | ||||
| return TREDRAW_HARD; | return TREDRAW_HARD; | ||||
| } | } | ||||
| #endif | |||||
| break; | break; | ||||
| case MOUSEMOVE: | case MOUSEMOVE: | ||||
| calcEdgeSlideCustomPoints(t); | calcEdgeSlideCustomPoints(t); | ||||
| break; | break; | ||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return TREDRAW_NOTHING; | return TREDRAW_NOTHING; | ||||
| } | } | ||||
| static void drawEdgeSlide(TransInfo *t) | static void drawEdgeSlide(TransInfo *t) | ||||
| { | { | ||||
| if ((t->mode == TFM_EDGE_SLIDE) && t->custom.mode.data) { | if ((t->mode == TFM_EDGE_SLIDE) && TRANS_DATA_CONTAINER_FIRST_OK(t)->custom_.mode.data) { | ||||
| EdgeSlideData *sld = t->custom.mode.data; | EdgeSlideParams *slp = t->custom.mode.data; | ||||
| EdgeSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom_.mode.data; | |||||
| const bool is_clamp = !(t->flag & T_ALT_TRANSFORM); | const bool is_clamp = !(t->flag & T_ALT_TRANSFORM); | ||||
| /* Even mode */ | /* Even mode */ | ||||
| if ((sld->use_even == true) || (is_clamp == false)) { | if ((slp->use_even == true) || (is_clamp == false)) { | ||||
| View3D *v3d = t->view; | View3D *v3d = t->view; | ||||
| const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f; | const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f; | ||||
| if (v3d && v3d->zbuf) | if (v3d && v3d->zbuf) | ||||
| glDisable(GL_DEPTH_TEST); | glDisable(GL_DEPTH_TEST); | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | ||||
| gpuPushMatrix(); | gpuPushMatrix(); | ||||
| gpuMultMatrix(t->obedit->obmat); | gpuMultMatrix(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); | ||||
| unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); | unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| if (sld->use_even == true) { | if (slp->use_even == true) { | ||||
| float co_a[3], co_b[3], co_mark[3]; | float co_a[3], co_b[3], co_mark[3]; | ||||
| TransDataEdgeSlideVert *curr_sv = &sld->sv[sld->curr_sv_index]; | TransDataEdgeSlideVert *curr_sv = &sld->sv[sld->curr_sv_index]; | ||||
| const float fac = (sld->perc + 1.0f) / 2.0f; | const float fac = (slp->perc + 1.0f) / 2.0f; | ||||
| const float ctrl_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5f; | const float ctrl_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5f; | ||||
| const float guide_size = ctrl_size - 0.5f; | const float guide_size = ctrl_size - 0.5f; | ||||
| const int alpha_shade = -30; | const int alpha_shade = -30; | ||||
| add_v3_v3v3(co_a, curr_sv->v_co_orig, curr_sv->dir_side[0]); | add_v3_v3v3(co_a, curr_sv->v_co_orig, curr_sv->dir_side[0]); | ||||
| add_v3_v3v3(co_b, curr_sv->v_co_orig, curr_sv->dir_side[1]); | add_v3_v3v3(co_b, curr_sv->v_co_orig, curr_sv->dir_side[1]); | ||||
| glLineWidth(line_size); | glLineWidth(line_size); | ||||
| immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); | immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); | ||||
| immBeginAtMost(GWN_PRIM_LINES, 4); | immBeginAtMost(GWN_PRIM_LINES, 4); | ||||
| if (curr_sv->v_side[0]) { | if (curr_sv->v_side[0]) { | ||||
| immVertex3fv(pos, curr_sv->v_side[0]->co); | immVertex3fv(pos, curr_sv->v_side[0]->co); | ||||
| immVertex3fv(pos, curr_sv->v_co_orig); | immVertex3fv(pos, curr_sv->v_co_orig); | ||||
| } | } | ||||
| if (curr_sv->v_side[1]) { | if (curr_sv->v_side[1]) { | ||||
| immVertex3fv(pos, curr_sv->v_side[1]->co); | immVertex3fv(pos, curr_sv->v_side[1]->co); | ||||
| immVertex3fv(pos, curr_sv->v_co_orig); | immVertex3fv(pos, curr_sv->v_co_orig); | ||||
| } | } | ||||
| immEnd(); | immEnd(); | ||||
| immUniformThemeColorShadeAlpha(TH_SELECT, -30, alpha_shade); | immUniformThemeColorShadeAlpha(TH_SELECT, -30, alpha_shade); | ||||
| glPointSize(ctrl_size); | glPointSize(ctrl_size); | ||||
| immBegin(GWN_PRIM_POINTS, 1); | immBegin(GWN_PRIM_POINTS, 1); | ||||
| if (sld->flipped) { | if (slp->flipped) { | ||||
| if (curr_sv->v_side[1]) immVertex3fv(pos, curr_sv->v_side[1]->co); | if (curr_sv->v_side[1]) immVertex3fv(pos, curr_sv->v_side[1]->co); | ||||
| } | } | ||||
| else { | else { | ||||
| if (curr_sv->v_side[0]) immVertex3fv(pos, curr_sv->v_side[0]->co); | if (curr_sv->v_side[0]) immVertex3fv(pos, curr_sv->v_side[0]->co); | ||||
| } | } | ||||
| immEnd(); | immEnd(); | ||||
| immUniformThemeColorShadeAlpha(TH_SELECT, 255, alpha_shade); | immUniformThemeColorShadeAlpha(TH_SELECT, 255, alpha_shade); | ||||
| Show All 9 Lines | if ((slp->use_even == true) || (is_clamp == false)) { | ||||
| TransDataEdgeSlideVert *sv; | TransDataEdgeSlideVert *sv; | ||||
| int i; | int i; | ||||
| const int alpha_shade = -160; | const int alpha_shade = -160; | ||||
| glLineWidth(line_size); | glLineWidth(line_size); | ||||
| immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); | immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); | ||||
| immBegin(GWN_PRIM_LINES, sld->totsv * 2); | immBegin(GWN_PRIM_LINES, sld->totsv * 2); | ||||
| /* TODO(campbell): Loop over all verts */ | |||||
| sv = sld->sv; | sv = sld->sv; | ||||
| for (i = 0; i < sld->totsv; i++, sv++) { | for (i = 0; i < sld->totsv; i++, sv++) { | ||||
| float a[3], b[3]; | float a[3], b[3]; | ||||
| if (!is_zero_v3(sv->dir_side[side_index])) { | if (!is_zero_v3(sv->dir_side[side_index])) { | ||||
| copy_v3_v3(a, sv->dir_side[side_index]); | copy_v3_v3(a, sv->dir_side[side_index]); | ||||
| } | } | ||||
| else { | else { | ||||
| Show All 24 Lines | if ((slp->use_even == true) || (is_clamp == false)) { | ||||
| if (v3d && v3d->zbuf) | if (v3d && v3d->zbuf) | ||||
| glEnable(GL_DEPTH_TEST); | glEnable(GL_DEPTH_TEST); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void doEdgeSlide(TransInfo *t, float perc) | static void doEdgeSlide(TransInfo *t, float perc) | ||||
| { | { | ||||
| EdgeSlideData *sld = t->custom.mode.data; | EdgeSlideParams *slp = t->custom.mode.data; | ||||
| TransDataEdgeSlideVert *svlist = sld->sv, *sv; | EdgeSlideData *sld_active = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom_.mode.data; | ||||
| int i; | |||||
| sld->perc = perc; | slp->perc = perc; | ||||
| sv = svlist; | |||||
| if (sld->use_even == false) { | if (slp->use_even == false) { | ||||
| const bool is_clamp = !(t->flag & T_ALT_TRANSFORM); | const bool is_clamp = !(t->flag & T_ALT_TRANSFORM); | ||||
| if (is_clamp) { | if (is_clamp) { | ||||
| const int side_index = (perc < 0.0f); | const int side_index = (perc < 0.0f); | ||||
| const float perc_final = fabsf(perc); | const float perc_final = fabsf(perc); | ||||
| for (i = 0; i < sld->totsv; i++, sv++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| EdgeSlideData *sld = tc->custom_.mode.data; | |||||
| TransDataEdgeSlideVert *sv = sld->sv; | |||||
| for (int i = 0; i < sld->totsv; i++, sv++) { | |||||
| madd_v3_v3v3fl(sv->v->co, sv->v_co_orig, sv->dir_side[side_index], perc_final); | madd_v3_v3v3fl(sv->v->co, sv->v_co_orig, sv->dir_side[side_index], perc_final); | ||||
| } | } | ||||
| sld->curr_side_unclamp = side_index; | sld->curr_side_unclamp = side_index; | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| else { | else { | ||||
| const int side_index = sld->curr_side_unclamp; | const float perc_init = fabsf(perc) * ((sld_active->curr_side_unclamp == (perc < 0.0f)) ? 1 : -1); | ||||
| const float perc_init = fabsf(perc) * ((sld->curr_side_unclamp == (perc < 0.0f)) ? 1 : -1); | const int side_index = sld_active->curr_side_unclamp; | ||||
| for (i = 0; i < sld->totsv; i++, sv++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| EdgeSlideData *sld = tc->custom_.mode.data; | |||||
| TransDataEdgeSlideVert *sv = sld->sv; | |||||
| for (int i = 0; i < sld->totsv; i++, sv++) { | |||||
| float dir_flip[3]; | float dir_flip[3]; | ||||
| float perc_final = perc_init; | float perc_final = perc_init; | ||||
| if (!is_zero_v3(sv->dir_side[side_index])) { | if (!is_zero_v3(sv->dir_side[side_index])) { | ||||
| copy_v3_v3(dir_flip, sv->dir_side[side_index]); | copy_v3_v3(dir_flip, sv->dir_side[side_index]); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v3_v3(dir_flip, sv->dir_side[!side_index]); | copy_v3_v3(dir_flip, sv->dir_side[!side_index]); | ||||
| perc_final *= -1; | perc_final *= -1; | ||||
| } | } | ||||
| madd_v3_v3v3fl(sv->v->co, sv->v_co_orig, dir_flip, perc_final); | madd_v3_v3v3fl(sv->v->co, sv->v_co_orig, dir_flip, perc_final); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /** | /** | ||||
| * Implementation note, even mode ignores the starting positions and uses only the | * Implementation note, even mode ignores the starting positions and uses only the | ||||
| * a/b verts, this could be changed/improved so the distance is still met but the verts are moved along | * a/b verts, this could be changed/improved so the distance is still met but the verts are moved along | ||||
| * their original path (which may not be straight), however how it works now is OK and matches 2.4x - Campbell | * their original path (which may not be straight), however how it works now is OK and matches 2.4x - Campbell | ||||
| * | * | ||||
| * \note len_v3v3(curr_sv->dir_side[0], curr_sv->dir_side[1]) | * \note len_v3v3(curr_sv->dir_side[0], curr_sv->dir_side[1]) | ||||
| * is the same as the distance between the original vert locations, same goes for the lines below. | * is the same as the distance between the original vert locations, same goes for the lines below. | ||||
| */ | */ | ||||
| TransDataEdgeSlideVert *curr_sv = &sld->sv[sld->curr_sv_index]; | TransDataEdgeSlideVert *curr_sv = &sld_active->sv[sld_active->curr_sv_index]; | ||||
| const float curr_length_perc = curr_sv->edge_len * (((sld->flipped ? perc : -perc) + 1.0f) / 2.0f); | const float curr_length_perc = curr_sv->edge_len * (((slp->flipped ? perc : -perc) + 1.0f) / 2.0f); | ||||
| float co_a[3]; | float co_a[3]; | ||||
| float co_b[3]; | float co_b[3]; | ||||
| for (i = 0; i < sld->totsv; i++, sv++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| EdgeSlideData *sld = tc->custom_.mode.data; | |||||
| TransDataEdgeSlideVert *sv = sld->sv; | |||||
| for (int i = 0; i < sld->totsv; i++, sv++) { | |||||
| if (sv->edge_len > FLT_EPSILON) { | if (sv->edge_len > FLT_EPSILON) { | ||||
| const float fac = min_ff(sv->edge_len, curr_length_perc) / sv->edge_len; | const float fac = min_ff(sv->edge_len, curr_length_perc) / sv->edge_len; | ||||
| add_v3_v3v3(co_a, sv->v_co_orig, sv->dir_side[0]); | add_v3_v3v3(co_a, sv->v_co_orig, sv->dir_side[0]); | ||||
| add_v3_v3v3(co_b, sv->v_co_orig, sv->dir_side[1]); | add_v3_v3v3(co_b, sv->v_co_orig, sv->dir_side[1]); | ||||
| if (sld->flipped) { | if (slp->flipped) { | ||||
| interp_line_v3_v3v3v3(sv->v->co, co_b, sv->v_co_orig, co_a, fac); | interp_line_v3_v3v3v3(sv->v->co, co_b, sv->v_co_orig, co_a, fac); | ||||
| } | } | ||||
| else { | else { | ||||
| interp_line_v3_v3v3v3(sv->v->co, co_a, sv->v_co_orig, co_b, fac); | interp_line_v3_v3v3v3(sv->v->co, co_a, sv->v_co_orig, co_b, fac); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| } | } | ||||
| static void applyEdgeSlide(TransInfo *t, const int UNUSED(mval[2])) | static void applyEdgeSlide(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| size_t ofs = 0; | size_t ofs = 0; | ||||
| float final; | float final; | ||||
| EdgeSlideData *sld = t->custom.mode.data; | EdgeSlideParams *slp = t->custom.mode.data; | ||||
| bool flipped = sld->flipped; | bool flipped = slp->flipped; | ||||
| bool use_even = sld->use_even; | bool use_even = slp->use_even; | ||||
| const bool is_clamp = !(t->flag & T_ALT_TRANSFORM); | const bool is_clamp = !(t->flag & T_ALT_TRANSFORM); | ||||
| const bool is_constrained = !(is_clamp == false || hasNumInput(&t->num)); | const bool is_constrained = !(is_clamp == false || hasNumInput(&t->num)); | ||||
| final = t->values[0]; | final = t->values[0]; | ||||
| snapGridIncrement(t, &final); | snapGridIncrement(t, &final); | ||||
| /* only do this so out of range values are not displayed */ | /* only do this so out of range values are not displayed */ | ||||
| Show All 35 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /* Transform (Vert Slide) */ | /* Transform (Vert Slide) */ | ||||
| /** \name Transform Vert Slide | /** \name Transform Vert Slide | ||||
| * \{ */ | * \{ */ | ||||
| static void calcVertSlideCustomPoints(struct TransInfo *t) | static void calcVertSlideCustomPoints(struct TransInfo *t) | ||||
| { | { | ||||
| VertSlideData *sld = t->custom.mode.data; | VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom_.mode.data; | ||||
| TransDataVertSlideVert *sv = &sld->sv[sld->curr_sv_index]; | TransDataVertSlideVert *sv = &sld->sv[sld->curr_sv_index]; | ||||
| const float *co_orig_3d = sv->co_orig_3d; | const float *co_orig_3d = sv->co_orig_3d; | ||||
| const float *co_curr_3d = sv->co_link_orig_3d[sv->co_link_curr]; | const float *co_curr_3d = sv->co_link_orig_3d[sv->co_link_curr]; | ||||
| float co_curr_2d[2], co_orig_2d[2]; | float co_curr_2d[2], co_orig_2d[2]; | ||||
| int mval_ofs[2], mval_start[2], mval_end[2]; | int mval_ofs[2], mval_start[2], mval_end[2]; | ||||
| Show All 18 Lines | static void calcVertSlideCustomPoints(struct TransInfo *t) | ||||
| applyMouseInput(t, &t->mouse, t->mval, t->values); | applyMouseInput(t, &t->mouse, t->mval, t->values); | ||||
| } | } | ||||
| /** | /** | ||||
| * Run once when initializing vert slide to find the reference edge | * Run once when initializing vert slide to find the reference edge | ||||
| */ | */ | ||||
| static void calcVertSlideMouseActiveVert(struct TransInfo *t, const int mval[2]) | static void calcVertSlideMouseActiveVert(struct TransInfo *t, const int mval[2]) | ||||
| { | { | ||||
| VertSlideData *sld = t->custom.mode.data; | /* Active object may have no selected vertices. */ | ||||
| VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom_.mode.data; | |||||
| float mval_fl[2] = {UNPACK2(mval)}; | float mval_fl[2] = {UNPACK2(mval)}; | ||||
| TransDataVertSlideVert *sv; | TransDataVertSlideVert *sv; | ||||
| /* set the vertex to use as a reference for the mouse direction 'curr_sv_index' */ | /* set the vertex to use as a reference for the mouse direction 'curr_sv_index' */ | ||||
| float dist_sq = 0.0f; | float dist_sq = 0.0f; | ||||
| float dist_min_sq = FLT_MAX; | float dist_min_sq = FLT_MAX; | ||||
| int i; | int i; | ||||
| Show All 10 Lines | static void calcVertSlideMouseActiveVert(struct TransInfo *t, const int mval[2]) | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Run while moving the mouse to slide along the edge matching the mouse direction | * Run while moving the mouse to slide along the edge matching the mouse direction | ||||
| */ | */ | ||||
| static void calcVertSlideMouseActiveEdges(struct TransInfo *t, const int mval[2]) | static void calcVertSlideMouseActiveEdges(struct TransInfo *t, const int mval[2]) | ||||
| { | { | ||||
| VertSlideData *sld = t->custom.mode.data; | VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom_.mode.data; | ||||
| float imval_fl[2] = {UNPACK2(t->mouse.imval)}; | float imval_fl[2] = {UNPACK2(t->mouse.imval)}; | ||||
| float mval_fl[2] = {UNPACK2(mval)}; | float mval_fl[2] = {UNPACK2(mval)}; | ||||
| float dir[3]; | float dir[3]; | ||||
| TransDataVertSlideVert *sv; | TransDataVertSlideVert *sv; | ||||
| int i; | int i; | ||||
| /* note: we could save a matrix-multiply for each vertex | /* note: we could save a matrix-multiply for each vertex | ||||
| Show All 11 Lines | if (sv->co_link_tot > 1) { | ||||
| int co_link_curr_best = -1; | int co_link_curr_best = -1; | ||||
| int j; | int j; | ||||
| for (j = 0; j < sv->co_link_tot; j++) { | for (j = 0; j < sv->co_link_tot; j++) { | ||||
| float tdir[3]; | float tdir[3]; | ||||
| float dir_dot; | float dir_dot; | ||||
| sub_v3_v3v3(tdir, sv->co_orig_3d, sv->co_link_orig_3d[j]); | sub_v3_v3v3(tdir, sv->co_orig_3d, sv->co_link_orig_3d[j]); | ||||
| mul_mat3_m4_v3(t->obedit->obmat, tdir); | mul_mat3_m4_v3(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat, tdir); | ||||
| project_plane_v3_v3v3(tdir, tdir, t->viewinv[2]); | project_plane_v3_v3v3(tdir, tdir, t->viewinv[2]); | ||||
| normalize_v3(tdir); | normalize_v3(tdir); | ||||
| dir_dot = dot_v3v3(dir, tdir); | dir_dot = dot_v3v3(dir, tdir); | ||||
| if (dir_dot > dir_dot_best) { | if (dir_dot > dir_dot_best) { | ||||
| dir_dot_best = dir_dot; | dir_dot_best = dir_dot; | ||||
| co_link_curr_best = j; | co_link_curr_best = j; | ||||
| } | } | ||||
| } | } | ||||
| if (co_link_curr_best != -1) { | if (co_link_curr_best != -1) { | ||||
| sv->co_link_curr = co_link_curr_best; | sv->co_link_curr = co_link_curr_best; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static bool createVertSlideVerts(TransInfo *t, bool use_even, bool flipped, bool use_clamp) | static bool createVertSlideVerts(TransInfo *t, TransDataContainer *tc) | ||||
| { | { | ||||
| BMEditMesh *em = BKE_editmesh_from_object(t->obedit); | BMEditMesh *em = BKE_editmesh_from_object(tc->obedit); | ||||
| BMesh *bm = em->bm; | BMesh *bm = em->bm; | ||||
| BMIter iter; | BMIter iter; | ||||
| BMIter eiter; | BMIter eiter; | ||||
| BMEdge *e; | BMEdge *e; | ||||
| BMVert *v; | BMVert *v; | ||||
| TransDataVertSlideVert *sv_array; | TransDataVertSlideVert *sv_array; | ||||
| VertSlideData *sld = MEM_callocN(sizeof(*sld), "sld"); | VertSlideData *sld = MEM_callocN(sizeof(*sld), "sld"); | ||||
| int j; | int j; | ||||
| slide_origdata_init_flag(t, &sld->orig_data); | slide_origdata_init_flag(t, tc, &sld->orig_data); | ||||
| sld->use_even = use_even; | |||||
| sld->curr_sv_index = 0; | sld->curr_sv_index = 0; | ||||
| sld->flipped = flipped; | |||||
| if (!use_clamp) | |||||
| t->flag |= T_ALT_TRANSFORM; | |||||
| j = 0; | j = 0; | ||||
| BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { | BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { | ||||
| bool ok = false; | bool ok = false; | ||||
| if (BM_elem_flag_test(v, BM_ELEM_SELECT) && v->e) { | if (BM_elem_flag_test(v, BM_ELEM_SELECT) && v->e) { | ||||
| BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) { | BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) { | ||||
| if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { | if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { | ||||
| ok = true; | ok = true; | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | if (BM_elem_flag_test(v, BM_ELEM_TAG)) { | ||||
| j++; | j++; | ||||
| } | } | ||||
| } | } | ||||
| sld->sv = sv_array; | sld->sv = sv_array; | ||||
| sld->totsv = j; | sld->totsv = j; | ||||
| bmesh_edit_begin(bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES); | bmesh_edit_begin(bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES); | ||||
| slide_origdata_init_data(t, &sld->orig_data); | slide_origdata_init_data(tc, &sld->orig_data); | ||||
| slide_origdata_create_data(t, &sld->orig_data, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv); | slide_origdata_create_data(t, tc, &sld->orig_data, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv); | ||||
| sld->em = em; | sld->em = em; | ||||
| sld->perc = 0.0f; | tc->custom_.mode.data = sld; | ||||
| t->custom.mode.data = sld; | |||||
| /* most likely will be set below */ | /* most likely will be set below */ | ||||
| unit_m4(sld->proj_mat); | unit_m4(sld->proj_mat); | ||||
| if (t->spacetype == SPACE_VIEW3D) { | if (t->spacetype == SPACE_VIEW3D) { | ||||
| /* view vars */ | /* view vars */ | ||||
| RegionView3D *rv3d = NULL; | RegionView3D *rv3d = NULL; | ||||
| ARegion *ar = t->ar; | ARegion *ar = t->ar; | ||||
| rv3d = ar ? ar->regiondata : NULL; | rv3d = ar ? ar->regiondata : NULL; | ||||
| if (rv3d) { | if (rv3d) { | ||||
| ED_view3d_ob_project_mat_get(rv3d, t->obedit, sld->proj_mat); | ED_view3d_ob_project_mat_get(rv3d, tc->obedit, sld->proj_mat); | ||||
| } | |||||
| } | } | ||||
| /* XXX, calc vert slide across all objects */ | |||||
| if (tc == t->data_container) { | |||||
| calcVertSlideMouseActiveVert(t, t->mval); | calcVertSlideMouseActiveVert(t, t->mval); | ||||
| calcVertSlideMouseActiveEdges(t, t->mval); | calcVertSlideMouseActiveEdges(t, t->mval); | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| void projectVertSlideData(TransInfo *t, bool is_final) | void projectVertSlideData(TransInfo *t, bool is_final) | ||||
| { | { | ||||
| VertSlideData *sld = t->custom.mode.data; | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| VertSlideData *sld = tc->custom_.mode.data; | |||||
| SlideOrigData *sod = &sld->orig_data; | SlideOrigData *sod = &sld->orig_data; | ||||
| if (sod->use_origfaces == true) { | |||||
| if (sod->use_origfaces == false) { | slide_origdata_interp_data(tc->obedit, sod, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv, is_final); | ||||
| return; | |||||
| } | } | ||||
| } // FIXME(indent) | |||||
| slide_origdata_interp_data(t, sod, (TransDataGenericSlideVert *)sld->sv, sizeof(*sld->sv), sld->totsv, is_final); | |||||
| } | } | ||||
| void freeVertSlideTempFaces(VertSlideData *sld) | void freeVertSlideTempFaces(VertSlideData *sld) | ||||
| { | { | ||||
| slide_origdata_free_date(&sld->orig_data); | slide_origdata_free_date(&sld->orig_data); | ||||
| } | } | ||||
| void freeVertSlideVerts(TransInfo *UNUSED(t), TransCustomData *custom_data) | void freeVertSlideVerts(TransInfo *UNUSED(t), TransDataContainer *UNUSED(tc), TransCustomData *custom_data) | ||||
| { | { | ||||
| VertSlideData *sld = custom_data->data; | VertSlideData *sld = custom_data->data; | ||||
| if (!sld) | if (!sld) | ||||
| return; | return; | ||||
| freeVertSlideTempFaces(sld); | freeVertSlideTempFaces(sld); | ||||
| Show All 10 Lines | void freeVertSlideVerts(TransInfo *UNUSED(t), TransDataContainer *UNUSED(tc), TransCustomData *custom_data) | ||||
| MEM_freeN(sld->sv); | MEM_freeN(sld->sv); | ||||
| MEM_freeN(sld); | MEM_freeN(sld); | ||||
| custom_data->data = NULL; | custom_data->data = NULL; | ||||
| } | } | ||||
| static void initVertSlide_ex(TransInfo *t, bool use_even, bool flipped, bool use_clamp) | static void initVertSlide_ex(TransInfo *t, bool use_even, bool flipped, bool use_clamp) | ||||
| { | { | ||||
| VertSlideData *sld; | |||||
| t->mode = TFM_VERT_SLIDE; | t->mode = TFM_VERT_SLIDE; | ||||
| t->transform = applyVertSlide; | t->transform = applyVertSlide; | ||||
| t->handleEvent = handleEventVertSlide; | t->handleEvent = handleEventVertSlide; | ||||
| if (!createVertSlideVerts(t, use_even, flipped, use_clamp)) { | { | ||||
| t->state = TRANS_CANCEL; | VertSlideParams *slp = MEM_callocN(sizeof(*slp), __func__); | ||||
| return; | slp->use_even = use_even; | ||||
| slp->flipped = flipped; | |||||
| slp->perc = 0.0f; | |||||
| if (!use_clamp) { | |||||
| t->flag |= T_ALT_TRANSFORM; | |||||
| } | } | ||||
| sld = t->custom.mode.data; | t->custom.mode.data = slp; | ||||
| t->custom.mode.use_free = true; | |||||
| } | |||||
| if (!sld) | bool ok = false; | ||||
| return; | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| ok |= createVertSlideVerts(t, tc); | |||||
| VertSlideData *sld = tc->custom_.mode.data; | |||||
| if (sld) { | |||||
| tc->custom_.mode.free_cb = freeVertSlideVerts; | |||||
| } | |||||
| } | |||||
| t->custom.mode.free_cb = freeVertSlideVerts; | if (ok == false) { | ||||
| t->state = TRANS_CANCEL; | |||||
| return; | |||||
| } | |||||
| /* set custom point first if you want value to be initialized by init */ | /* set custom point first if you want value to be initialized by init */ | ||||
| calcVertSlideCustomPoints(t); | calcVertSlideCustomPoints(t); | ||||
| initMouseInputMode(t, &t->mouse, INPUT_CUSTOM_RATIO); | initMouseInputMode(t, &t->mouse, INPUT_CUSTOM_RATIO); | ||||
| t->idx_max = 0; | t->idx_max = 0; | ||||
| t->num.idx_max = 0; | t->num.idx_max = 0; | ||||
| t->snap[0] = 0.0f; | t->snap[0] = 0.0f; | ||||
| Show All 10 Lines | |||||
| static void initVertSlide(TransInfo *t) | static void initVertSlide(TransInfo *t) | ||||
| { | { | ||||
| initVertSlide_ex(t, false, false, true); | initVertSlide_ex(t, false, false, true); | ||||
| } | } | ||||
| static eRedrawFlag handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event) | static eRedrawFlag handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event) | ||||
| { | { | ||||
| if (t->mode == TFM_VERT_SLIDE) { | if (t->mode == TFM_VERT_SLIDE) { | ||||
| VertSlideData *sld = t->custom.mode.data; | VertSlideParams *slp = t->custom.mode.data; | ||||
| if (sld) { | if (slp) { | ||||
| switch (event->type) { | switch (event->type) { | ||||
| case EKEY: | case EKEY: | ||||
| if (event->val == KM_PRESS) { | if (event->val == KM_PRESS) { | ||||
| sld->use_even = !sld->use_even; | slp->use_even = !slp->use_even; | ||||
| if (sld->flipped) { | if (slp->flipped) { | ||||
| calcVertSlideCustomPoints(t); | calcVertSlideCustomPoints(t); | ||||
| } | } | ||||
| return TREDRAW_HARD; | return TREDRAW_HARD; | ||||
| } | } | ||||
| break; | break; | ||||
| case FKEY: | case FKEY: | ||||
| if (event->val == KM_PRESS) { | if (event->val == KM_PRESS) { | ||||
| sld->flipped = !sld->flipped; | slp->flipped = !slp->flipped; | ||||
| calcVertSlideCustomPoints(t); | calcVertSlideCustomPoints(t); | ||||
| return TREDRAW_HARD; | return TREDRAW_HARD; | ||||
| } | } | ||||
| break; | break; | ||||
| case CKEY: | case CKEY: | ||||
| /* use like a modifier key */ | /* use like a modifier key */ | ||||
| if (event->val == KM_PRESS) { | if (event->val == KM_PRESS) { | ||||
| t->flag ^= T_ALT_TRANSFORM; | t->flag ^= T_ALT_TRANSFORM; | ||||
| Show All 28 Lines | #endif | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return TREDRAW_NOTHING; | return TREDRAW_NOTHING; | ||||
| } | } | ||||
| static void drawVertSlide(TransInfo *t) | static void drawVertSlide(TransInfo *t) | ||||
| { | { | ||||
| if ((t->mode == TFM_VERT_SLIDE) && t->custom.mode.data) { | if ((t->mode == TFM_VERT_SLIDE) && TRANS_DATA_CONTAINER_FIRST_OK(t)->custom_.mode.data) { | ||||
| VertSlideData *sld = t->custom.mode.data; | VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom_.mode.data; | ||||
| const bool is_clamp = !(t->flag & T_ALT_TRANSFORM); | const bool is_clamp = !(t->flag & T_ALT_TRANSFORM); | ||||
| /* Non-Prop mode */ | /* Non-Prop mode */ | ||||
| { | { | ||||
| View3D *v3d = t->view; | View3D *v3d = t->view; | ||||
| TransDataVertSlideVert *curr_sv = &sld->sv[sld->curr_sv_index]; | TransDataVertSlideVert *curr_sv = &sld->sv[sld->curr_sv_index]; | ||||
| TransDataVertSlideVert *sv; | TransDataVertSlideVert *sv; | ||||
| const float ctrl_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5f; | const float ctrl_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5f; | ||||
| const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f; | const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f; | ||||
| const int alpha_shade = -160; | const int alpha_shade = -160; | ||||
| int i; | int i; | ||||
| if (v3d && v3d->zbuf) | if (v3d && v3d->zbuf) | ||||
| glDisable(GL_DEPTH_TEST); | glDisable(GL_DEPTH_TEST); | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | ||||
| gpuPushMatrix(); | gpuPushMatrix(); | ||||
| gpuMultMatrix(t->obedit->obmat); | gpuMultMatrix(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); | ||||
| glLineWidth(line_size); | glLineWidth(line_size); | ||||
| const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); | const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); | immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); | ||||
| immBegin(GWN_PRIM_LINES, sld->totsv * 2); | immBegin(GWN_PRIM_LINES, sld->totsv * 2); | ||||
| if (is_clamp) { | if (is_clamp) { | ||||
| sv = sld->sv; | sv = sld->sv; | ||||
| for (i = 0; i < sld->totsv; i++, sv++) { | for (i = 0; i < sld->totsv; i++, sv++) { | ||||
| immVertex3fv(shdr_pos, sv->co_orig_3d); | immVertex3fv(shdr_pos, sv->co_orig_3d); | ||||
| Show All 33 Lines | /* Non-Prop mode */ | ||||
| float zfac; | float zfac; | ||||
| float mval_ofs[2]; | float mval_ofs[2]; | ||||
| float co_orig_3d[3]; | float co_orig_3d[3]; | ||||
| float co_dest_3d[3]; | float co_dest_3d[3]; | ||||
| mval_ofs[0] = t->mval[0] - t->mouse.imval[0]; | mval_ofs[0] = t->mval[0] - t->mouse.imval[0]; | ||||
| mval_ofs[1] = t->mval[1] - t->mouse.imval[1]; | mval_ofs[1] = t->mval[1] - t->mouse.imval[1]; | ||||
| mul_v3_m4v3(co_orig_3d, t->obedit->obmat, curr_sv->co_orig_3d); | mul_v3_m4v3(co_orig_3d, TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat, curr_sv->co_orig_3d); | ||||
| zfac = ED_view3d_calc_zfac(t->ar->regiondata, co_orig_3d, NULL); | zfac = ED_view3d_calc_zfac(t->ar->regiondata, co_orig_3d, NULL); | ||||
| ED_view3d_win_to_delta(t->ar, mval_ofs, co_dest_3d, zfac); | ED_view3d_win_to_delta(t->ar, mval_ofs, co_dest_3d, zfac); | ||||
| invert_m4_m4(t->obedit->imat, t->obedit->obmat); | invert_m4_m4(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->imat, TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); | ||||
| mul_mat3_m4_v3(t->obedit->imat, co_dest_3d); | mul_mat3_m4_v3(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->imat, co_dest_3d); | ||||
| add_v3_v3(co_dest_3d, curr_sv->co_orig_3d); | add_v3_v3(co_dest_3d, curr_sv->co_orig_3d); | ||||
| glLineWidth(1.0f); | glLineWidth(1.0f); | ||||
| immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR); | ||||
| float viewport_size[4]; | float viewport_size[4]; | ||||
| Show All 18 Lines | /* Non-Prop mode */ | ||||
| if (v3d && v3d->zbuf) | if (v3d && v3d->zbuf) | ||||
| glEnable(GL_DEPTH_TEST); | glEnable(GL_DEPTH_TEST); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void doVertSlide(TransInfo *t, float perc) | static void doVertSlide(TransInfo *t, float perc) | ||||
| { | { | ||||
| VertSlideData *sld = t->custom.mode.data; | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| VertSlideData *sld = tc->custom_.mode.data; | |||||
| TransDataVertSlideVert *svlist = sld->sv, *sv; | TransDataVertSlideVert *svlist = sld->sv, *sv; | ||||
| int i; | int i; | ||||
| sld->perc = perc; | sld->perc = perc; | ||||
| sv = svlist; | sv = svlist; | ||||
| if (sld->use_even == false) { | if (sld->use_even == false) { | ||||
| for (i = 0; i < sld->totsv; i++, sv++) { | for (i = 0; i < sld->totsv; i++, sv++) { | ||||
| Show All 20 Lines | for (i = 0; i < sld->totsv; i++, sv++) { | ||||
| madd_v3_v3v3fl(sv->v->co, sv->co_orig_3d, dir, tperc); | madd_v3_v3v3fl(sv->v->co, sv->co_orig_3d, dir, tperc); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v3_v3(sv->v->co, sv->co_orig_3d); | copy_v3_v3(sv->v->co, sv->co_orig_3d); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| static void applyVertSlide(TransInfo *t, const int UNUSED(mval[2])) | static void applyVertSlide(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| size_t ofs = 0; | size_t ofs = 0; | ||||
| float final; | float final; | ||||
| VertSlideData *sld = t->custom.mode.data; | VertSlideData *slp = t->custom.mode.data; | ||||
| const bool flipped = sld->flipped; | const bool flipped = slp->flipped; | ||||
| const bool use_even = sld->use_even; | const bool use_even = slp->use_even; | ||||
| const bool is_clamp = !(t->flag & T_ALT_TRANSFORM); | const bool is_clamp = !(t->flag & T_ALT_TRANSFORM); | ||||
| const bool is_constrained = !(is_clamp == false || hasNumInput(&t->num)); | const bool is_constrained = !(is_clamp == false || hasNumInput(&t->num)); | ||||
| final = t->values[0]; | final = t->values[0]; | ||||
| snapGridIncrement(t, &final); | snapGridIncrement(t, &final); | ||||
| /* only do this so out of range values are not displayed */ | /* only do this so out of range values are not displayed */ | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | static void initBoneRoll(TransInfo *t) | ||||
| t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS); | t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS); | ||||
| t->num.unit_type[0] = B_UNIT_ROTATION; | t->num.unit_type[0] = B_UNIT_ROTATION; | ||||
| t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT; | t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT; | ||||
| } | } | ||||
| static void applyBoneRoll(TransInfo *t, const int UNUSED(mval[2])) | static void applyBoneRoll(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| TransData *td = t->data; | |||||
| int i; | int i; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| float final; | float final; | ||||
| final = t->values[0]; | final = t->values[0]; | ||||
| snapGridIncrement(t, &final); | snapGridIncrement(t, &final); | ||||
| Show All 9 Lines | if (hasNumInput(&t->num)) { | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Roll: %s"), &c[0]); | BLI_snprintf(str, sizeof(str), IFACE_("Roll: %s"), &c[0]); | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Roll: %.2f"), RAD2DEGF(final)); | BLI_snprintf(str, sizeof(str), IFACE_("Roll: %.2f"), RAD2DEGF(final)); | ||||
| } | } | ||||
| /* set roll values */ | /* set roll values */ | ||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| *(td->val) = td->ival - final; | *(td->val) = td->ival - final; | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_headerprint(t->sa, str); | ED_area_headerprint(t->sa, str); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| Show All 16 Lines | static void initBakeTime(TransInfo *t) | ||||
| copy_v3_fl(t->num.val_inc, t->snap[1]); | copy_v3_fl(t->num.val_inc, t->snap[1]); | ||||
| t->num.unit_sys = t->scene->unit.system; | t->num.unit_sys = t->scene->unit.system; | ||||
| t->num.unit_type[0] = B_UNIT_NONE; /* Don't think this uses units? */ | t->num.unit_type[0] = B_UNIT_NONE; /* Don't think this uses units? */ | ||||
| } | } | ||||
| static void applyBakeTime(TransInfo *t, const int mval[2]) | static void applyBakeTime(TransInfo *t, const int mval[2]) | ||||
| { | { | ||||
| TransData *td = t->data; | |||||
| float time; | float time; | ||||
| int i; | int i; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| float fac = 0.1f; | float fac = 0.1f; | ||||
| /* XXX, disable precision for now, | /* XXX, disable precision for now, | ||||
| * this isn't even accessible by the user */ | * this isn't even accessible by the user */ | ||||
| Show All 27 Lines | #endif | ||||
| else { | else { | ||||
| /* default header print */ | /* default header print */ | ||||
| if (time >= 0.0f) | if (time >= 0.0f) | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Time: +%.3f %s"), time, t->proptext); | BLI_snprintf(str, sizeof(str), IFACE_("Time: +%.3f %s"), time, t->proptext); | ||||
| else | else | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Time: %.3f %s"), time, t->proptext); | BLI_snprintf(str, sizeof(str), IFACE_("Time: %.3f %s"), time, t->proptext); | ||||
| } | } | ||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| if (td->val) { | if (td->val) { | ||||
| *td->val = td->ival + time * td->factor; | *td->val = td->ival + time * td->factor; | ||||
| if (td->ext->size && *td->val < *td->ext->size) *td->val = *td->ext->size; | if (td->ext->size && *td->val < *td->ext->size) *td->val = *td->ext->size; | ||||
| if (td->ext->quat && *td->val > *td->ext->quat) *td->val = *td->ext->quat; | if (td->ext->quat && *td->val > *td->ext->quat) *td->val = *td->ext->quat; | ||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_headerprint(t->sa, str); | ED_area_headerprint(t->sa, str); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /* Transform (Mirror) */ | /* Transform (Mirror) */ | ||||
| /** \name Transform Mirror | /** \name Transform Mirror | ||||
| * \{ */ | * \{ */ | ||||
| static void initMirror(TransInfo *t) | static void initMirror(TransInfo *t) | ||||
| { | { | ||||
| t->transform = applyMirror; | t->transform = applyMirror; | ||||
| initMouseInputMode(t, &t->mouse, INPUT_NONE); | initMouseInputMode(t, &t->mouse, INPUT_NONE); | ||||
| t->flag |= T_NULL_ONE; | t->flag |= T_NULL_ONE; | ||||
| if (!t->obedit) { | if ((t->flag & T_EDIT) == 0) { | ||||
| t->flag |= T_NO_ZERO; | t->flag |= T_NO_ZERO; | ||||
| } | } | ||||
| } | } | ||||
| static void applyMirror(TransInfo *t, const int UNUSED(mval[2])) | static void applyMirror(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| TransData *td; | |||||
| float size[3], mat[3][3]; | float size[3], mat[3][3]; | ||||
| int i; | int i; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| /* | /* | ||||
| * OPTIMIZATION: | * OPTIMIZATION: | ||||
| * This still recalcs transformation on mouse move | * This still recalcs transformation on mouse move | ||||
| * while it should only recalc on constraint change | * while it should only recalc on constraint change | ||||
| * */ | * */ | ||||
| /* if an axis has been selected */ | /* if an axis has been selected */ | ||||
| if (t->con.mode & CON_APPLY) { | if (t->con.mode & CON_APPLY) { | ||||
| size[0] = size[1] = size[2] = -1; | size[0] = size[1] = size[2] = -1; | ||||
| size_to_mat3(mat, size); | size_to_mat3(mat, size); | ||||
| if (t->con.applySize) { | if (t->con.applySize) { | ||||
| t->con.applySize(t, NULL, mat); | t->con.applySize(t, NULL, NULL, mat); | ||||
| } | } | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("Mirror%s"), t->con.text); | BLI_snprintf(str, sizeof(str), IFACE_("Mirror%s"), t->con.text); | ||||
| for (i = 0, td = t->data; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| ElementResize(t, td, mat); | ElementResize(t, tc, td, mat); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_headerprint(t->sa, str); | ED_area_headerprint(t->sa, str); | ||||
| } | } | ||||
| else { | else { | ||||
| size[0] = size[1] = size[2] = 1; | size[0] = size[1] = size[2] = 1; | ||||
| size_to_mat3(mat, size); | size_to_mat3(mat, size); | ||||
| for (i = 0, td = t->data; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| ElementResize(t, td, mat); | ElementResize(t, tc, td, mat); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| if (t->flag & T_2D_EDIT) | if (t->flag & T_2D_EDIT) | ||||
| ED_area_headerprint(t->sa, IFACE_("Select a mirror axis (X, Y)")); | ED_area_headerprint(t->sa, IFACE_("Select a mirror axis (X, Y)")); | ||||
| else | else | ||||
| ED_area_headerprint(t->sa, IFACE_("Select a mirror axis (X, Y, Z)")); | ED_area_headerprint(t->sa, IFACE_("Select a mirror axis (X, Y, Z)")); | ||||
| } | } | ||||
| Show All 13 Lines | static void initAlign(TransInfo *t) | ||||
| t->transform = applyAlign; | t->transform = applyAlign; | ||||
| initMouseInputMode(t, &t->mouse, INPUT_NONE); | initMouseInputMode(t, &t->mouse, INPUT_NONE); | ||||
| } | } | ||||
| static void applyAlign(TransInfo *t, const int UNUSED(mval[2])) | static void applyAlign(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| TransData *td = t->data; | |||||
| float center[3]; | float center[3]; | ||||
| int i; | int i; | ||||
| /* saving original center */ | |||||
| copy_v3_v3(center, t->center); | |||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| /* saving original center */ | |||||
| copy_v3_v3(center, tc->center_local); | |||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| float mat[3][3], invmat[3][3]; | float mat[3][3], invmat[3][3]; | ||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| /* around local centers */ | /* around local centers */ | ||||
| if (t->flag & (T_OBJECT | T_POSE)) { | if (t->flag & (T_OBJECT | T_POSE)) { | ||||
| copy_v3_v3(t->center, td->center); | copy_v3_v3(tc->center_local, td->center); | ||||
| } | } | ||||
| else { | else { | ||||
| if (t->settings->selectmode & SCE_SELECT_FACE) { | if (t->settings->selectmode & SCE_SELECT_FACE) { | ||||
| copy_v3_v3(t->center, td->center); | copy_v3_v3(tc->center_local, td->center); | ||||
| } | } | ||||
| } | } | ||||
| invert_m3_m3(invmat, td->axismtx); | invert_m3_m3(invmat, td->axismtx); | ||||
| mul_m3_m3m3(mat, t->spacemtx, invmat); | mul_m3_m3m3(mat, t->spacemtx, invmat); | ||||
| ElementRotation(t, td, mat, t->around); | ElementRotation(t, tc, td, mat, t->around); | ||||
| } | } | ||||
| /* restoring original center */ | /* restoring original center */ | ||||
| copy_v3_v3(t->center, center); | copy_v3_v3(tc->center_local, center); | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_headerprint(t->sa, IFACE_("Align")); | ED_area_headerprint(t->sa, IFACE_("Align")); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | if (t->keymap) { | ||||
| } | } | ||||
| } | } | ||||
| ofs += BLI_snprintf(str + ofs, UI_MAX_DRAW_STR - ofs, IFACE_(" or Alt) Expand to fit %s"), | ofs += BLI_snprintf(str + ofs, UI_MAX_DRAW_STR - ofs, IFACE_(" or Alt) Expand to fit %s"), | ||||
| WM_bool_as_string((t->flag & T_ALT_TRANSFORM) != 0)); | WM_bool_as_string((t->flag & T_ALT_TRANSFORM) != 0)); | ||||
| } | } | ||||
| static void applySeqSlideValue(TransInfo *t, const float val[2]) | static void applySeqSlideValue(TransInfo *t, const float val[2]) | ||||
| { | { | ||||
| TransData *td = t->data; | |||||
| int i; | int i; | ||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| madd_v2_v2v2fl(td->loc, td->iloc, val, td->factor); | madd_v2_v2v2fl(td->loc, td->iloc, val, td->factor); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| static void applySeqSlide(TransInfo *t, const int mval[2]) | static void applySeqSlide(TransInfo *t, const int mval[2]) | ||||
| { | { | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| snapSequenceBounds(t, mval); | snapSequenceBounds(t, mval); | ||||
| if (t->con.mode & CON_APPLY) { | if (t->con.mode & CON_APPLY) { | ||||
| float pvec[3] = {0.0f, 0.0f, 0.0f}; | float pvec[3] = {0.0f, 0.0f, 0.0f}; | ||||
| float tvec[3]; | float tvec[3]; | ||||
| t->con.applyVec(t, NULL, t->values, tvec, pvec); | t->con.applyVec(t, NULL, NULL, t->values, tvec, pvec); | ||||
| copy_v3_v3(t->values, tvec); | copy_v3_v3(t->values, tvec); | ||||
| } | } | ||||
| else { | else { | ||||
| // snapGridIncrement(t, t->values); | // snapGridIncrement(t, t->values); | ||||
| applyNumInput(&t->num, t->values); | applyNumInput(&t->num, t->values); | ||||
| } | } | ||||
| t->values[0] = floorf(t->values[0] + 0.5f); | t->values[0] = floorf(t->values[0] + 0.5f); | ||||
| ▲ Show 20 Lines • Show All 203 Lines • ▼ Show 20 Lines | static void headerTimeTranslate(TransInfo *t, char str[UI_MAX_DRAW_STR]) | ||||
| if (t->flag & T_PROP_EDIT_ALL) { | if (t->flag & T_PROP_EDIT_ALL) { | ||||
| ofs += BLI_snprintf(str + ofs, UI_MAX_DRAW_STR - ofs, IFACE_(" Proportional size: %.2f"), t->prop_size); | ofs += BLI_snprintf(str + ofs, UI_MAX_DRAW_STR - ofs, IFACE_(" Proportional size: %.2f"), t->prop_size); | ||||
| } | } | ||||
| } | } | ||||
| static void applyTimeTranslateValue(TransInfo *t) | static void applyTimeTranslateValue(TransInfo *t) | ||||
| { | { | ||||
| TransData *td = t->data; | |||||
| TransData2D *td2d = t->data2d; | |||||
| Scene *scene = t->scene; | Scene *scene = t->scene; | ||||
| int i; | int i; | ||||
| const short autosnap = getAnimEdit_SnapMode(t); | const short autosnap = getAnimEdit_SnapMode(t); | ||||
| const double secf = FPS; | const double secf = FPS; | ||||
| float deltax, val /* , valprev */; | float deltax, val /* , valprev */; | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | |||||
| TransData *td = tc->data; | |||||
| TransData2D *td2d = tc->data_2d; | |||||
| /* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */ | /* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */ | ||||
| for (i = 0; i < t->total; i++, td++, td2d++) { | for (i = 0; i < tc->data_len; i++, td++, td2d++) { | ||||
| /* it is assumed that td->extra is a pointer to the AnimData, | /* it is assumed that td->extra is a pointer to the AnimData, | ||||
| * whose active action is where this keyframe comes from | * whose active action is where this keyframe comes from | ||||
| * (this is only valid when not in NLA) | * (this is only valid when not in NLA) | ||||
| */ | */ | ||||
| AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL; | AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL; | ||||
| /* valprev = *td->val; */ /* UNUSED */ | /* valprev = *td->val; */ /* UNUSED */ | ||||
| Show All 23 Lines | else { | ||||
| } | } | ||||
| *(td->val) = td->ival + val; | *(td->val) = td->ival + val; | ||||
| } | } | ||||
| /* apply nearest snapping */ | /* apply nearest snapping */ | ||||
| doAnimEdit_SnapFrame(t, td, td2d, adt, autosnap); | doAnimEdit_SnapFrame(t, td, td2d, adt, autosnap); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| static void applyTimeTranslate(TransInfo *t, const int mval[2]) | static void applyTimeTranslate(TransInfo *t, const int mval[2]) | ||||
| { | { | ||||
| View2D *v2d = (View2D *)t->view; | View2D *v2d = (View2D *)t->view; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| /* calculate translation amount from mouse movement - in 'time-grid space' */ | /* calculate translation amount from mouse movement - in 'time-grid space' */ | ||||
| ▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | static void initTimeSlide(TransInfo *t) | ||||
| { | { | ||||
| Scene *scene = t->scene; | Scene *scene = t->scene; | ||||
| float *range; | float *range; | ||||
| t->custom.mode.data = range = MEM_mallocN(sizeof(float[2]), "TimeSlide Min/Max"); | t->custom.mode.data = range = MEM_mallocN(sizeof(float[2]), "TimeSlide Min/Max"); | ||||
| t->custom.mode.use_free = true; | t->custom.mode.use_free = true; | ||||
| float min = 999999999.0f, max = -999999999.0f; | float min = 999999999.0f, max = -999999999.0f; | ||||
| int i; | int i; | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | |||||
| TransData *td = t->data; | TransData *td = tc->data; | ||||
| for (i = 0; i < t->total; i++, td++) { | for (i = 0; i < tc->data_len; i++, td++) { | ||||
| AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL; | AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL; | ||||
| float val = *(td->val); | float val = *(td->val); | ||||
| /* strip/action time to global (mapped) time */ | /* strip/action time to global (mapped) time */ | ||||
| if (adt) | if (adt) | ||||
| val = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_MAP); | val = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_MAP); | ||||
| if (min > val) min = val; | if (min > val) min = val; | ||||
| if (max < val) max = val; | if (max < val) max = val; | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| if (min == max) { | if (min == max) { | ||||
| /* just use the current frame ranges */ | /* just use the current frame ranges */ | ||||
| min = (float)PSFRA; | min = (float)PSFRA; | ||||
| max = (float)PEFRA; | max = (float)PEFRA; | ||||
| } | } | ||||
| range[0] = min; | range[0] = min; | ||||
| Show All 35 Lines | else { | ||||
| BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", val); | BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", val); | ||||
| } | } | ||||
| BLI_snprintf(str, UI_MAX_DRAW_STR, IFACE_("TimeSlide: %s"), &tvec[0]); | BLI_snprintf(str, UI_MAX_DRAW_STR, IFACE_("TimeSlide: %s"), &tvec[0]); | ||||
| } | } | ||||
| static void applyTimeSlideValue(TransInfo *t, float sval) | static void applyTimeSlideValue(TransInfo *t, float sval) | ||||
| { | { | ||||
| TransData *td = t->data; | |||||
| int i; | int i; | ||||
| const float *range = t->custom.mode.data; | const float *range = t->custom.mode.data; | ||||
| float minx = range[0]; | float minx = range[0]; | ||||
| float maxx = range[1]; | float maxx = range[1]; | ||||
| /* set value for drawing black line */ | /* set value for drawing black line */ | ||||
| if (t->spacetype == SPACE_ACTION) { | if (t->spacetype == SPACE_ACTION) { | ||||
| SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; | SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; | ||||
| float cvalf = t->values[0]; | float cvalf = t->values[0]; | ||||
| saction->timeslide = cvalf; | saction->timeslide = cvalf; | ||||
| } | } | ||||
| /* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */ | /* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */ | ||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| /* it is assumed that td->extra is a pointer to the AnimData, | /* it is assumed that td->extra is a pointer to the AnimData, | ||||
| * whose active action is where this keyframe comes from | * whose active action is where this keyframe comes from | ||||
| * (this is only valid when not in NLA) | * (this is only valid when not in NLA) | ||||
| */ | */ | ||||
| AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL; | AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL; | ||||
| float cval = t->values[0]; | float cval = t->values[0]; | ||||
| /* only apply to data if in range */ | /* only apply to data if in range */ | ||||
| Show All 24 Lines | if ((sval > minx) && (sval < maxx)) { | ||||
| } | } | ||||
| if (adt) { | if (adt) { | ||||
| /* global to strip */ | /* global to strip */ | ||||
| *(td->val) = BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_UNMAP); | *(td->val) = BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_UNMAP); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| static void applyTimeSlide(TransInfo *t, const int mval[2]) | static void applyTimeSlide(TransInfo *t, const int mval[2]) | ||||
| { | { | ||||
| View2D *v2d = (View2D *)t->view; | View2D *v2d = (View2D *)t->view; | ||||
| float cval[2], sval[2]; | float cval[2], sval[2]; | ||||
| const float *range = t->custom.mode.data; | const float *range = t->custom.mode.data; | ||||
| float minx = range[0]; | float minx = range[0]; | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | static void initTimeScale(TransInfo *t) | ||||
| } | } | ||||
| t->mode = TFM_TIME_SCALE; | t->mode = TFM_TIME_SCALE; | ||||
| t->transform = applyTimeScale; | t->transform = applyTimeScale; | ||||
| /* recalculate center2d to use CFRA and mouse Y, since that's | /* recalculate center2d to use CFRA and mouse Y, since that's | ||||
| * what is used in time scale */ | * what is used in time scale */ | ||||
| if ((t->flag & T_OVERRIDE_CENTER) == 0) { | if ((t->flag & T_OVERRIDE_CENTER) == 0) { | ||||
| t->center[0] = t->scene->r.cfra; | t->center_global[0] = t->scene->r.cfra; | ||||
| projectFloatView(t, t->center, center); | projectFloatView(t, t->center_global, center); | ||||
| center[1] = t->mouse.imval[1]; | center[1] = t->mouse.imval[1]; | ||||
| } | } | ||||
| /* force a reinit with the center2d used here */ | /* force a reinit with the center2d used here */ | ||||
| initMouseInput(t, &t->mouse, center, t->mouse.imval, false); | initMouseInput(t, &t->mouse, center, t->mouse.imval, false); | ||||
| initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP); | initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP); | ||||
| Show All 24 Lines | else | ||||
| BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", t->values[0]); | BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", t->values[0]); | ||||
| BLI_snprintf(str, UI_MAX_DRAW_STR, IFACE_("ScaleX: %s"), &tvec[0]); | BLI_snprintf(str, UI_MAX_DRAW_STR, IFACE_("ScaleX: %s"), &tvec[0]); | ||||
| } | } | ||||
| static void applyTimeScaleValue(TransInfo *t) | static void applyTimeScaleValue(TransInfo *t) | ||||
| { | { | ||||
| Scene *scene = t->scene; | Scene *scene = t->scene; | ||||
| TransData *td = t->data; | |||||
| TransData2D *td2d = t->data2d; | |||||
| int i; | int i; | ||||
| const short autosnap = getAnimEdit_SnapMode(t); | const short autosnap = getAnimEdit_SnapMode(t); | ||||
| const double secf = FPS; | const double secf = FPS; | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | |||||
| for (i = 0; i < t->total; i++, td++, td2d++) { | TransData *td = tc->data; | ||||
| TransData2D *td2d = tc->data_2d; | |||||
| for (i = 0; i < tc->data_len; i++, td++, td2d++) { | |||||
| /* it is assumed that td->extra is a pointer to the AnimData, | /* it is assumed that td->extra is a pointer to the AnimData, | ||||
| * whose active action is where this keyframe comes from | * whose active action is where this keyframe comes from | ||||
| * (this is only valid when not in NLA) | * (this is only valid when not in NLA) | ||||
| */ | */ | ||||
| AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL; | AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL; | ||||
| float startx = CFRA; | float startx = CFRA; | ||||
| float fac = t->values[0]; | float fac = t->values[0]; | ||||
| Show All 9 Lines | if (adt) | ||||
| startx = BKE_nla_tweakedit_remap(adt, startx, NLATIME_CONVERT_UNMAP); | startx = BKE_nla_tweakedit_remap(adt, startx, NLATIME_CONVERT_UNMAP); | ||||
| /* now, calculate the new value */ | /* now, calculate the new value */ | ||||
| *(td->val) = ((td->ival - startx) * fac) + startx; | *(td->val) = ((td->ival - startx) * fac) + startx; | ||||
| /* apply nearest snapping */ | /* apply nearest snapping */ | ||||
| doAnimEdit_SnapFrame(t, td, td2d, adt, autosnap); | doAnimEdit_SnapFrame(t, td, td2d, adt, autosnap); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| static void applyTimeScale(TransInfo *t, const int UNUSED(mval[2])) | static void applyTimeScale(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| /* handle numeric-input stuff */ | /* handle numeric-input stuff */ | ||||
| t->vec[0] = t->values[0]; | t->vec[0] = t->values[0]; | ||||
| Show All 11 Lines | |||||
| /* TODO, move to: transform_queries.c */ | /* TODO, move to: transform_queries.c */ | ||||
| bool checkUseAxisMatrix(TransInfo *t) | bool checkUseAxisMatrix(TransInfo *t) | ||||
| { | { | ||||
| /* currently only checks for editmode */ | /* currently only checks for editmode */ | ||||
| if (t->flag & T_EDIT) { | if (t->flag & T_EDIT) { | ||||
| if ((t->around == V3D_AROUND_LOCAL_ORIGINS) && | if ((t->around == V3D_AROUND_LOCAL_ORIGINS) && | ||||
| (ELEM(t->obedit->type, OB_MESH, OB_CURVE, OB_MBALL, OB_ARMATURE))) | (ELEM(t->obedit_type, OB_MESH, OB_CURVE, OB_MBALL, OB_ARMATURE))) | ||||
| { | { | ||||
| /* not all editmode supports axis-matrix */ | /* not all editmode supports axis-matrix */ | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||