Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_mode_vert_slide.c
| Show First 20 Lines • Show All 460 Lines • ▼ Show 20 Lines | /* Non-Prop mode */ | ||||
| GPU_matrix_pop(); | GPU_matrix_pop(); | ||||
| GPU_depth_test(GPU_DEPTH_LESS_EQUAL); | GPU_depth_test(GPU_DEPTH_LESS_EQUAL); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void vert_slide_apply_elem(const VertSlideData *sld, | |||||
| const TransDataVertSlideVert *sv, | |||||
| const float perc, | |||||
| const bool use_even, | |||||
| const bool use_flip, | |||||
| float r_co[3]) | |||||
| { | |||||
| if (use_even == false) { | |||||
| interp_v3_v3v3(r_co, sv->co_orig_3d, sv->co_link_orig_3d[sv->co_link_curr], perc); | |||||
| } | |||||
| else { | |||||
| float dir[3]; | |||||
| sub_v3_v3v3(dir, sv->co_link_orig_3d[sv->co_link_curr], sv->co_orig_3d); | |||||
| float edge_len = normalize_v3(dir); | |||||
| if (edge_len > FLT_EPSILON) { | |||||
| if (use_flip) { | |||||
| madd_v3_v3v3fl(r_co, sv->co_link_orig_3d[sv->co_link_curr], dir, -perc); | |||||
| } | |||||
| else { | |||||
| madd_v3_v3v3fl(r_co, sv->co_orig_3d, dir, perc); | |||||
| } | |||||
| } | |||||
| else { | |||||
| copy_v3_v3(r_co, sv->co_orig_3d); | |||||
| } | |||||
| } | |||||
| } | |||||
| static void doVertSlide(TransInfo *t, float perc) | static void doVertSlide(TransInfo *t, float perc) | ||||
| { | { | ||||
| VertSlideParams *slp = t->custom.mode.data; | VertSlideParams *slp = t->custom.mode.data; | ||||
| slp->perc = perc; | slp->perc = perc; | ||||
| const bool use_even = slp->use_even; | |||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| VertSlideData *sld = tc->custom.mode.data; | VertSlideData *sld = tc->custom.mode.data; | ||||
| if (sld == NULL) { | if (sld == NULL) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| TransDataVertSlideVert *svlist = sld->sv, *sv; | float tperc = perc; | ||||
| int i; | if (use_even) { | ||||
| sv = svlist; | |||||
| if (slp->use_even == false) { | |||||
| for (i = 0; i < sld->totsv; i++, sv++) { | |||||
| interp_v3_v3v3(sv->v->co, sv->co_orig_3d, sv->co_link_orig_3d[sv->co_link_curr], perc); | |||||
| } | |||||
| } | |||||
| else { | |||||
| TransDataVertSlideVert *sv_curr = &sld->sv[sld->curr_sv_index]; | TransDataVertSlideVert *sv_curr = &sld->sv[sld->curr_sv_index]; | ||||
| const float edge_len_curr = len_v3v3(sv_curr->co_orig_3d, | const float edge_len_curr = len_v3v3(sv_curr->co_orig_3d, | ||||
| sv_curr->co_link_orig_3d[sv_curr->co_link_curr]); | sv_curr->co_link_orig_3d[sv_curr->co_link_curr]); | ||||
| const float tperc = perc * edge_len_curr; | tperc *= edge_len_curr; | ||||
| for (i = 0; i < sld->totsv; i++, sv++) { | |||||
| float edge_len; | |||||
| float dir[3]; | |||||
| sub_v3_v3v3(dir, sv->co_link_orig_3d[sv->co_link_curr], sv->co_orig_3d); | |||||
| edge_len = normalize_v3(dir); | |||||
| if (edge_len > FLT_EPSILON) { | |||||
| if (slp->flipped) { | |||||
| madd_v3_v3v3fl(sv->v->co, sv->co_link_orig_3d[sv->co_link_curr], dir, -tperc); | |||||
| } | |||||
| else { | |||||
| madd_v3_v3v3fl(sv->v->co, sv->co_orig_3d, dir, tperc); | |||||
| } | |||||
| } | |||||
| else { | |||||
| copy_v3_v3(sv->v->co, sv->co_orig_3d); | |||||
| } | |||||
| } | } | ||||
| TransDataVertSlideVert *sv = sld->sv; | |||||
| for (int i = 0; i < sld->totsv; i++, sv++) { | |||||
| vert_slide_apply_elem(sld, sv, tperc, use_even, slp->flipped, sv->v->co); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void vert_slide_snap_apply(TransInfo *t, float *value) | static void vert_slide_snap_apply(TransInfo *t, float *value) | ||||
| { | { | ||||
| TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_OK(t); | TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_OK(t); | ||||
| VertSlideData *sld = tc->custom.mode.data; | VertSlideData *sld = tc->custom.mode.data; | ||||
| ▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | static void applyVertSlide(TransInfo *t, const int UNUSED(mval[2])) | ||||
| /* do stuff here */ | /* do stuff here */ | ||||
| doVertSlide(t, final); | doVertSlide(t, final); | ||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_status_text(t->area, str); | ED_area_status_text(t->area, str); | ||||
| } | } | ||||
| static void vert_slide_transform_matrix_fn(struct TransInfo *t, float mat_xform[4][4]) | |||||
| { | |||||
| float delta[3], orig_co[3], final_co[3]; | |||||
| VertSlideParams *slp = t->custom.mode.data; | |||||
| TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_OK(t); | |||||
| VertSlideData *sld_active = tc->custom.mode.data; | |||||
| TransDataVertSlideVert *sv_active = &sld_active->sv[sld_active->curr_sv_index]; | |||||
| copy_v3_v3(orig_co, sv_active->co_orig_3d); | |||||
| float tperc = t->values_final[0]; | |||||
| if (slp->use_even) { | |||||
| const float edge_len_curr = len_v3v3(sv_active->co_orig_3d, | |||||
| sv_active->co_link_orig_3d[sv_active->co_link_curr]); | |||||
| tperc *= edge_len_curr; | |||||
| } | |||||
| vert_slide_apply_elem(sld_active, sv_active, tperc, slp->use_even, slp->flipped, final_co); | |||||
| if (tc->use_local_mat) { | |||||
| mul_m4_v3(tc->mat, orig_co); | |||||
| mul_m4_v3(tc->mat, final_co); | |||||
| } | |||||
| sub_v3_v3v3(delta, final_co, orig_co); | |||||
| add_v3_v3(mat_xform[3], delta); | |||||
| } | |||||
| void initVertSlide_ex(TransInfo *t, bool use_even, bool flipped, bool use_clamp) | void initVertSlide_ex(TransInfo *t, bool use_even, bool flipped, bool use_clamp) | ||||
| { | { | ||||
| t->mode = TFM_VERT_SLIDE; | t->mode = TFM_VERT_SLIDE; | ||||
| t->transform = applyVertSlide; | t->transform = applyVertSlide; | ||||
| t->handleEvent = handleEventVertSlide; | t->handleEvent = handleEventVertSlide; | ||||
| t->transform_matrix = NULL; | t->transform_matrix = vert_slide_transform_matrix_fn; | ||||
| t->tsnap.snap_mode_apply_fn = vert_slide_snap_apply; | t->tsnap.snap_mode_apply_fn = vert_slide_snap_apply; | ||||
| t->tsnap.snap_mode_distance_fn = transform_snap_distance_len_squared_fn; | t->tsnap.snap_mode_distance_fn = transform_snap_distance_len_squared_fn; | ||||
| { | { | ||||
| VertSlideParams *slp = MEM_callocN(sizeof(*slp), __func__); | VertSlideParams *slp = MEM_callocN(sizeof(*slp), __func__); | ||||
| slp->use_even = use_even; | slp->use_even = use_even; | ||||
| slp->flipped = flipped; | slp->flipped = flipped; | ||||
| slp->perc = 0.0f; | slp->perc = 0.0f; | ||||
| ▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines | |||||