Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-02-27 16:19:37 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-02-27 16:23:43 +0300
commit8a432c1a4061492fbb0b8c1880a2408444e8009a (patch)
tree51484586263b0dbe505208fdbf54cc970f455f0d /source/blender/editors/transform
parent048088e1d2435d249f36feb4774d14aeaf1293e9 (diff)
Transform: shear redo support for other orientations
Shear gizmo now uses a single orientation and sets different ortho axis instead of constructing a different matrix for each handle - allowing the redo panel to select orientations.
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r--source/blender/editors/transform/transform.c61
-rw-r--r--source/blender/editors/transform/transform_generics.c7
-rw-r--r--source/blender/editors/transform/transform_gizmo_3d.c19
3 files changed, 54 insertions, 33 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 53c5fbddcdb..0c9fe0fbaf9 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -2159,15 +2159,29 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
RNA_property_boolean_set(op->ptr, prop, (t->flag & T_NO_MIRROR) == 0);
}
- short orientation = (t->con.mode & CON_APPLY) ? t->con.orientation : t->orientation.unset;
- if (orientation == V3D_ORIENT_CUSTOM) {
- const int orientation_index_custom = BKE_scene_transform_orientation_get_index(
- t->scene, t->orientation.custom);
- /* Maybe we need a t->con.custom_orientation?
- * Seems like it would always match t->orientation.custom. */
- orientation = V3D_ORIENT_CUSTOM + orientation_index_custom;
- BLI_assert(orientation >= V3D_ORIENT_CUSTOM);
+ /* Orientastion used for redo. */
+ short orientation;
+ if (t->con.mode & CON_APPLY) {
+ orientation = t->con.orientation;
+ if (orientation == V3D_ORIENT_CUSTOM) {
+ const int orientation_index_custom = BKE_scene_transform_orientation_get_index(
+ t->scene, t->orientation.custom);
+ /* Maybe we need a t->con.custom_orientation?
+ * Seems like it would always match t->orientation.custom. */
+ orientation = V3D_ORIENT_CUSTOM + orientation_index_custom;
+ BLI_assert(orientation >= V3D_ORIENT_CUSTOM);
+ }
+ }
+ else if ((t->orientation.user == V3D_ORIENT_CUSTOM_MATRIX) &&
+ (prop = RNA_struct_find_property(op->ptr, "orient_matrix_type")))
+ {
+ orientation = RNA_property_enum_get(op->ptr, prop);
}
+ else {
+ /* We're not using an orientation, use the fallback. */
+ orientation = t->orientation.unset;
+ }
+
if ((prop = RNA_struct_find_property(op->ptr, "orient_axis"))) {
if (t->flag & T_MODAL) {
@@ -2177,6 +2191,14 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
RNA_property_enum_set(op->ptr, prop, orient_axis);
}
}
+ else {
+ RNA_property_enum_set(op->ptr, prop, t->orient_axis);
+ }
+ }
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho"))) {
+ if (t->flag & T_MODAL) {
+ RNA_property_enum_set(op->ptr, prop, t->orient_axis_ortho);
}
}
@@ -3414,6 +3436,11 @@ static void initShear_mouseInputMode(TransInfo *t)
cross_v3_v3v3(dir, t->orient_matrix[t->orient_axis_ortho], t->orient_matrix[t->orient_axis]);
}
+ /* Without this, half the gizmo handles move in the opposite direction. */
+ if ((t->orient_axis_ortho + 1) % 3 != t->orient_axis) {
+ negate_v3(dir);
+ }
+
mul_mat3_m4_v3(t->viewmat, dir);
if (normalize_v2(dir) == 0.0f) {
dir[0] = 1.0f;
@@ -3429,21 +3456,13 @@ static void initShear(TransInfo *t)
t->transform = applyShear;
t->handleEvent = handleEventShear;
- t->orient_axis = 2;
- t->orient_axis_ortho = 1;
-
+ if (t->orient_axis == t->orient_axis_ortho) {
+ t->orient_axis = 2;
+ t->orient_axis_ortho = 1;
+ }
if (t->orient_matrix_is_set == false) {
t->orient_matrix_is_set = true;
- float *axis = t->orient_matrix[t->orient_axis];
- float *axis_ortho = t->orient_matrix[t->orient_axis_ortho];
- if (is_zero_v3(axis)) {
- negate_v3_v3(axis, t->viewinv[2]);
- normalize_v3(axis);
- }
- if (is_zero_v3(axis_ortho)) {
- copy_v3_v3(axis_ortho, t->viewinv[0]);
- normalize_v3(axis_ortho);
- }
+ copy_m3_m3(t->orient_matrix, t->spacemtx);
}
initShear_mouseInputMode(t);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index fb52918de9b..46eeb049b42 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -1518,6 +1518,13 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->around = V3D_AROUND_CENTER_BOUNDS;
}
+ if ((prop = RNA_struct_find_property(op->ptr, "orient_axis"))) {
+ t->orient_axis = RNA_property_enum_get(op->ptr, prop);
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho"))) {
+ t->orient_axis_ortho = RNA_property_enum_get(op->ptr, prop);
+ }
+
if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_matrix")) &&
RNA_property_is_set(op->ptr, prop)) &&
((t->flag & T_MODAL) ||
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index 1839b08f6a1..7cf526f69fc 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -2203,18 +2203,13 @@ static void WIDGETGROUP_xform_shear_refresh(const bContext *C, wmGizmoGroup *gzg
WM_gizmo_set_matrix_rotation_from_yz_axis(gz, rv3d->twmat[i_ortho_a], rv3d->twmat[i]);
WM_gizmo_set_matrix_location(gz, rv3d->twmat[3]);
- float axis[3];
- if (j == 0) {
- copy_v3_v3(axis, tbounds.axis[i_ortho_b]);
- }
- else {
- negate_v3_v3(axis, tbounds.axis[i_ortho_b]);
- }
- float orient_matrix[3][3];
- cross_v3_v3v3(orient_matrix[0], tbounds.axis[i_ortho_a], axis);
- copy_v3_v3(orient_matrix[1], tbounds.axis[i_ortho_a]);
- copy_v3_v3(orient_matrix[2], axis);
- RNA_float_set_array(&gzop->ptr, "orient_matrix", &orient_matrix[0][0]);
+ RNA_float_set_array(&gzop->ptr, "orient_matrix", &tbounds.axis[0][0]);
+ RNA_enum_set(&gzop->ptr, "orient_type", orient_slot->type);
+ RNA_enum_set(&gzop->ptr, "orient_matrix_type", orient_slot->type);
+
+ RNA_enum_set(&gzop->ptr, "orient_axis", i_ortho_b);
+ RNA_enum_set(&gzop->ptr, "orient_axis_ortho", i_ortho_a);
+
mul_v3_fl(gz->matrix_basis[0], 0.5f);
mul_v3_fl(gz->matrix_basis[1], 6.0f);
}