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:
authorGermano Cavalcante <germano.costa@ig.com.br>2020-05-22 18:34:29 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2020-05-22 18:39:56 +0300
commitc75a665c442e9aa906703fa1f46ec2dc621e9263 (patch)
tree8cbd7c9d8b6bece138f45e4bda470c0a64ffeec7 /source/blender/editors/transform/transform.c
parent06860ba29b517d1823b1dcd247363c99cc5af784 (diff)
Transform: refactoring - unify constraint and default orientation
Diffstat (limited to 'source/blender/editors/transform/transform.c')
-rw-r--r--source/blender/editors/transform/transform.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index bb4291555d0..5fc65522fe6 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -825,17 +825,17 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, bool is
}
}
else if (!edit_2d) {
- if (t->orientation.index == 0 || ELEM(cmode, '\0', axis)) {
+ if (t->orient_curr == 0 || ELEM(cmode, '\0', axis)) {
/* Successive presses on existing axis, cycle orientation modes. */
- t->orientation.index = (t->orientation.index + 1) % ARRAY_SIZE(t->orientation.types);
- initTransformOrientation(t->context, t, t->orientation.types[t->orientation.index]);
+ t->orient_curr = (short)((t->orient_curr + 1) % (int)ARRAY_SIZE(t->orient));
+ transform_orientations_current_set(t, t->orient_curr);
}
- if (t->orientation.index == 0) {
+ if (t->orient_curr == 0) {
stopConstraint(t);
}
else {
- const short orientation = t->orientation.types[t->orientation.index];
+ const short orientation = t->orient[t->orient_curr].type;
if (is_plane == false) {
setUserConstraint(t, orientation, constraint_axis, msg2);
}
@@ -983,7 +983,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
}
else if (transform_mode_is_changeable(t->mode)) {
/* Scale isn't normally very useful after extrude along normals, see T39756 */
- if ((t->con.mode & CON_APPLY) && (t->con.orientation == V3D_ORIENT_NORMAL)) {
+ if ((t->con.mode & CON_APPLY) && (t->orient[t->orient_curr].type == V3D_ORIENT_NORMAL)) {
stopConstraint(t);
}
@@ -1601,8 +1601,8 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
mul_m3_v3(t->spacemtx, t->values_final);
unit_m3(t->spacemtx);
- BLI_assert(t->orientation.index == 0);
- t->orientation.types[0] = V3D_ORIENT_GLOBAL;
+ BLI_assert(t->orient_curr == 0);
+ t->orient[0].type = V3D_ORIENT_GLOBAL;
}
// Save back mode in case we're in the generic operator
@@ -1713,19 +1713,20 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
if ((prop = RNA_struct_find_property(op->ptr, "orient_type"))) {
- short orient_set, orient_cur;
- orient_set = RNA_property_is_set(op->ptr, prop) ? RNA_property_enum_get(op->ptr, prop) : -1;
- orient_cur = t->orientation.types[t->orientation.index];
+ short orient_type_set, orient_type_curr;
+ orient_type_set = RNA_property_is_set(op->ptr, prop) ? RNA_property_enum_get(op->ptr, prop) :
+ -1;
+ orient_type_curr = t->orient[t->orient_curr].type;
- if (!ELEM(orient_cur, orient_set, V3D_ORIENT_CUSTOM_MATRIX)) {
- RNA_property_enum_set(op->ptr, prop, orient_cur);
- orient_set = orient_cur;
+ if (!ELEM(orient_type_curr, orient_type_set, V3D_ORIENT_CUSTOM_MATRIX)) {
+ RNA_property_enum_set(op->ptr, prop, orient_type_curr);
+ orient_type_set = orient_type_curr;
}
if (((prop = RNA_struct_find_property(op->ptr, "orient_matrix_type")) &&
!RNA_property_is_set(op->ptr, prop))) {
/* Set the first time to register on redo. */
- RNA_property_enum_set(op->ptr, prop, orient_set);
+ RNA_property_enum_set(op->ptr, prop, orient_type_set);
RNA_float_set_array(op->ptr, "orient_matrix", &t->spacemtx[0][0]);
}
}
@@ -1873,11 +1874,8 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
initTransInfo(C, t, op, event);
/* Use the custom orientation when it is set. */
- short orientation = t->orientation.types[0] == V3D_ORIENT_CUSTOM_MATRIX ?
- V3D_ORIENT_CUSTOM_MATRIX :
- t->orientation.types[t->orientation.index];
-
- initTransformOrientation(C, t, orientation);
+ short orient_index = t->orient[0].type == V3D_ORIENT_CUSTOM_MATRIX ? 0 : t->orient_curr;
+ transform_orientations_current_set(t, orient_index);
if (t->spacetype == SPACE_VIEW3D) {
t->draw_handle_apply = ED_region_draw_cb_activate(
@@ -2033,7 +2031,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
/* Constraint init from operator */
if (t->con.mode & CON_APPLY) {
- setUserConstraint(t, t->orientation.types[t->orientation.index], t->con.mode, "%s");
+ setUserConstraint(t, t->orient[t->orient_curr].type, t->con.mode, "%s");
}
/* Don't write into the values when non-modal because they are already set from operator redo