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:
Diffstat (limited to 'source/blender/editors/transform/transform_generics.c')
-rw-r--r--source/blender/editors/transform/transform_generics.c134
1 files changed, 68 insertions, 66 deletions
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 8f590d87f4c..60848eb5678 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -61,6 +61,7 @@
#include "transform.h"
#include "transform_mode.h"
+#include "transform_orientations.h"
#include "transform_snap.h"
/* ************************** Functions *************************** */
@@ -165,9 +166,9 @@ void initTransDataContainers_FromObjectData(TransInfo *t,
TransDataContainer *tc = &t->data_container[i];
if (((t->flag & T_NO_MIRROR) == 0) && ((t->options & CTX_NO_MIRROR) == 0) &&
(objects[i]->type == OB_MESH)) {
- tc->use_mirror_axis_x = (((Mesh *)objects[i]->data)->editflag & ME_EDIT_MIRROR_X) != 0;
- tc->use_mirror_axis_y = (((Mesh *)objects[i]->data)->editflag & ME_EDIT_MIRROR_Y) != 0;
- tc->use_mirror_axis_z = (((Mesh *)objects[i]->data)->editflag & ME_EDIT_MIRROR_Z) != 0;
+ tc->use_mirror_axis_x = (((Mesh *)objects[i]->data)->symmetry & ME_SYMMETRY_X) != 0;
+ tc->use_mirror_axis_y = (((Mesh *)objects[i]->data)->symmetry & ME_SYMMETRY_Y) != 0;
+ tc->use_mirror_axis_z = (((Mesh *)objects[i]->data)->symmetry & ME_SYMMETRY_Z) != 0;
}
if (object_mode & OB_MODE_EDIT) {
@@ -269,9 +270,6 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->data_len_all = 0;
- t->val = 0.0f;
-
- zero_v3(t->vec);
zero_v3(t->center_global);
unit_m3(t->mat);
@@ -389,7 +387,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
else if (t->spacetype == SPACE_IMAGE) {
SpaceImage *sima = area->spacedata.first;
- // XXX for now, get View2D from the active region
+ /* XXX for now, get View2D from the active region. */
t->view = &region->v2d;
t->around = sima->around;
@@ -408,7 +406,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
/* image not in uv edit, nor in mask mode, can happen for some tools */
}
else if (t->spacetype == SPACE_NODE) {
- // XXX for now, get View2D from the active region
+ /* XXX for now, get View2D from the active region. */
t->view = &region->v2d;
t->around = V3D_AROUND_CENTER_BOUNDS;
}
@@ -431,9 +429,9 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
else {
if (region) {
- // XXX for now, get View2D from the active region
+ /* XXX for now, get View2D from the active region */
t->view = &region->v2d;
- // XXX for now, the center point is the midpoint of the data
+ /* XXX for now, the center point is the midpoint of the data */
}
else {
t->view = NULL;
@@ -442,7 +440,10 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
BLI_assert(is_zero_v4(t->values_modal_offset));
+
+ bool use_orient_axis = false;
bool t_values_set_is_array = false;
+
if (op && (prop = RNA_struct_find_property(op->ptr, "value")) &&
RNA_property_is_set(op->ptr, prop)) {
float values[4] = {0}; /* in case value isn't length 4, avoid uninitialized memory */
@@ -465,19 +466,26 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
}
+ if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis"))) {
+ t->orient_axis = RNA_property_enum_get(op->ptr, prop);
+ use_orient_axis = true;
+ }
+
if (op && (prop = RNA_struct_find_property(op->ptr, "constraint_axis"))) {
bool constraint_axis[3] = {false, false, false};
- if (RNA_property_is_set(op->ptr, prop)) {
- RNA_property_boolean_get_array(op->ptr, prop, constraint_axis);
- }
-
- if (t_values_set_is_array && t->flag & T_INPUT_IS_VALUES_FINAL) {
- /* For operators whose `t->values` is array, set constraint so that the
- * orientation is more intuitive in the Redo Panel. */
- for (int i = 3; i--;) {
- constraint_axis[i] |= t->values[i] != 0.0f;
+ if (t->flag & T_INPUT_IS_VALUES_FINAL) {
+ if (t_values_set_is_array) {
+ /* For operators whose `t->values` is array, set constraint so that the
+ * orientation is more intuitive in the Redo Panel. */
+ constraint_axis[0] = constraint_axis[1] = constraint_axis[2] = true;
+ }
+ else if (use_orient_axis) {
+ constraint_axis[t->orient_axis] = true;
}
}
+ else if (RNA_property_is_set(op->ptr, prop)) {
+ RNA_property_boolean_get_array(op->ptr, prop, constraint_axis);
+ }
if (constraint_axis[0] || constraint_axis[1] || constraint_axis[2]) {
t->con.mode |= CON_APPLY;
@@ -495,9 +503,13 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
{
- short orient_type_set = -1;
- short orient_type_matrix_set = -1;
+ short orient_types[3];
+ float custom_matrix[3][3];
+
+ short orient_type_default = V3D_ORIENT_GLOBAL;
short orient_type_scene = V3D_ORIENT_GLOBAL;
+ short orient_type_set = V3D_ORIENT_GLOBAL;
+ short orient_type_matrix_set = -1;
if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) {
TransformOrientationSlot *orient_slot = &t->scene->orientation_slots[SCE_ORIENT_DEFAULT];
@@ -508,14 +520,6 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
}
- short orient_types[3];
- float custom_matrix[3][3];
- bool use_orient_axis = false;
-
- if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis"))) {
- t->orient_axis = RNA_property_enum_get(op->ptr, prop);
- use_orient_axis = true;
- }
if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho"))) {
t->orient_axis_ortho = RNA_property_enum_get(op->ptr, prop);
}
@@ -523,28 +527,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_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;
- }
+ if (orient_type_set >= V3D_ORIENT_CUSTOM + BIF_countTransformOrientation(C)) {
+ orient_type_set = V3D_ORIENT_GLOBAL;
}
/* Change the default orientation to be used when redoing. */
- orient_types[0] = orient_type_set;
- orient_types[1] = orient_type_set;
- orient_types[2] = orient_type_scene;
+ orient_type_default = orient_type_set;
+ }
+ else if (t->con.mode & CON_APPLY) {
+ orient_type_set = orient_type_default = orient_type_scene;
}
else {
+ if (orient_type_set == orient_type_scene) {
+ BLI_assert(orient_type_set == V3D_ORIENT_GLOBAL);
+ orient_type_set = V3D_ORIENT_LOCAL;
+ }
+
if ((t->flag & T_MODAL) && (use_orient_axis || transform_mode_is_changeable(t->mode)) &&
(t->mode != TFM_ALIGN)) {
- orient_types[0] = V3D_ORIENT_VIEW;
- }
- else {
- orient_types[0] = orient_type_scene;
+ orient_type_default = V3D_ORIENT_VIEW;
}
- orient_types[1] = orient_type_scene;
- orient_types[2] = orient_type_scene != V3D_ORIENT_GLOBAL ? V3D_ORIENT_GLOBAL :
- V3D_ORIENT_LOCAL;
}
if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_matrix")) &&
@@ -555,39 +557,39 @@ 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_set = V3D_ORIENT_GLOBAL;
+ orient_type_matrix_set = orient_type_set;
}
if (orient_type_matrix_set == orient_type_set) {
/* Constraints are forced to use the custom matrix when redoing. */
- orient_types[0] = V3D_ORIENT_CUSTOM_MATRIX;
+ orient_type_set = V3D_ORIENT_CUSTOM_MATRIX;
}
}
- if (t->con.mode & CON_APPLY) {
- t->orient_curr = 1;
- }
+ orient_types[0] = orient_type_default;
+ orient_types[1] = orient_type_scene;
+ orient_types[2] = orient_type_set;
- /* For efficiency, avoid calculating the same orientation twice. */
- for (int i = 1; i < 3; i++) {
- t->orient[i].type = transform_orientation_matrix_get(
- C, t, orient_types[i], custom_matrix, t->orient[i].matrix);
- }
-
- if (orient_types[0] != orient_types[1]) {
- t->orient[0].type = transform_orientation_matrix_get(
- C, t, orient_types[0], custom_matrix, t->orient[0].matrix);
- }
- else {
- memcpy(&t->orient[0], &t->orient[1], sizeof(t->orient[0]));
+ for (int i = 0; i < 3; i++) {
+ /* For efficiency, avoid calculating the same orientation twice. */
+ int j;
+ for (j = 0; j < i; j++) {
+ if (orient_types[j] == orient_types[i]) {
+ memcpy(&t->orient[i], &t->orient[j], sizeof(*t->orient));
+ break;
+ }
+ }
+ if (j == i) {
+ t->orient[i].type = transform_orientation_matrix_get(
+ C, t, orient_types[i], custom_matrix, t->orient[i].matrix);
+ }
}
- const char *spacename = transform_orientations_spacename_get(t, orient_types[0]);
- BLI_strncpy(t->spacename, spacename, sizeof(t->spacename));
+ /* Set orient_curr to -1 in order to force the update in
+ * `transform_orientations_current_set`. */
+ t->orient_curr = -1;
+ transform_orientations_current_set(t, (t->con.mode & CON_APPLY) ? 2 : 0);
}
if (op && ((prop = RNA_struct_find_property(op->ptr, "release_confirm")) &&
@@ -710,7 +712,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
}
- // Mirror is not supported with PET, turn it off.
+ /* Mirror is not supported with PET, turn it off. */
#if 0
if (t->flag & T_PROP_EDIT) {
t->flag &= ~T_MIRROR;