From 535984a848865c07a39610b32a53432d1a078c59 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 29 Nov 2018 12:49:02 +1100 Subject: 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). --- source/blender/editors/transform/transform.c | 8 +++++--- source/blender/editors/transform/transform.h | 3 +-- source/blender/editors/transform/transform_generics.c | 14 +++++++------- 3 files changed, 13 insertions(+), 12 deletions(-) (limited to 'source') 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))) { -- cgit v1.2.3