diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2020-05-12 21:44:08 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2020-05-12 21:44:19 +0300 |
commit | 289242fef912b0a51ca9b07972a304f651c6cc25 (patch) | |
tree | 7d21c90939465abcb57f3a12ed26334b8b81d836 /source/blender/editors/transform/transform_generics.c | |
parent | 36e3847093546232db3f16da9189ab7f30207126 (diff) |
Transform orientation tweaks
If the orietation is setted as a parameter, it is best to refer
to it as a constraint orietation so that it can be reused in
successive axis presses.
This is useful to retrieve the orientation of the extrude for example.
Diffstat (limited to 'source/blender/editors/transform/transform_generics.c')
-rw-r--r-- | source/blender/editors/transform/transform_generics.c | 74 |
1 files changed, 39 insertions, 35 deletions
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 0d6055563b4..4472facf183 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1651,20 +1651,17 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve { TransformOrientationSlot *orient_slot = &t->scene->orientation_slots[SCE_ORIENT_DEFAULT]; TransformOrientation *custom_orientation = NULL; - short orient_type_constraint = orient_slot->type; - if (orient_type_constraint == V3D_ORIENT_CUSTOM) { + short orient_type_set = -1; + short orient_type_matrix_set = -1; + short orient_type_scene = orient_slot->type; + if (orient_type_scene == V3D_ORIENT_CUSTOM) { const int index_custom = orient_slot->index_custom; custom_orientation = BKE_scene_transform_orientation_find(t->scene, index_custom); - orient_type_constraint += index_custom; + orient_type_scene += index_custom; } - short orient_type_default = orient_type_constraint; - short orient_type_matrix_set = -1; - - /* Init orientation 0 even if (t->con.mode & CON_APPLY) is true. - * So the extrude can use the orientation defined in the scene when - * changing constrain orientation. */ - int orient_index = 0; + short orient_type_default = V3D_ORIENT_GLOBAL; + short orient_type_constraint[2]; if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis"))) { t->orient_axis = RNA_property_enum_get(op->ptr, prop); @@ -1672,9 +1669,6 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve /* For transfor modes that require "orient_axis" use * `V3D_ORIENT_VIEW` as default. */ orient_type_default = V3D_ORIENT_VIEW; - if (t->con.mode & CON_APPLY) { - orient_index = 1; - } } if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho"))) { t->orient_axis_ortho = RNA_property_enum_get(op->ptr, prop); @@ -1682,7 +1676,26 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_type")) && RNA_property_is_set(op->ptr, prop))) { - orient_type_default = RNA_property_enum_get(op->ptr, prop); + orient_type_set = RNA_property_enum_get(op->ptr, prop); + if (orient_type_set >= V3D_ORIENT_CUSTOM) { + if (orient_type_set >= V3D_ORIENT_CUSTOM + BIF_countTransformOrientation(C)) { + orient_type_set = V3D_ORIENT_GLOBAL; + } + else { + custom_orientation = BKE_scene_transform_orientation_find( + t->scene, orient_type_default - V3D_ORIENT_CUSTOM); + } + } + + /* Change the default orientation to be used when redoing. */ + orient_type_default = orient_type_set; + orient_type_constraint[0] = orient_type_set; + orient_type_constraint[1] = orient_type_scene; + } + else { + orient_type_constraint[0] = orient_type_scene; + orient_type_constraint[1] = orient_type_scene != V3D_ORIENT_GLOBAL ? V3D_ORIENT_GLOBAL : + V3D_ORIENT_LOCAL; } if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_matrix")) && @@ -1693,36 +1706,27 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve RNA_property_is_set(op->ptr, prop)) { orient_type_matrix_set = RNA_property_enum_get(op->ptr, prop); } + else if (orient_type_set != -1) { + orient_type_matrix_set = orient_type_set; + } else { - orient_type_matrix_set = orient_type_default; + orient_type_matrix_set = orient_type_set = V3D_ORIENT_GLOBAL; } - if (orient_type_matrix_set == orient_type_default) { - /* Set the original orientation in the contraint to be used for redo. */ - orient_type_constraint = orient_type_default; - orient_index = 1; - + if (orient_type_matrix_set == orient_type_set) { + /* Constraints are forced to use the custom matrix when redoing. */ orient_type_default = V3D_ORIENT_CUSTOM_MATRIX; } } - if (orient_type_default >= V3D_ORIENT_CUSTOM) { - if (orient_type_default >= V3D_ORIENT_CUSTOM + BIF_countTransformOrientation(C)) { - orient_type_default = V3D_ORIENT_GLOBAL; - } - else { - custom_orientation = BKE_scene_transform_orientation_find( - t->scene, orient_type_default - V3D_ORIENT_CUSTOM); - } - } - t->orientation.types[0] = orient_type_default; - t->orientation.types[1] = orient_type_constraint; - t->orientation.types[2] = orient_type_constraint != V3D_ORIENT_GLOBAL ? V3D_ORIENT_GLOBAL : - V3D_ORIENT_LOCAL; - + t->orientation.types[1] = orient_type_constraint[0]; + t->orientation.types[2] = orient_type_constraint[1]; t->orientation.custom = custom_orientation; - t->orientation.index = orient_index; + + if (t->con.mode & CON_APPLY) { + t->orientation.index = 1; + } } if (op && ((prop = RNA_struct_find_property(op->ptr, "release_confirm")) && |