Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 2,087 Lines • ▼ Show 20 Lines | void saveTransform(bContext *C, TransInfo *t, wmOperator *op) | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| // Save back mode in case we're in the generic operator | // Save back mode in case we're in the generic operator | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "mode"))) { | if ((prop = RNA_struct_find_property(op->ptr, "mode"))) { | ||||
| RNA_property_enum_set(op->ptr, prop, t->mode); | RNA_property_enum_set(op->ptr, prop, t->mode); | ||||
| } | } | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "value"))) { | if ((prop = RNA_struct_find_property(op->ptr, "value"))) { | ||||
| float values[4]; | |||||
| copy_v4_v4(values, (t->flag & T_AUTOVALUES) ? t->auto_values : t->values); | |||||
| if (RNA_property_array_check(prop)) { | if (RNA_property_array_check(prop)) { | ||||
| RNA_property_float_set_array(op->ptr, prop, values); | RNA_property_float_set_array(op->ptr, prop, t->values_final); | ||||
| } | } | ||||
| else { | else { | ||||
| RNA_property_float_set(op->ptr, prop, values[0]); | RNA_property_float_set(op->ptr, prop, t->values_final[0]); | ||||
| } | } | ||||
| } | } | ||||
| if (t->flag & T_PROP_EDIT_ALL) { | if (t->flag & T_PROP_EDIT_ALL) { | ||||
| if (t->flag & T_PROP_EDIT) { | if (t->flag & T_PROP_EDIT) { | ||||
| proportional |= PROP_EDIT_USE; | proportional |= PROP_EDIT_USE; | ||||
| } | } | ||||
| if (t->flag & T_PROP_CONNECTED) { | if (t->flag & T_PROP_CONNECTED) { | ||||
| ▲ Show 20 Lines • Show All 370 Lines • ▼ Show 20 Lines | if ((prop = RNA_struct_find_property(op->ptr, "value")) && RNA_property_is_set(op->ptr, prop)) { | ||||
| copy_v4_v4(t->values, values); | copy_v4_v4(t->values, values); | ||||
| if (t->flag & T_MODAL) { | if (t->flag & T_MODAL) { | ||||
| copy_v4_v4(t->values_modal_offset, values); | copy_v4_v4(t->values_modal_offset, values); | ||||
| t->redraw = TREDRAW_HARD; | t->redraw = TREDRAW_HARD; | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v4_v4(t->auto_values, values); | copy_v4_v4(t->values, values); | ||||
| t->flag |= T_AUTOVALUES; | t->flag |= T_INPUT_IS_VALUES_FINAL; | ||||
| } | } | ||||
| } | } | ||||
| if (event) { | if (event) { | ||||
| /* Initialize accurate transform to settings requested by keymap. */ | /* Initialize accurate transform to settings requested by keymap. */ | ||||
| bool use_accurate = false; | bool use_accurate = false; | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "use_accurate")) && | if ((prop = RNA_struct_find_property(op->ptr, "use_accurate")) && | ||||
| RNA_property_is_set(op->ptr, prop)) { | RNA_property_is_set(op->ptr, prop)) { | ||||
| ▲ Show 20 Lines • Show All 868 Lines • ▼ Show 20 Lines | if (t->tsnap.mode & SCE_SNAP_MODE_INCREMENT) { | ||||
| values.scale /= snap_hack; | values.scale /= snap_hack; | ||||
| } | } | ||||
| #endif | #endif | ||||
| if (applyNumInput(&t->num, values.vector)) { | if (applyNumInput(&t->num, values.vector)) { | ||||
| values.scale = values.scale / data->warp_init_dist; | values.scale = values.scale / data->warp_init_dist; | ||||
| } | } | ||||
| copy_v2_v2(t->values, values.vector); | copy_v2_v2(t->values_final, values.vector); | ||||
| /* header print for NumInput */ | /* header print for NumInput */ | ||||
| if (hasNumInput(&t->num)) { | if (hasNumInput(&t->num)) { | ||||
| char c[NUM_STR_REP_LEN * 2]; | char c[NUM_STR_REP_LEN * 2]; | ||||
| outputNumInput(&(t->num), c, &t->scene->unit); | outputNumInput(&(t->num), c, &t->scene->unit); | ||||
| BLI_snprintf(str, | BLI_snprintf(str, | ||||
| ▲ Show 20 Lines • Show All 224 Lines • ▼ Show 20 Lines | static void applyShear(TransInfo *t, const int UNUSED(mval[2])) | ||||
| const bool is_local_center = transdata_check_local_center(t, t->around); | const bool is_local_center = transdata_check_local_center(t, t->around); | ||||
| value = t->values[0]; | value = t->values[0]; | ||||
| snapGridIncrement(t, &value); | snapGridIncrement(t, &value); | ||||
| applyNumInput(&t->num, &value); | applyNumInput(&t->num, &value); | ||||
| t->values[0] = value; | t->values_final[0] = value; | ||||
| /* 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), TIP_("Shear: %s %s"), c, t->proptext); | BLI_snprintf(str, sizeof(str), TIP_("Shear: %s %s"), c, t->proptext); | ||||
| ▲ Show 20 Lines • Show All 314 Lines • ▼ Show 20 Lines | static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3]) | ||||
| /* grease pencil falloff */ | /* grease pencil falloff */ | ||||
| if (t->options & CTX_GPENCIL_STROKES) { | if (t->options & CTX_GPENCIL_STROKES) { | ||||
| bGPDstroke *gps = (bGPDstroke *)td->extra; | bGPDstroke *gps = (bGPDstroke *)td->extra; | ||||
| mul_v3_fl(vec, td->factor * gps->runtime.multi_frame_falloff); | mul_v3_fl(vec, td->factor * gps->runtime.multi_frame_falloff); | ||||
| /* scale stroke thickness */ | /* scale stroke thickness */ | ||||
| if (td->val) { | if (td->val) { | ||||
| snapGridIncrement(t, t->values); | snapGridIncrement(t, t->values_final); | ||||
| applyNumInput(&t->num, t->values); | applyNumInput(&t->num, t->values_final); | ||||
| float ratio = t->values[0]; | float ratio = t->values_final[0]; | ||||
| *td->val = td->ival * ratio * gps->runtime.multi_frame_falloff; | *td->val = td->ival * ratio * gps->runtime.multi_frame_falloff; | ||||
| CLAMP_MIN(*td->val, 0.001f); | CLAMP_MIN(*td->val, 0.001f); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| mul_v3_fl(vec, td->factor); | mul_v3_fl(vec, td->factor); | ||||
| } | } | ||||
| Show All 10 Lines | |||||
| } | } | ||||
| static void applyResize(TransInfo *t, const int UNUSED(mval[2])) | static void applyResize(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| 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_INPUT_IS_VALUES_FINAL) { | ||||
| copy_v3_v3(t->values, t->auto_values); | copy_v3_v3(t->values_final, t->values); | ||||
| } | } | ||||
| else { | else { | ||||
| float ratio = t->values[0]; | float ratio = t->values[0]; | ||||
| copy_v3_fl(t->values, ratio); | copy_v3_fl(t->values_final, ratio); | ||||
| snapGridIncrement(t, t->values); | snapGridIncrement(t, t->values_final); | ||||
| if (applyNumInput(&t->num, t->values)) { | if (applyNumInput(&t->num, t->values_final)) { | ||||
| constraintNumInput(t, t->values); | constraintNumInput(t, t->values_final); | ||||
| } | } | ||||
| applySnapping(t, t->values); | applySnapping(t, t->values_final); | ||||
| } | } | ||||
| size_to_mat3(mat, t->values); | size_to_mat3(mat, t->values_final); | ||||
| if (t->con.mode & CON_APPLY) { | if (t->con.mode & CON_APPLY) { | ||||
| t->con.applySize(t, NULL, NULL, mat); | t->con.applySize(t, NULL, NULL, mat); | ||||
| /* Only so we have re-usable value with redo. */ | /* Only so we have re-usable value with redo. */ | ||||
| float pvec[3] = {0.0f, 0.0f, 0.0f}; | float pvec[3] = {0.0f, 0.0f, 0.0f}; | ||||
| int j = 0; | int j = 0; | ||||
| for (i = 0; i < 3; i++) { | for (i = 0; i < 3; i++) { | ||||
| if (!(t->con.mode & (CON_AXIS0 << i))) { | if (!(t->con.mode & (CON_AXIS0 << i))) { | ||||
| t->values[i] = 1.0f; | t->values_final[i] = 1.0f; | ||||
| } | } | ||||
| else { | else { | ||||
| pvec[j++] = t->values[i]; | pvec[j++] = t->values_final[i]; | ||||
| } | } | ||||
| } | } | ||||
| headerResize(t, pvec, str); | headerResize(t, pvec, str); | ||||
| } | } | ||||
| else { | else { | ||||
| headerResize(t, t->values, str); | headerResize(t, t->values_final, str); | ||||
| } | } | ||||
| copy_m3_m3(t->mat, mat); // used in gizmo | copy_m3_m3(t->mat, mat); // used in gizmo | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | TransData *td = tc->data; | ||||
| for (i = 0; i < tc->data_len; i++, td++) { | 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, tc, td, mat); | ElementResize(t, tc, td, mat); | ||||
| } | } | ||||
| } | } | ||||
| /* 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_final, 1)) { | ||||
| size_to_mat3(mat, t->values); | size_to_mat3(mat, t->values_final); | ||||
| if (t->con.mode & CON_APPLY) { | if (t->con.mode & CON_APPLY) { | ||||
| t->con.applySize(t, NULL, NULL, mat); | t->con.applySize(t, NULL, NULL, mat); | ||||
| } | } | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | TransData *td = tc->data; | ||||
| for (i = 0; i < tc->data_len; i++, td++) { | for (i = 0; i < tc->data_len; i++, td++) { | ||||
| ▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | #endif | ||||
| 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])) | ||||
| { | { | ||||
| float size[3], mat[3][3]; | float 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]); | if (t->flag & T_INPUT_IS_VALUES_FINAL) { | ||||
| copy_v3_v3(t->values_final, t->values); | |||||
| snapGridIncrement(t, size); | |||||
| if (applyNumInput(&t->num, size)) { | |||||
| constraintNumInput(t, size); | |||||
| } | } | ||||
| else { | |||||
| copy_v3_fl(t->values_final, t->values[0]); | |||||
| applySnapping(t, size); | snapGridIncrement(t, t->values_final); | ||||
| if (t->flag & T_AUTOVALUES) { | if (applyNumInput(&t->num, t->values_final)) { | ||||
| copy_v3_v3(size, t->auto_values); | constraintNumInput(t, t->values_final); | ||||
| } | } | ||||
| copy_v3_v3(t->values, size); | applySnapping(t, t->values_final); | ||||
| } | |||||
| size_to_mat3(mat, size); | size_to_mat3(mat, t->values_final); | ||||
| headerResize(t, size, str); | headerResize(t, t->values_final, str); | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | TransData *td = tc->data; | ||||
| for (i = 0; i < tc->data_len; i++, td++) { | 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) { | ||||
| ▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | static void applyToSphere(TransInfo *t, const int UNUSED(mval[2])) | ||||
| 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_final[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), TIP_("To Sphere: %s %s"), c, t->proptext); | BLI_snprintf(str, sizeof(str), TIP_("To Sphere: %s %s"), c, t->proptext); | ||||
| ▲ Show 20 Lines • Show All 449 Lines • ▼ Show 20 Lines | static void applyRotation(TransInfo *t, const int UNUSED(mval[2])) | ||||
| applySnapping(t, &final); | applySnapping(t, &final); | ||||
| if (applyNumInput(&t->num, &final)) { | if (applyNumInput(&t->num, &final)) { | ||||
| /* We have to limit the amount of turns to a reasonable number here, | /* We have to limit the amount of turns to a reasonable number here, | ||||
| * to avoid things getting *very* slow, see how applyRotationValue() handles those... */ | * to avoid things getting *very* slow, see how applyRotationValue() handles those... */ | ||||
| final = large_rotation_limit(final); | final = large_rotation_limit(final); | ||||
| } | } | ||||
| t->values[0] = final; | t->values_final[0] = final; | ||||
| headerRotation(t, str, final); | headerRotation(t, str, final); | ||||
| const bool is_large_rotation = hasNumInput(&t->num); | const bool is_large_rotation = hasNumInput(&t->num); | ||||
| applyRotationValue(t, final, axis_final, is_large_rotation); | applyRotationValue(t, final, axis_final, is_large_rotation); | ||||
| recalcData(t); | recalcData(t); | ||||
| ▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | #endif | ||||
| normalize_v3(axis2); | normalize_v3(axis2); | ||||
| copy_v2_v2(phi, t->values); | copy_v2_v2(phi, t->values); | ||||
| snapGridIncrement(t, phi); | snapGridIncrement(t, phi); | ||||
| applyNumInput(&t->num, phi); | applyNumInput(&t->num, phi); | ||||
| copy_v2_v2(t->values, phi); | copy_v2_v2(t->values_final, phi); | ||||
| if (hasNumInput(&t->num)) { | if (hasNumInput(&t->num)) { | ||||
| char c[NUM_STR_REP_LEN * 2]; | char c[NUM_STR_REP_LEN * 2]; | ||||
| outputNumInput(&(t->num), c, &t->scene->unit); | outputNumInput(&(t->num), c, &t->scene->unit); | ||||
| ofs += BLI_snprintf(str + ofs, | ofs += BLI_snprintf(str + ofs, | ||||
| sizeof(str) - ofs, | sizeof(str) - ofs, | ||||
| ▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| axis_angle_normalized_to_mat3(mat, axis, angle); | axis_angle_normalized_to_mat3(mat, axis, angle); | ||||
| for (int i = 0; i < lnors_ed_arr->totloop; i++, lnor_ed++) { | for (int i = 0; i < lnors_ed_arr->totloop; i++, lnor_ed++) { | ||||
| mul_v3_m3v3(lnor_ed->nloc, mat, lnor_ed->niloc); | mul_v3_m3v3(lnor_ed->nloc, mat, lnor_ed->niloc); | ||||
| BKE_lnor_space_custom_normal_to_data( | BKE_lnor_space_custom_normal_to_data( | ||||
| bm->lnor_spacearr->lspacearr[lnor_ed->loop_index], lnor_ed->nloc, lnor_ed->clnors_data); | bm->lnor_spacearr->lspacearr[lnor_ed->loop_index], lnor_ed->nloc, lnor_ed->clnors_data); | ||||
| } | } | ||||
| t->values_final[0] = angle; | |||||
| } | } | ||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_status_text(t->sa, str); | ED_area_status_text(t->sa, str); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| ▲ Show 20 Lines • Show All 340 Lines • ▼ Show 20 Lines | for (int i = 0; i < tc->data_len; i++, td++) { | ||||
| constraintTransLim(t, td); | constraintTransLim(t, td); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| 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 values_final[3]; | ||||
| if (t->flag & T_AUTOVALUES) { | if (t->flag & T_INPUT_IS_VALUES_FINAL) { | ||||
| copy_v3_v3(t->values, t->auto_values); | copy_v3_v3(t->values_final, t->values); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v3_v3(t->values_final, t->values); | |||||
| if ((t->con.mode & CON_APPLY) == 0) { | if ((t->con.mode & CON_APPLY) == 0) { | ||||
| snapGridIncrement(t, t->values); | snapGridIncrement(t, t->values_final); | ||||
| } | } | ||||
| if (applyNumInput(&t->num, t->values)) { | if (applyNumInput(&t->num, t->values_final)) { | ||||
| removeAspectRatio(t, t->values); | removeAspectRatio(t, t->values_final); | ||||
| } | } | ||||
| applySnapping(t, t->values); | applySnapping(t, t->values_final); | ||||
| } | } | ||||
| copy_v3_v3(values_final, t->values_final); | |||||
| 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, NULL, t->values, value_final, pvec); | t->con.applyVec(t, NULL, NULL, t->values_final, values_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_final, t->con.imtx, values_final); | ||||
| } | } | ||||
| else { | else { | ||||
| headerTranslation(t, t->values, str); | headerTranslation(t, t->values_final, str); | ||||
| copy_v3_v3(value_final, t->values); | copy_v3_v3(values_final, t->values_final); | ||||
| } | } | ||||
| /* don't use 't->values' now on */ | /* don't use 't->values' now on */ | ||||
| applyTranslationValue(t, value_final); | applyTranslationValue(t, values_final); | ||||
| /* evil hack - redo translation if clipping needed */ | /* evil hack - redo translation if clipping needed */ | ||||
| if (t->flag & T_CLIP_UV && clipUVTransform(t, value_final, 0)) { | if (t->flag & T_CLIP_UV && clipUVTransform(t, values_final, 0)) { | ||||
| applyTranslationValue(t, value_final); | applyTranslationValue(t, values_final); | ||||
| /* 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); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) | ||||
| size_t ofs = 0; | size_t ofs = 0; | ||||
| 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_final[0] = -distance; | ||||
| /* header print for NumInput */ | /* header print for NumInput */ | ||||
| ofs += BLI_strncpy_rlen(str + ofs, TIP_("Shrink/Fatten:"), sizeof(str) - ofs); | ofs += BLI_strncpy_rlen(str + ofs, TIP_("Shrink/Fatten:"), sizeof(str) - ofs); | ||||
| 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); | ||||
| ofs += BLI_snprintf(str + ofs, sizeof(str) - ofs, " %s", c); | ofs += BLI_snprintf(str + ofs, sizeof(str) - ofs, " %s", c); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | static void applyTilt(TransInfo *t, const int UNUSED(mval[2])) | ||||
| float final; | float final; | ||||
| final = t->values[0]; | final = t->values[0]; | ||||
| snapGridIncrement(t, &final); | snapGridIncrement(t, &final); | ||||
| applyNumInput(&t->num, &final); | applyNumInput(&t->num, &final); | ||||
| t->values[0] = final; | t->values_final[0] = final; | ||||
| 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), TIP_("Tilt: %s° %s"), &c[0], t->proptext); | BLI_snprintf(str, sizeof(str), TIP_("Tilt: %s° %s"), &c[0], t->proptext); | ||||
| /* 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_final[0] = final; | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_snprintf(str, sizeof(str), TIP_("Tilt: %.2f° %s"), RAD2DEGF(final), t->proptext); | BLI_snprintf(str, sizeof(str), TIP_("Tilt: %.2f° %s"), RAD2DEGF(final), t->proptext); | ||||
| } | } | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | TransData *td = tc->data; | ||||
| for (i = 0; i < tc->data_len; i++, td++) { | for (i = 0; i < tc->data_len; i++, td++) { | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) | ||||
| 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_final[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), TIP_("Shrink/Fatten: %s"), c); | BLI_snprintf(str, sizeof(str), TIP_("Shrink/Fatten: %s"), c); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) | ||||
| 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_final[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), TIP_("Feather Shrink/Fatten: %s"), c); | BLI_snprintf(str, sizeof(str), TIP_("Feather Shrink/Fatten: %s"), c); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) | ||||
| 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_final[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), TIP_("Shrink/Fatten: %s"), c); | BLI_snprintf(str, sizeof(str), TIP_("Shrink/Fatten: %s"), c); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | static void applyGPOpacity(TransInfo *t, const int UNUSED(mval[2])) | ||||
| 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_final[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), TIP_("Opacity: %s"), c); | BLI_snprintf(str, sizeof(str), TIP_("Opacity: %s"), c); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | static void applyPushPull(TransInfo *t, const int UNUSED(mval[2])) | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| 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_final[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), TIP_("Push/Pull: %s%s %s"), c, t->con.text, t->proptext); | BLI_snprintf(str, sizeof(str), TIP_("Push/Pull: %s%s %s"), c, t->con.text, t->proptext); | ||||
| ▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2])) | ||||
| weight = t->values[0]; | weight = t->values[0]; | ||||
| CLAMP_MAX(weight, 1.0f); | CLAMP_MAX(weight, 1.0f); | ||||
| snapGridIncrement(t, &weight); | snapGridIncrement(t, &weight); | ||||
| applyNumInput(&t->num, &weight); | applyNumInput(&t->num, &weight); | ||||
| t->values[0] = weight; | t->values_final[0] = weight; | ||||
| /* 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); | ||||
| if (weight >= 0.0f) { | if (weight >= 0.0f) { | ||||
| ▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | static void applyCrease(TransInfo *t, const int UNUSED(mval[2])) | ||||
| crease = t->values[0]; | crease = t->values[0]; | ||||
| CLAMP_MAX(crease, 1.0f); | CLAMP_MAX(crease, 1.0f); | ||||
| snapGridIncrement(t, &crease); | snapGridIncrement(t, &crease); | ||||
| applyNumInput(&t->num, &crease); | applyNumInput(&t->num, &crease); | ||||
| t->values[0] = crease; | t->values_final[0] = crease; | ||||
| /* 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); | ||||
| if (crease >= 0.0f) { | if (crease >= 0.0f) { | ||||
| ▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2])) | ||||
| 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_final, size); | ||||
| size_to_mat3(mat, size); | size_to_mat3(mat, size); | ||||
| if (t->con.applySize) { | if (t->con.applySize) { | ||||
| t->con.applySize(t, NULL, NULL, mat); | t->con.applySize(t, NULL, NULL, mat); | ||||
| } | } | ||||
| copy_m3_m3(t->mat, mat); // used in gizmo | copy_m3_m3(t->mat, mat); // used in gizmo | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2])) | ||||
| 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_final[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), TIP_("Envelope: %s"), c); | BLI_snprintf(str, sizeof(str), TIP_("Envelope: %s"), c); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,797 Lines • ▼ Show 20 Lines | static void applyEdgeSlide(TransInfo *t, const int UNUSED(mval[2])) | ||||
| /* only do this so out of range values are not displayed */ | /* only do this so out of range values are not displayed */ | ||||
| if (is_constrained) { | if (is_constrained) { | ||||
| CLAMP(final, -1.0f, 1.0f); | CLAMP(final, -1.0f, 1.0f); | ||||
| } | } | ||||
| applyNumInput(&t->num, &final); | applyNumInput(&t->num, &final); | ||||
| t->values[0] = final; | t->values_final[0] = final; | ||||
| /* header string */ | /* header string */ | ||||
| ofs += BLI_strncpy_rlen(str + ofs, TIP_("Edge Slide: "), sizeof(str) - ofs); | ofs += BLI_strncpy_rlen(str + ofs, TIP_("Edge Slide: "), sizeof(str) - ofs); | ||||
| 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); | ||||
| ofs += BLI_strncpy_rlen(str + ofs, &c[0], sizeof(str) - ofs); | ofs += BLI_strncpy_rlen(str + ofs, &c[0], sizeof(str) - ofs); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 594 Lines • ▼ Show 20 Lines | static void applyVertSlide(TransInfo *t, const int UNUSED(mval[2])) | ||||
| /* only do this so out of range values are not displayed */ | /* only do this so out of range values are not displayed */ | ||||
| if (is_constrained) { | if (is_constrained) { | ||||
| CLAMP(final, 0.0f, 1.0f); | CLAMP(final, 0.0f, 1.0f); | ||||
| } | } | ||||
| applyNumInput(&t->num, &final); | applyNumInput(&t->num, &final); | ||||
| t->values[0] = final; | t->values_final[0] = final; | ||||
| /* header string */ | /* header string */ | ||||
| ofs += BLI_strncpy_rlen(str + ofs, TIP_("Vert Slide: "), sizeof(str) - ofs); | ofs += BLI_strncpy_rlen(str + ofs, TIP_("Vert Slide: "), sizeof(str) - ofs); | ||||
| 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); | ||||
| ofs += BLI_strncpy_rlen(str + ofs, &c[0], sizeof(str) - ofs); | ofs += BLI_strncpy_rlen(str + ofs, &c[0], sizeof(str) - ofs); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | static void applyBoneRoll(TransInfo *t, const int UNUSED(mval[2])) | ||||
| float final; | float final; | ||||
| final = t->values[0]; | final = t->values[0]; | ||||
| snapGridIncrement(t, &final); | snapGridIncrement(t, &final); | ||||
| applyNumInput(&t->num, &final); | applyNumInput(&t->num, &final); | ||||
| t->values[0] = final; | t->values_final[0] = final; | ||||
| 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), TIP_("Roll: %s"), &c[0]); | BLI_snprintf(str, sizeof(str), TIP_("Roll: %s"), &c[0]); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | static void initMirror(TransInfo *t) | ||||
| } | } | ||||
| } | } | ||||
| static void applyMirror(TransInfo *t, const int UNUSED(mval[2])) | static void applyMirror(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| 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_v3(t->values_final, t->values); | |||||
| /* | /* | ||||
| * 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 */ | ||||
| ▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | 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, 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_final, tvec); | ||||
| } | } | ||||
| else { | else { | ||||
| // snapGridIncrement(t, t->values); | // snapGridIncrement(t, t->values); | ||||
| applyNumInput(&t->num, t->values); | applyNumInput(&t->num, t->values); | ||||
| copy_v3_v3(t->values_final, t->values); | |||||
| } | } | ||||
| t->values[0] = floorf(t->values[0] + 0.5f); | t->values_final[0] = floorf(t->values_final[0] + 0.5f); | ||||
| t->values[1] = floorf(t->values[1] + 0.5f); | t->values_final[1] = floorf(t->values_final[1] + 0.5f); | ||||
| headerSeqSlide(t, t->values, str); | headerSeqSlide(t, t->values_final, str); | ||||
| applySeqSlideValue(t, t->values); | applySeqSlideValue(t, t->values_final); | ||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_status_text(t->sa, str); | ED_area_status_text(t->sa, str); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| ▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | static void headerTimeTranslate(TransInfo *t, char str[UI_MAX_DRAW_STR]) | ||||
| /* if numeric input is active, use results from that, otherwise apply snapping to result */ | /* if numeric input is active, use results from that, otherwise apply snapping to result */ | ||||
| if (hasNumInput(&t->num)) { | if (hasNumInput(&t->num)) { | ||||
| outputNumInput(&(t->num), tvec, &t->scene->unit); | outputNumInput(&(t->num), tvec, &t->scene->unit); | ||||
| } | } | ||||
| else { | else { | ||||
| const Scene *scene = t->scene; | const Scene *scene = t->scene; | ||||
| const short autosnap = getAnimEdit_SnapMode(t); | const short autosnap = getAnimEdit_SnapMode(t); | ||||
| const double secf = FPS; | const double secf = FPS; | ||||
| float val = t->values[0]; | float val = t->values_final[0]; | ||||
| /* apply snapping + frame->seconds conversions */ | /* apply snapping + frame->seconds conversions */ | ||||
| if (autosnap == SACTSNAP_STEP) { | if (autosnap == SACTSNAP_STEP) { | ||||
| /* frame step */ | /* frame step */ | ||||
| val = floorf(val + 0.5f); | val = floorf(val + 0.5f); | ||||
| } | } | ||||
| else if (autosnap == SACTSNAP_TSTEP) { | else if (autosnap == SACTSNAP_TSTEP) { | ||||
| /* second step */ | /* second step */ | ||||
| Show All 30 Lines | |||||
| { | { | ||||
| 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 */; | ||||
| t->values_final[0] = t->values[0]; | |||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | TransData *td = tc->data; | ||||
| TransData2D *td2d = tc->data_2d; | TransData2D *td2d = tc->data_2d; | ||||
| /* It doesn't matter whether we apply to t->data or | /* It doesn't matter whether we apply to t->data or | ||||
| * t->data2d, but t->data2d is more convenient. */ | * t->data2d, but t->data2d is more convenient. */ | ||||
| for (i = 0; i < tc->data_len; 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 */ | ||||
| /* check if any need to apply nla-mapping */ | /* check if any need to apply nla-mapping */ | ||||
| if (adt && (t->spacetype != SPACE_SEQ)) { | if (adt && (t->spacetype != SPACE_SEQ)) { | ||||
| deltax = t->values[0]; | deltax = t->values_final[0]; | ||||
| if (autosnap == SACTSNAP_TSTEP) { | if (autosnap == SACTSNAP_TSTEP) { | ||||
| deltax = (float)(floor(((double)deltax / secf) + 0.5) * secf); | deltax = (float)(floor(((double)deltax / secf) + 0.5) * secf); | ||||
| } | } | ||||
| else if (autosnap == SACTSNAP_STEP) { | else if (autosnap == SACTSNAP_STEP) { | ||||
| deltax = floorf(deltax + 0.5f); | deltax = floorf(deltax + 0.5f); | ||||
| } | } | ||||
| val = BKE_nla_tweakedit_remap(adt, td->ival, NLATIME_CONVERT_MAP); | val = BKE_nla_tweakedit_remap(adt, td->ival, NLATIME_CONVERT_MAP); | ||||
| val += deltax * td->factor; | val += deltax * td->factor; | ||||
| *(td->val) = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP); | *(td->val) = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP); | ||||
| } | } | ||||
| else { | else { | ||||
| deltax = val = t->values[0]; | deltax = val = t->values_final[0]; | ||||
| if (autosnap == SACTSNAP_TSTEP) { | if (autosnap == SACTSNAP_TSTEP) { | ||||
| val = (float)(floor(((double)deltax / secf) + 0.5) * secf); | val = (float)(floor(((double)deltax / secf) + 0.5) * secf); | ||||
| } | } | ||||
| else if (autosnap == SACTSNAP_STEP) { | else if (autosnap == SACTSNAP_STEP) { | ||||
| val = floorf(val + 0.5f); | val = floorf(val + 0.5f); | ||||
| } | } | ||||
| Show All 19 Lines | if (t->flag & T_MODAL) { | ||||
| /* we only need to calculate effect for time (applyTimeTranslate only needs that) */ | /* we only need to calculate effect for time (applyTimeTranslate only needs that) */ | ||||
| t->values[0] = cval[0] - sval[0]; | t->values[0] = cval[0] - sval[0]; | ||||
| } | } | ||||
| /* handle numeric-input stuff */ | /* handle numeric-input stuff */ | ||||
| t->vec[0] = t->values[0]; | t->vec[0] = t->values[0]; | ||||
| applyNumInput(&t->num, &t->vec[0]); | applyNumInput(&t->num, &t->vec[0]); | ||||
| t->values[0] = t->vec[0]; | t->values_final[0] = t->vec[0]; | ||||
| headerTimeTranslate(t, str); | headerTimeTranslate(t, str); | ||||
| applyTimeTranslateValue(t); | applyTimeTranslateValue(t); | ||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_status_text(t->sa, str); | ED_area_status_text(t->sa, str); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | static void headerTimeSlide(TransInfo *t, const float sval, char str[UI_MAX_DRAW_STR]) | ||||
| if (hasNumInput(&t->num)) { | if (hasNumInput(&t->num)) { | ||||
| outputNumInput(&(t->num), tvec, &t->scene->unit); | outputNumInput(&(t->num), tvec, &t->scene->unit); | ||||
| } | } | ||||
| else { | else { | ||||
| 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]; | ||||
| float cval = t->values[0]; | float cval = t->values_final[0]; | ||||
| float val; | float val; | ||||
| val = 2.0f * (cval - sval) / (maxx - minx); | val = 2.0f * (cval - sval) / (maxx - minx); | ||||
| CLAMP(val, -1.0f, 1.0f); | CLAMP(val, -1.0f, 1.0f); | ||||
| 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, TIP_("TimeSlide: %s"), &tvec[0]); | BLI_snprintf(str, UI_MAX_DRAW_STR, TIP_("TimeSlide: %s"), &tvec[0]); | ||||
| } | } | ||||
| static void applyTimeSlideValue(TransInfo *t, float sval) | static void applyTimeSlideValue(TransInfo *t, float sval) | ||||
| { | { | ||||
| 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]; | ||||
| t->values_final[0] = t->values[0]; | |||||
| /* 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_final[0]; | ||||
| saction->timeslide = cvalf; | saction->timeslide = cvalf; | ||||
| } | } | ||||
| /* It doesn't matter whether we apply to t->data or | /* It doesn't matter whether we apply to t->data or | ||||
| * t->data2d, but t->data2d is more convenient. */ | * t->data2d, but t->data2d is more convenient. */ | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | TransData *td = tc->data; | ||||
| for (i = 0; i < tc->data_len; i++, td++) { | 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_final[0]; | ||||
| /* only apply to data if in range */ | /* only apply to data if in range */ | ||||
| if ((sval > minx) && (sval < maxx)) { | if ((sval > minx) && (sval < maxx)) { | ||||
| float cvalc = CLAMPIS(cval, minx, maxx); | float cvalc = CLAMPIS(cval, minx, maxx); | ||||
| float ival = td->ival; | float ival = td->ival; | ||||
| float timefac; | float timefac; | ||||
| /* NLA mapping magic here works as follows: | /* NLA mapping magic here works as follows: | ||||
| Show All 34 Lines | static void applyTimeSlide(TransInfo *t, const int mval[2]) | ||||
| float minx = range[0]; | float minx = range[0]; | ||||
| float maxx = range[1]; | float maxx = range[1]; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| /* calculate mouse co-ordinates */ | /* calculate mouse co-ordinates */ | ||||
| UI_view2d_region_to_view(v2d, mval[0], mval[1], &cval[0], &cval[1]); | UI_view2d_region_to_view(v2d, mval[0], mval[1], &cval[0], &cval[1]); | ||||
| UI_view2d_region_to_view(v2d, t->mouse.imval[0], t->mouse.imval[1], &sval[0], &sval[1]); | UI_view2d_region_to_view(v2d, t->mouse.imval[0], t->mouse.imval[1], &sval[0], &sval[1]); | ||||
| /* t->values[0] stores cval[0], which is the current mouse-pointer location (in frames) */ | /* t->values_final[0] stores cval[0], which is the current mouse-pointer location (in frames) */ | ||||
| // XXX Need to be able to repeat this | // XXX Need to be able to repeat this | ||||
| /* t->values[0] = cval[0]; */ /* UNUSED (reset again later). */ | /* t->values_final[0] = cval[0]; */ /* UNUSED (reset again later). */ | ||||
| /* handle numeric-input stuff */ | /* handle numeric-input stuff */ | ||||
| t->vec[0] = 2.0f * (cval[0] - sval[0]) / (maxx - minx); | t->vec[0] = 2.0f * (cval[0] - sval[0]) / (maxx - minx); | ||||
| applyNumInput(&t->num, &t->vec[0]); | applyNumInput(&t->num, &t->vec[0]); | ||||
| t->values[0] = (maxx - minx) * t->vec[0] / 2.0f + sval[0]; | t->values_final[0] = (maxx - minx) * t->vec[0] / 2.0f + sval[0]; | ||||
| headerTimeSlide(t, sval[0], str); | headerTimeSlide(t, sval[0], str); | ||||
| applyTimeSlideValue(t, sval[0]); | applyTimeSlideValue(t, sval[0]); | ||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_status_text(t->sa, str); | ED_area_status_text(t->sa, str); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
| static void headerTimeScale(TransInfo *t, char str[UI_MAX_DRAW_STR]) | static void headerTimeScale(TransInfo *t, char str[UI_MAX_DRAW_STR]) | ||||
| { | { | ||||
| char tvec[NUM_STR_REP_LEN * 3]; | char tvec[NUM_STR_REP_LEN * 3]; | ||||
| if (hasNumInput(&t->num)) { | if (hasNumInput(&t->num)) { | ||||
| outputNumInput(&(t->num), tvec, &t->scene->unit); | outputNumInput(&(t->num), tvec, &t->scene->unit); | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", t->values[0]); | BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", t->values_final[0]); | ||||
| } | } | ||||
| BLI_snprintf(str, UI_MAX_DRAW_STR, TIP_("ScaleX: %s"), &tvec[0]); | BLI_snprintf(str, UI_MAX_DRAW_STR, TIP_("ScaleX: %s"), &tvec[0]); | ||||
| } | } | ||||
| static void applyTimeScaleValue(TransInfo *t) | static void applyTimeScaleValue(TransInfo *t) | ||||
| { | { | ||||
| 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; | ||||
| t->values_final[0] = t->values[0]; | |||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | TransData *td = tc->data; | ||||
| TransData2D *td2d = tc->data_2d; | TransData2D *td2d = tc->data_2d; | ||||
| for (i = 0; i < tc->data_len; 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; | ||||
| float startx = CFRA; | float startx = CFRA; | ||||
| float fac = t->values[0]; | float fac = t->values_final[0]; | ||||
| if (autosnap == SACTSNAP_TSTEP) { | if (autosnap == SACTSNAP_TSTEP) { | ||||
| fac = (float)(floor((double)fac / secf + 0.5) * secf); | fac = (float)(floor((double)fac / secf + 0.5) * secf); | ||||
| } | } | ||||
| else if (autosnap == SACTSNAP_STEP) { | else if (autosnap == SACTSNAP_STEP) { | ||||
| fac = floorf(fac + 0.5f); | fac = floorf(fac + 0.5f); | ||||
| } | } | ||||
| Show All 16 Lines | |||||
| 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]; | ||||
| applyNumInput(&t->num, &t->vec[0]); | applyNumInput(&t->num, &t->vec[0]); | ||||
| t->values[0] = t->vec[0]; | t->values_final[0] = t->vec[0]; | ||||
| headerTimeScale(t, str); | headerTimeScale(t, str); | ||||
| applyTimeScaleValue(t); | applyTimeScaleValue(t); | ||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_status_text(t->sa, str); | ED_area_status_text(t->sa, str); | ||||
| } | } | ||||
| Show All 16 Lines | |||||