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:
-rw-r--r--source/blender/editors/transform/transform.c23
-rw-r--r--source/blender/editors/transform/transform_constraints.c14
-rw-r--r--source/blender/editors/transform/transform_constraints.h2
-rw-r--r--source/blender/editors/transform/transform_generics.c110
-rw-r--r--source/blender/editors/transform/transform_mode_rotate.c24
-rw-r--r--source/blender/editors/transform/transform_orientations.c5
6 files changed, 94 insertions, 84 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index bc08cb91c0d..ab24bbb35d4 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -755,27 +755,22 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, bool is
stopConstraint(t);
}
else {
- setUserConstraint(t, V3D_ORIENT_GLOBAL, constraint_axis, msg1);
+ setUserConstraint(t, constraint_axis, msg1);
}
}
else if (!edit_2d) {
+ short orient_index = 1;
if (t->orient_curr == 0 || ELEM(cmode, '\0', axis)) {
/* Successive presses on existing axis, cycle orientation modes. */
- t->orient_curr = (short)((t->orient_curr + 1) % (int)ARRAY_SIZE(t->orient));
- transform_orientations_current_set(t, t->orient_curr);
+ orient_index = (short)((t->orient_curr + 1) % (int)ARRAY_SIZE(t->orient));
}
- if (t->orient_curr == 0) {
+ transform_orientations_current_set(t, orient_index);
+ if (orient_index == 0) {
stopConstraint(t);
}
else {
- const short orientation = t->orient[t->orient_curr].type;
- if (is_plane == false) {
- setUserConstraint(t, orientation, constraint_axis, msg2);
- }
- else {
- setUserConstraint(t, orientation, constraint_plane, msg3);
- }
+ setUserConstraint(t, constraint_axis, is_plane ? msg3 : msg2);
}
}
t->redraw |= TREDRAW_HARD;
@@ -1717,10 +1712,6 @@ 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 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(
t->region->type, drawTransformApply, t, REGION_DRAW_PRE_VIEW);
@@ -1868,7 +1859,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->orient[t->orient_curr].type, t->con.mode, "%s");
+ setUserConstraint(t, t->con.mode, "%s");
}
/* Don't write into the values when non-modal because they are already set from operator redo
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 805411ffc20..27ece728276 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -686,9 +686,15 @@ void setLocalConstraint(TransInfo *t, int mode, const char text[])
* ftext is a format string passed to BLI_snprintf. It will add the name of
* the orientation where %s is (logically).
*/
-void setUserConstraint(TransInfo *t, short orientation, int mode, const char ftext[])
+void setUserConstraint(TransInfo *t, int mode, const char ftext[])
{
char text[256];
+ short orientation = t->orient[t->orient_curr].type;
+ if (orientation == V3D_ORIENT_CUSTOM_MATRIX) {
+ /* Use the real value of the "orient_type". */
+ orientation = t->orient[0].type;
+ }
+
const char *spacename = transform_orientations_spacename_get(t, orientation);
BLI_snprintf(text, sizeof(text), ftext, spacename);
@@ -943,12 +949,10 @@ void stopConstraint(TransInfo *t)
void initSelectConstraint(TransInfo *t)
{
if (t->orient_curr == 0) {
- t->orient_curr = 1;
- transform_orientations_current_set(t, t->orient_curr);
+ transform_orientations_current_set(t, 1);
}
- short orientation = t->orient[t->orient_curr].type;
- setUserConstraint(t, orientation, CON_APPLY | CON_SELECT, "%s");
+ setUserConstraint(t, CON_APPLY | CON_SELECT, "%s");
setNearestAxis(t);
}
diff --git a/source/blender/editors/transform/transform_constraints.h b/source/blender/editors/transform/transform_constraints.h
index 4c901842964..ac62c057f9d 100644
--- a/source/blender/editors/transform/transform_constraints.h
+++ b/source/blender/editors/transform/transform_constraints.h
@@ -35,7 +35,7 @@ void transform_constraint_snap_axis_to_face(const TransInfo *t,
void setConstraint(TransInfo *t, int mode, const char text[]);
void setAxisMatrixConstraint(TransInfo *t, int mode, const char text[]);
void setLocalConstraint(TransInfo *t, int mode, const char text[]);
-void setUserConstraint(TransInfo *t, short orientation, int mode, const char text[]);
+void setUserConstraint(TransInfo *t, int mode, const char text[]);
void drawConstraint(TransInfo *t);
void drawPropCircle(const struct bContext *C, TransInfo *t);
void startConstraint(TransInfo *t);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index a2e1c50e375..ba87f0bcc38 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -442,7 +442,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 +468,28 @@ 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. */
+ for (int i = 3; i--;) {
+ constraint_axis[i] |= t->values[i] != 0.0f;
+ }
+ }
+ 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 +507,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 +524,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);
}
@@ -530,21 +538,21 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
/* 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;
+ orient_type_default = V3D_ORIENT_VIEW;
}
- else {
- orient_types[0] = orient_type_scene;
- }
- 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 +563,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")) &&
diff --git a/source/blender/editors/transform/transform_mode_rotate.c b/source/blender/editors/transform/transform_mode_rotate.c
index c0ddd4eb2a6..37b68877b08 100644
--- a/source/blender/editors/transform/transform_mode_rotate.c
+++ b/source/blender/editors/transform/transform_mode_rotate.c
@@ -195,28 +195,30 @@ static void applyRotationValue(TransInfo *t,
static void applyRotation(TransInfo *t, const int UNUSED(mval[2]))
{
char str[UI_MAX_DRAW_STR];
-
- float final;
-
- final = t->values[0];
-
- transform_snap_increment(t, &final);
-
float axis_final[3];
- /* Use the negative axis to match the default Z axis of the view matrix. */
- negate_v3_v3(axis_final, t->spacemtx[t->orient_axis]);
+ float final = t->values[0];
if ((t->con.mode & CON_APPLY) && t->con.applyRot) {
t->con.applyRot(t, NULL, NULL, axis_final, NULL);
}
-
- applySnapping(t, &final);
+ else {
+ copy_v3_v3(axis_final, t->spacemtx[t->orient_axis]);
+ if (!(t->flag & T_INPUT_IS_VALUES_FINAL) && (dot_v3v3(axis_final, t->viewinv[2]) > 0.0f)) {
+ /* The input is obtained according to the position of the mouse.
+ * Flip to better match the movement. */
+ final *= -1;
+ }
+ }
if (applyNumInput(&t->num, &final)) {
/* We have to limit the amount of turns to a reasonable number here,
* to avoid things getting *very* slow, see how applyRotationValue() handles those... */
final = large_rotation_limit(final);
}
+ else {
+ transform_snap_increment(t, &final);
+ applySnapping(t, &final);
+ }
t->values_final[0] = final;
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 276d9381a0b..dc693bd6b15 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -616,12 +616,17 @@ const char *transform_orientations_spacename_get(TransInfo *t, const short orien
void transform_orientations_current_set(TransInfo *t, const short orient_index)
{
+ if (t->orient_curr == orient_index) {
+ return;
+ }
+
const short orientation = t->orient[orient_index].type;
const char *spacename = transform_orientations_spacename_get(t, orientation);
BLI_strncpy(t->spacename, spacename, sizeof(t->spacename));
copy_m3_m3(t->spacemtx, t->orient[orient_index].matrix);
invert_m3_m3(t->spacemtx_inv, t->spacemtx);
+ t->orient_curr = orient_index;
}
/**