Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_mode_bend.c
| Show All 37 Lines | |||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "transform.h" | #include "transform.h" | ||||
| #include "transform_data.h" | |||||
| #include "transform_mode.h" | #include "transform_mode.h" | ||||
| #include "transform_snap.h" | #include "transform_snap.h" | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /* Transform (Bend) */ | /* Transform (Bend) */ | ||||
| /** \name Transform Bend | /** \name Transform Bend | ||||
| * \{ */ | * \{ */ | ||||
| Show All 21 Lines | static eRedrawFlag handleEventBend(TransInfo *UNUSED(t), const wmEvent *event) | ||||
| return status; | return status; | ||||
| } | } | ||||
| static void Bend(TransInfo *t, const int UNUSED(mval[2])) | static void Bend(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| float vec[3]; | float vec[3]; | ||||
| float pivot_global[3]; | float pivot_global[3]; | ||||
| float warp_end_radius_global[3]; | float warp_end_radius_global[3]; | ||||
| 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; | ||||
| union { | union { | ||||
| struct { | struct { | ||||
| float angle, scale; | float angle, scale; | ||||
| }; | }; | ||||
| ▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | #endif | ||||
| else { | else { | ||||
| madd_v3_v3fl(pivot_global, | madd_v3_v3fl(pivot_global, | ||||
| data->warp_tan, | data->warp_tan, | ||||
| +values.scale * shell_angle_to_dist((float)M_PI_2 + values.angle)); | +values.scale * shell_angle_to_dist((float)M_PI_2 + values.angle)); | ||||
| } | } | ||||
| /* TODO(campbell): xform, compensate object center. */ | /* TODO(campbell): xform, compensate object center. */ | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| float warp_sta_local[3]; | float warp_sta_local[3]; | ||||
| float warp_end_local[3]; | float warp_end_local[3]; | ||||
| float warp_end_radius_local[3]; | float warp_end_radius_local[3]; | ||||
| float pivot_local[3]; | float pivot_local[3]; | ||||
| if (tc->use_local_mat) { | if (tc->use_local_mat) { | ||||
| sub_v3_v3v3(warp_sta_local, data->warp_sta, tc->mat[3]); | sub_v3_v3v3(warp_sta_local, data->warp_sta, tc->mat[3]); | ||||
| sub_v3_v3v3(warp_end_local, data->warp_end, tc->mat[3]); | sub_v3_v3v3(warp_end_local, data->warp_end, tc->mat[3]); | ||||
| sub_v3_v3v3(warp_end_radius_local, warp_end_radius_global, tc->mat[3]); | sub_v3_v3v3(warp_end_radius_local, warp_end_radius_global, tc->mat[3]); | ||||
| sub_v3_v3v3(pivot_local, pivot_global, tc->mat[3]); | sub_v3_v3v3(pivot_local, pivot_global, tc->mat[3]); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v3_v3(warp_sta_local, data->warp_sta); | copy_v3_v3(warp_sta_local, data->warp_sta); | ||||
| copy_v3_v3(warp_end_local, data->warp_end); | copy_v3_v3(warp_end_local, data->warp_end); | ||||
| copy_v3_v3(warp_end_radius_local, warp_end_radius_global); | copy_v3_v3(warp_end_radius_local, warp_end_radius_global); | ||||
| copy_v3_v3(pivot_local, pivot_global); | copy_v3_v3(pivot_local, pivot_global); | ||||
| } | } | ||||
| for (i = 0; i < tc->data_len; i++, td++) { | TransData *td = tc->data; | ||||
| for (int tdi = 0; tdi < tc->data_len; tdi++) { | |||||
| 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_SKIP) { | if (td->basic[tdi].flag & TD_SKIP) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (UNLIKELY(values.angle == 0.0f)) { | if (UNLIKELY(values.angle == 0.0f)) { | ||||
| copy_v3_v3(td->loc, td->iloc); | copy_v3_v3(td->basic[tdi].loc, td->basic[tdi].iloc); | ||||
| continue; | continue; | ||||
| } | } | ||||
| copy_v3_v3(vec, td->iloc); | copy_v3_v3(vec, td->basic[tdi].iloc); | ||||
| mul_m3_v3(td->mtx, vec); | mul_m3_v3(td->space[tdi].mtx, vec); | ||||
| fac = line_point_factor_v3(vec, warp_sta_local, warp_end_radius_local); | fac = line_point_factor_v3(vec, warp_sta_local, warp_end_radius_local); | ||||
| if (is_clamp) { | if (is_clamp) { | ||||
| CLAMP(fac, 0.0f, 1.0f); | CLAMP(fac, 0.0f, 1.0f); | ||||
| } | } | ||||
| if (t->options & CTX_GPENCIL_STROKES) { | if (t->options & CTX_GPENCIL_STROKES) { | ||||
| /* grease pencil multiframe falloff */ | /* grease pencil multiframe falloff */ | ||||
| bGPDstroke *gps = (bGPDstroke *)td->extra; | bGPDstroke *gps = (bGPDstroke *)td->basic[tdi].extra; | ||||
| if (gps != NULL) { | if (gps != NULL) { | ||||
| fac_scaled = fac * td->factor * gps->runtime.multi_frame_falloff; | fac_scaled = fac * td->prop[tdi].factor * gps->runtime.multi_frame_falloff; | ||||
| } | } | ||||
| else { | else { | ||||
| fac_scaled = fac * td->factor; | fac_scaled = fac * td->prop[tdi].factor; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| fac_scaled = fac * td->factor; | fac_scaled = fac * td->prop[tdi].factor; | ||||
| } | } | ||||
| axis_angle_normalized_to_mat3(mat, data->warp_nor, values.angle * fac_scaled); | axis_angle_normalized_to_mat3(mat, data->warp_nor, values.angle * fac_scaled); | ||||
| interp_v3_v3v3(delta, warp_sta_local, warp_end_radius_local, fac_scaled); | interp_v3_v3v3(delta, warp_sta_local, warp_end_radius_local, fac_scaled); | ||||
| sub_v3_v3(delta, warp_sta_local); | sub_v3_v3(delta, warp_sta_local); | ||||
| /* delta is subtracted, rotation adds back this offset */ | /* delta is subtracted, rotation adds back this offset */ | ||||
| sub_v3_v3(vec, delta); | sub_v3_v3(vec, delta); | ||||
| sub_v3_v3(vec, pivot_local); | sub_v3_v3(vec, pivot_local); | ||||
| mul_m3_v3(mat, vec); | mul_m3_v3(mat, vec); | ||||
| add_v3_v3(vec, pivot_local); | add_v3_v3(vec, pivot_local); | ||||
| mul_m3_v3(td->smtx, vec); | mul_m3_v3(td->space[tdi].smtx, vec); | ||||
| /* rotation */ | /* rotation */ | ||||
| if ((t->flag & T_POINTS) == 0) { | if ((t->flag & T_POINTS) == 0) { | ||||
| ElementRotation(t, tc, td, mat, V3D_AROUND_LOCAL_ORIGINS); | ElementRotation(t, tc, tdi, mat, V3D_AROUND_LOCAL_ORIGINS); | ||||
| } | } | ||||
| /* location */ | /* location */ | ||||
| copy_v3_v3(td->loc, vec); | copy_v3_v3(td->basic[tdi].loc, vec); | ||||
| } | } | ||||
| } | } | ||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_status_text(t->area, str); | ED_area_status_text(t->area, str); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines | |||||