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>2021-04-09 22:01:53 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-04-10 00:26:27 +0300
commit0515ff70ec09694d11e36e90212119574c65ada9 (patch)
treef710d7ef3cb8e682424633905a8164323c1b49bd /source/blender/editors/transform/transform_generics.c
parenta272eb38f433464e157b8370c78ed3b88ef8357c (diff)
Transform: Use "orient_matrix" as a default when available
The "orient_matrix" parameter was only used when contraint was defined. This change will hardly be noticed by the user, but it can be useful for addon developers. Possibly resolves T85734.
Diffstat (limited to 'source/blender/editors/transform/transform_generics.c')
-rw-r--r--source/blender/editors/transform/transform_generics.c69
1 files changed, 39 insertions, 30 deletions
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index e43a3ff3635..c0c4b22da98 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -409,9 +409,10 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
short orient_types[3];
float custom_matrix[3][3];
- short orient_type_scene = V3D_ORIENT_GLOBAL;
- short orient_type_set = V3D_ORIENT_GLOBAL;
- short orient_type_matrix_set = -1;
+ int orient_type_scene = V3D_ORIENT_GLOBAL;
+ int orient_type_default = -1;
+ int orient_type_set = -1;
+ int orient_type_matrix_set = -1;
bool use_orient_axis = false;
@@ -424,7 +425,13 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
}
- short orient_type_default = orient_type_scene;
+ 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 + BIF_countTransformOrientation(C)) {
+ orient_type_set = V3D_ORIENT_GLOBAL;
+ }
+ }
if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis"))) {
t->orient_axis = RNA_property_enum_get(op->ptr, prop);
@@ -435,52 +442,54 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->orient_axis_ortho = RNA_property_enum_get(op->ptr, prop);
}
- if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_type")) &&
+ if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_matrix")) &&
RNA_property_is_set(op->ptr, prop))) {
- orient_type_set = RNA_property_enum_get(op->ptr, prop);
- if (orient_type_set >= V3D_ORIENT_CUSTOM + BIF_countTransformOrientation(C)) {
- orient_type_set = V3D_ORIENT_GLOBAL;
+ RNA_property_float_get_array(op->ptr, prop, &custom_matrix[0][0]);
+
+ if ((prop = RNA_struct_find_property(op->ptr, "orient_matrix_type")) &&
+ 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_set = V3D_ORIENT_CUSTOM_MATRIX;
}
+ }
- /* Change the default orientation to be used when redoing. */
+ if (orient_type_set != -1) {
orient_type_default = orient_type_set;
}
+ else if (orient_type_matrix_set != -1) {
+ orient_type_default = orient_type_set = orient_type_matrix_set;
+ }
else if (t->con.mode & CON_APPLY) {
- orient_type_set = orient_type_scene;
+ orient_type_default = orient_type_set = orient_type_scene;
}
else {
- if (orient_type_set == orient_type_scene) {
- BLI_assert(orient_type_set == V3D_ORIENT_GLOBAL);
+ if (orient_type_scene == V3D_ORIENT_GLOBAL) {
orient_type_set = V3D_ORIENT_LOCAL;
}
+ else {
+ orient_type_set = V3D_ORIENT_GLOBAL;
+ }
if ((t->flag & T_MODAL) && (use_orient_axis || transform_mode_is_changeable(t->mode)) &&
(t->mode != TFM_ALIGN)) {
orient_type_default = V3D_ORIENT_VIEW;
}
- }
-
- if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_matrix")) &&
- RNA_property_is_set(op->ptr, prop))) {
- RNA_property_float_get_array(op->ptr, prop, &custom_matrix[0][0]);
-
- if ((prop = RNA_struct_find_property(op->ptr, "orient_matrix_type")) &&
- RNA_property_is_set(op->ptr, prop)) {
- orient_type_matrix_set = RNA_property_enum_get(op->ptr, prop);
- }
else {
- orient_type_matrix_set = orient_type_set;
+ orient_type_default = orient_type_scene;
}
+ }
- if (orient_type_matrix_set == orient_type_set) {
- /* Constraints are forced to use the custom matrix when redoing. */
- orient_type_set = V3D_ORIENT_CUSTOM_MATRIX;
- }
+ BLI_assert(!ELEM(-1, orient_type_default, orient_type_set));
+ if (orient_type_matrix_set == orient_type_set) {
+ /* Constraints are forced to use the custom matrix when redoing. */
+ orient_type_set = V3D_ORIENT_CUSTOM_MATRIX;
}
- orient_types[0] = orient_type_default;
- orient_types[1] = orient_type_scene;
- orient_types[2] = orient_type_set;
+ orient_types[0] = (short)orient_type_default;
+ orient_types[1] = (short)orient_type_scene;
+ orient_types[2] = (short)orient_type_set;
for (int i = 0; i < 3; i++) {
/* For efficiency, avoid calculating the same orientation twice. */