diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-29 04:49:02 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-29 04:49:02 +0300 |
commit | 535984a848865c07a39610b32a53432d1a078c59 (patch) | |
tree | 7c25d24b5b12c8d7b23de475d39a3d469f000d33 /source/blender | |
parent | 27cccaeccd219e08c6947c3789ed8498f12f7878 (diff) |
Cleanup: simplify transform orientation cycling
Remove dummy first index, store a pointer to the user orientation
instead of having it store twice (which could get out of sync).
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/transform/transform.c | 8 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 3 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_generics.c | 14 |
3 files changed, 13 insertions, 12 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 97834f064f4..b5abb2ba5c2 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -994,8 +994,9 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm else if (!edit_2d) { if (cmode != axis) { /* First press, constraint to an axis. */ - t->orientation.index = 1; - const short orientation = t->orientation.types[t->orientation.index]; + t->orientation.index = 0; + const short *orientation_ptr = t->orientation.types[t->orientation.index]; + const short orientation = orientation_ptr ? *orientation_ptr : V3D_MANIP_GLOBAL; if (is_plane == false) { setUserConstraint(t, orientation, constraint_axis, msg2); } @@ -1011,7 +1012,8 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm stopConstraint(t); } else { - const short orientation = t->orientation.types[t->orientation.index]; + const short *orientation_ptr = t->orientation.types[t->orientation.index]; + const short orientation = orientation_ptr ? *orientation_ptr : V3D_MANIP_GLOBAL; if (is_plane == false) { setUserConstraint(t, orientation, constraint_axis, msg2); } diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 8101833a609..5dff9f9f30a 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -503,11 +503,10 @@ typedef struct TransInfo { /*************** NEW STUFF *********************/ short launch_event; /* event type used to launch transform */ - /* Always: 'orientation_types[orientation_index]' */ struct { short user; short index; - short types[3]; + short *types[2]; /* this gets used when current_orientation is V3D_MANIP_CUSTOM */ TransformOrientation *custom; } orientation; diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index ba5b81ae641..ff3d52d7ddb 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1399,6 +1399,13 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->orientation.custom = BKE_scene_transform_orientation_find( t->scene, t->scene->orientation_index_custom); + t->orientation.index = 0; + ARRAY_SET_ITEMS( + t->orientation.types, + &t->orientation.user, + /* V3D_MANIP_GLOBAL */ + NULL); + /* exceptional case */ if (t->around == V3D_AROUND_LOCAL_ORIGINS) { if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL)) { @@ -1513,13 +1520,6 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->orientation.custom = custom_orientation; } - t->orientation.index = 0; - ARRAY_SET_ITEMS( - t->orientation.types, - V3D_MANIP_GLOBAL, /* Value isn't used (first index is no constraint). */ - t->orientation.user, - V3D_MANIP_GLOBAL); - if (op && ((prop = RNA_struct_find_property(op->ptr, "release_confirm")) && RNA_property_is_set(op->ptr, prop))) { |