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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-10-16 13:52:30 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-10-16 14:06:23 +0300
commit5b9ab20fe4447152ff12284a9a149f92a34af9a7 (patch)
tree22e37560c8df043254123e21bcb4b5571aa2118a /source
parent345175082b1387270988f0d61fd43f09bbcf6afd (diff)
Transform: axis support for shear tool
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/include/ED_transform.h1
-rw-r--r--source/blender/editors/transform/transform.c32
-rw-r--r--source/blender/editors/transform/transform.h1
-rw-r--r--source/blender/editors/transform/transform_ops.c11
4 files changed, 37 insertions, 8 deletions
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index 4b4c995980f..6687ed231c9 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -144,6 +144,7 @@ int BIF_countTransformOrientation(const struct bContext *C);
#define P_MIRROR_DUMMY (P_MIRROR | (1 << 9))
#define P_PROPORTIONAL (1 << 1)
#define P_AXIS (1 << 2)
+#define P_AXIS_ORTHO (1 << 16)
#define P_SNAP (1 << 3)
#define P_GEO_SNAP (P_SNAP | (1 << 4))
#define P_ALIGN_SNAP (P_GEO_SNAP | (1 << 5))
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 1a9515c82b0..49de222144f 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -2174,6 +2174,10 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
RNA_property_float_set_array(op->ptr, prop, t->axis);
}
+ if ((prop = RNA_struct_find_property(op->ptr, "axis_ortho"))) {
+ RNA_property_float_set_array(op->ptr, prop, t->axis_ortho);
+ }
+
if ((prop = RNA_struct_find_property(op->ptr, "mirror"))) {
RNA_property_boolean_set(op->ptr, prop, (t->flag & T_MIRROR) != 0);
}
@@ -2394,6 +2398,11 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
copy_v3_v3(t->axis_orig, t->axis);
}
+ if ((prop = RNA_struct_find_property(op->ptr, "axis_ortho")) && RNA_property_is_set(op->ptr, prop)) {
+ RNA_property_float_get_array(op->ptr, prop, t->axis_ortho);
+ normalize_v3(t->axis_ortho);
+ }
+
/* Constraint init from operator */
if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis")) && RNA_property_is_set(op->ptr, prop)) {
bool constraint_axis[3];
@@ -3328,6 +3337,15 @@ static void initShear(TransInfo *t)
t->num.unit_type[0] = B_UNIT_NONE; /* Don't think we have any unit here? */
t->flag |= T_NO_CONSTRAINT;
+
+ if (is_zero_v3(t->axis)) {
+ negate_v3_v3(t->axis, t->viewinv[2]);
+ normalize_v3(t->axis);
+ }
+ if (is_zero_v3(t->axis_ortho)) {
+ copy_v3_v3(t->axis_ortho, t->viewinv[0]);
+ normalize_v3(t->axis_ortho);
+ }
}
static eRedrawFlag handleEventShear(TransInfo *t, const wmEvent *event)
@@ -3367,15 +3385,12 @@ static eRedrawFlag handleEventShear(TransInfo *t, const wmEvent *event)
static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
{
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], axismat[3][3], axismat_inv[3][3];
float value;
int i;
char str[UI_MAX_DRAW_STR];
const bool is_local_center = transdata_check_local_center(t, t->around);
- copy_m3_m4(persmat, t->viewmat);
- invert_m3_m3(persinv, persmat);
-
value = t->values[0];
snapGridIncrement(t, &value);
@@ -3405,8 +3420,13 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
else
smat[0][1] = value;
- mul_m3_m3m3(tmat, smat, persmat);
- mul_m3_m3m3(totmat, persinv, tmat);
+ copy_v3_v3(axismat_inv[0], t->axis_ortho);
+ copy_v3_v3(axismat_inv[2], t->axis);
+ cross_v3_v3v3(axismat_inv[1], axismat_inv[0], axismat_inv[2]);
+ invert_m3_m3(axismat, axismat_inv);
+
+ mul_m3_m3m3(tmat, smat, axismat);
+ mul_m3_m3m3(totmat, axismat_inv, tmat);
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 758e2182de8..06ae7a87212 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -516,6 +516,7 @@ typedef struct TransInfo {
float auto_values[4];
float axis[3];
float axis_orig[3]; /* TransCon can change 'axis', store the original value here */
+ float axis_ortho[3];
bool remove_on_cancel; /* remove elements if operator is canceled */
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 3e6e1f85002..9d928027882 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -552,6 +552,14 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
RNA_def_property_ui_text(prop, "Axis", "The axis around which the transformation occurs");
}
+ if (flags & P_AXIS_ORTHO) {
+ prop = RNA_def_property(ot->srna, "axis_ortho", PROP_FLOAT, PROP_DIRECTION);
+ RNA_def_property_array(prop, 3);
+ /* Make this not hidden when there's a nice axis selection widget */
+ RNA_def_property_flag(prop, PROP_HIDDEN);
+ RNA_def_property_ui_text(prop, "Axis", "The orthogonal axis around which the transformation occurs");
+ }
+
if (flags & P_CONSTRAINT) {
RNA_def_boolean_vector(ot->srna, "constraint_axis", 3, NULL, "Constraint Axis", "");
prop = RNA_def_property(ot->srna, "constraint_orientation", PROP_ENUM, PROP_NONE);
@@ -834,8 +842,7 @@ static void TRANSFORM_OT_shear(struct wmOperatorType *ot)
WM_operatortype_props_advanced_begin(ot);
- Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT);
- // XXX Shear axis?
+ Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT | P_AXIS | P_AXIS_ORTHO);
}
static void TRANSFORM_OT_push_pull(struct wmOperatorType *ot)